@foal/core
Version:
Full-featured Node.js framework, with no complexity
35 lines (34 loc) • 1.99 kB
TypeScript
import { Class, IAppController, ServiceManager } from '../core';
export declare const OPENAPI_SERVICE_ID = "OPENAPI_SERVICE_ID_a5NWKbBNBxVVZ";
type Middleware = (req: any, res: any, next: (err?: any) => any) => any;
type ErrorMiddleware = (err: any, req: any, res: any, next: (err?: any) => any) => any;
export interface CreateAppOptions {
expressInstance?: any;
serviceManager?: ServiceManager;
getHttpLogParams?: (tokens: any, req: any, res: any) => Record<string, any>;
preMiddlewares?: (Middleware | ErrorMiddleware)[];
afterPreMiddlewares?: (Middleware | ErrorMiddleware)[];
postMiddlewares?: (Middleware | ErrorMiddleware)[];
}
export declare function getHttpLogParamsDefault(tokens: any, req: any, res: any): Record<string, any>;
/**
* Create an Express application from the root controller.
*
* @export
* @param {Class<IAppController>} AppController - The root controller, usually called `AppController`
* and located in `src/app`.
* @param {CreateAppOptions} [options] - Options containaining Express middlewares or other settings.
* @param {any} [options.expressInstance] - Express instance to be used as base for the
* returned application.
* @param {boolean} [options.methods.handleError] - Specifies if AppController.handleError should be
* used to handle errors.
* @param {ServiceManager} [options.serviceManager] - Prebuilt and configured Service Manager for
* optionally overriding the mapped identities.
* @param {(RequestHandler | ErrorRequestHandler)[]} [options.preMiddlewares] Express
* middlewares to be executed before the controllers and hooks.
* @param {(RequestHandler | ErrorRequestHandler)[]} [options.postMiddlewares] Express
* middlewares to be executed after the controllers and hooks, but before the 500 or 404 handler get called.
* @returns {Promise<any>} The express application.
*/
export declare function createApp(AppController: Class<IAppController>, options?: CreateAppOptions): Promise<any>;
export {};