New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@lemur-bookstores/secure-stack-core

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lemur-bookstores/secure-stack-core

Core framework - Foundation of SecureStack

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

@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

Keywords

securestack

FAQs

Package last updated on 30 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts