npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lemur-bookstores/secure-stack-core

v0.2.0

Published

Core framework - Foundation of SecureStack

Readme

@lemur-bookstores/secure-stack-core

Core framework - Foundation of SecureStack

Installation

npm install @lemur-bookstores/secure-stack-core
# or
pnpm add @lemur-bookstores/secure-stack-core

Features

  • Context System - Flexible context builder with extension support
  • Middleware Pipeline - Koa-style middleware composition
  • Router Abstraction - Type-safe procedure definitions
  • Error Handling - Comprehensive error system with codes
  • Type Inference - Full TypeScript support
  • Service Mesh Support - Built-in mesh configuration

Quick Start

import { SecureStack, router, ServiceType } from '@lemur-bookstores/secure-stack-core';
import { z } from 'zod';

const app = new SecureStack({
  name: 'my-service',
  port: 3000,
  type: ServiceType.Microservice,
});

const userRouter = router()
  .query('getUser', {
    input: z.string(),
    handler: async ({ input }) => {
      return { id: input, name: 'John Doe' };
    }
  });

app.router('user', userRouter);
await app.start();

Middleware

SecureStack includes built-in middlewares:

import { logger, errorHandler, cors } from '@lemur-bookstores/secure-stack-core';

app.use(errorHandler());
app.use(logger());
app.use(cors({ origin: '*' }));

Custom Middleware

app.use(async (ctx, next) => {
  console.log('Before');
  await next();
  console.log('After');
});

Context

Create and extend contexts:

import { createContext } from '@lemur-bookstores/secure-stack-core';

const contextBuilder = createContext<{ user?: User }>();

app.setContextFactory((initial) => {
  return contextBuilder.create(initial);
});

Error Handling

Use built-in error types:

import { SecureStackError } from '@lemur-bookstores/secure-stack-core';

// Throw errors
throw SecureStackError.notFound('User not found');
throw SecureStackError.unauthorized();
throw SecureStackError.forbidden('Access denied');
throw SecureStackError.validationError('Invalid input');

Router

Define type-safe procedures:

const router = router()
  .query('getName', {
    input: z.string(),
    handler: async ({ input }) => {
      return { name: input };
    }
  })
  .mutation('create', {
    input: z.object({ name: z.string() }),
    handler: async ({ input }) => {
      return { id: '123', ...input };
    }
  });

Service Mesh

Enable the service mesh:

import { ServiceType, EncryptionMode, DiscoveryMode } from '@lemur-bookstores/secure-stack-core';

const app = new SecureStack({
  name: 'user-service',
  port: 50051,
  type: ServiceType.Microservice,
  mesh: {
    enabled: true,
    security: {
      encryption: EncryptionMode.Hybrid,
      rsaKeySize: 4096,
      aesKeySize: 256,
    },
    discovery: {
      mode: DiscoveryMode.Static,
      services: [
        { id: 'auth-service', host: 'auth.internal', port: 50052 }
      ]
    }
  }
});

// Connect to other services
const authService = app.mesh.connect('auth-service');
const response = await authService.call('verify', { token: 'abc' });

API Reference

SecureStack

Main framework class.

Methods:

  • router(name, router) - Register a router
  • use(middleware) - Add middleware
  • setContextFactory(factory) - Set context factory
  • createContext(initial) - Create context instance
  • start() - Start the server
  • stop() - Stop the server

router()

Create a new router.

Methods:

  • query(name, config) - Define a query procedure
  • mutation(name, config) - Define a mutation procedure
  • subscription(name, config) - Define a subscription procedure
  • middleware(fn) - Add middleware to router

Enums

  • ServiceType - Microservice | Gateway
  • EncryptionMode - Hybrid | TLS | None
  • DiscoveryMode - Static | DNS | Consul | Etcd
  • ErrorCode - All error codes

Examples

See the examples/ directory for complete examples:

  • examples/basic - Basic usage
  • examples/advanced - Middleware, errors, validation

License

MIT © @elkincp5