covenix / toExpress
Function: toExpress()
toExpress(
api,options?):Express
Defined in: src/express.ts:89
Convenience builder that assembles a ready-to-listen Express app for a Covenix instance, collapsing the usual boilerplate (express() + express.json() + mount + serveDocs + covenixErrorHandler) into one call — with the middleware order fixed by construction:
configure → body parsers (json / urlencoded) → routes → docs → after → error handler.
This is opt-in sugar, not the only way in: you can still build the app yourself and call Covenix.mount / Covenix.serveDocs directly. Each step here can be disabled (false) or customized via ToExpressOptions. Returns the app without listening — ideal for supertest-style tests; use serve to also listen.
Parameters
api
options?
ToExpressOptions = {}
Returns
Express
Example
const app = toExpress(api, {
configure: (app) => app.use(cors()), // before routes
json: { limit: '1mb' },
});