@pipeline-builder/api-server
v3.3.29
Published
Express server infrastructure for Pipeline Builder: app factory, middleware (CORS, Helmet, rate limiting, idempotency, ETag), request context, route wrappers, health-check helpers, and SSE support.
Maintainers
Readme
@pipeline-builder/api-server
Express server infrastructure for Pipeline Builder: the app factory, middleware (CORS, Helmet, rate limiting, idempotency, ETag), request context with structured logging, route wrappers, health-check helpers, and SSE support used by every backend service.
Key Exports
App Factory
createApp({ checkDependencies?, warmupHooks?, ... })— Creates a configured Express app with CORS, Helmet, rate limiting,/health(liveness),/ready(readiness),/warmup,/metrics, and OpenAPI/Swagger UI. PasswarmupHooks: [() => mongoose.connection.db?.admin().ping()]for services that need to pre-warm Mongo/Redis on cold start.runServer,startServer— Server lifecycle with graceful shutdown
Middleware
attachRequestContext/createRequestContext— Identity + logging attached to every requestrequireOrgId— Validatesx-org-idheadercheckQuota— Quota enforcement middlewareetagMiddleware— Conditional GET (304 Not Modified) supportidempotencyMiddleware— Idempotency key handling
Route Helpers
withRoute— Wraps async handlers with context extraction, orgId validation, and error mappinggetContext— RetrievesRequestContextfrom an Express requestcreateProtectedRoute,createAuthenticatedWithOrgRoute— Composable middleware chains
Health & Quota Helpers
postgresHealthCheck— Returns{ postgres: 'connected' | 'disconnected' }(the'unknown'fallback was removed — a real probe failure now correctly fails/ready)mongoHealthCheck(connection)— Returns{ mongodb: 'connected' | 'unknown' | 'disconnected' }based on mongoose'sreadyState(1 = connected, 2 = connecting/unknown, anything else = disconnected)incrementQuotaFromCtx(service, { req, ctx, orgId }, type)— Increments a quota counter using values pulled from the route context.typeis'plugins' | 'pipelines' | 'apiCalls' | 'aiCalls'.
Server-Sent Events
SSEManager— Connection manager for streaming logs to clients
License
Apache-2.0. See LICENSE.
