Application
Application API Reference
createApp()
Create an Express instance.
function createApp(options: AppOptions): Promise<Express>
AppOptions
Type:
type AppOptions = {
isDev?: boolean
enableHttpLogging?: boolean
cors?: CorsOptions | false
middlewares?: RouteMiddleware[]
onException?: (err: unknown, req: Request) => void
onRequestComplete?: (e: CompleteRequestEvent) => void
useBeforeRoutes?: (app: Express) => void;
useAfterRoutes?: (app: Express) => void;
plugins?: Plugin[];
}
isDev: when set totrue, global error handler will output errors details.enableHttpLogging: requiresmorganas optionalDependency. Set to true to log incoming http requests.cors: CORS are enabled by default. Set to false to disable.middlewares: define your global middlewares here.onException: if defined, this function is called by global error handler, before returning error response.onRequestComplete: if defined, this function is called after response has been returned.useBeforeRoutes: hook to be used to register Express middlewaresuseAfterRoutes: hook to be used to register Express error handlerspluginsoptional internal or external plugins that can extend your application