Skip to content

@privateaim/server-http-kit ​

HTTP server middleware, request handling utilities, and Swagger/OpenAPI documentation generation for Hub services.

Installation ​

bash
npm install @privateaim/server-http-kit

Usage ​

Middleware ​

typescript
import { ForceLoggedInMiddleware } from '@privateaim/server-http-kit';

Request Helpers ​

typescript
import {
    useRequestIdentityRealm,
    useRequestPermissionEvaluator, // the request's authup IPermissionEvaluator
} from '@privateaim/server-http-kit';

Swagger Generation ​

typescript
import { generateSwaggerDocumentation } from '@privateaim/server-http-kit';

API ​

Exports ​

ModuleDescription
middlewaresAuth middleware (ForceLoggedInMiddleware, ForceIdentityOrCapabilityMiddleware, ForceIdentityOrStreamCapabilityMiddleware); createAuthupTokenVerifier({ baseURL, client: { id, secret, realm }, redisClient?, cache? }) for the tokenVerifier option, which introspects as client and caches results per that client; createAuthupCapabilityTokenVerifier for the capability option of the authorization middleware
requestRequest identity, permission, and query helpers; useRequestCapability (a capability request has a capability and no identity, permission evaluator or token)
healthmountHealthRoutes(app, health) — anonymous GET/HEAD /livez and /readyz (200/503, Cache-Control: no-store); mount before every middleware
swaggerOpenAPI/Swagger documentation generator
constantsHTTP-specific constants

Dependencies ​

  • @authup/server-adapter — Authup middleware
  • routup — HTTP routing framework
  • @privateaim/server-kit — Server foundation
  • hapic — HTTP client utilities
  • cors — CORS middleware