@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-kitUsage
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
| Module | Description |
|---|---|
middlewares | Auth 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 |
request | Request identity, permission, and query helpers; useRequestCapability (a capability request has a capability and no identity, permission evaluator or token) |
health | mountHealthRoutes(app, health) — anonymous GET/HEAD /livez and /readyz (200/503, Cache-Control: no-store); mount before every middleware |
swagger | OpenAPI/Swagger documentation generator |
constants | HTTP-specific constants |
Dependencies
@authup/server-adapter— Authup middlewareroutup— HTTP routing framework@privateaim/server-kit— Server foundationhapic— HTTP client utilitiescors— CORS middleware