Skip to content

@saflib/express


@saflib/express

Packages which implement express servers should import and use this package.

Interfaces

InterfaceDescription
GlobalMiddlewareOptionsOptions for creating global middleware.
ScopedMiddlewareOptionsOptions for creating scoped middleware.
StartServerOptionsOptions when starting an Express server.

Functions

FunctionDescription
createErrorMiddlewareMiddleware which should be placed after all routes.
createGlobalMiddlewareMiddleware which should be put at the top of the middleware stack, and run for every request.
createHandlerWrapper for Express handlers. Promisifies the handler, ensuring any uncaught exceptions get passed to next.
createScopedMiddlewareMiddleware which should only be applied to a subset of routes in an express server. This middleware all depends on the OpenAPI spec for those routes.
startExpressServerGiven an Express app and options, starts the server and sets it up for graceful shutdown.