UNPKG

1.96 kBTypeScriptView Raw
1import { UseMetadata } from '../../metadata/UseMetadata';
2import { MiddlewareMetadata } from '../../metadata/MiddlewareMetadata';
3import { ActionMetadata } from '../../metadata/ActionMetadata';
4import { Action } from '../../Action';
5import { ParamMetadata } from '../../metadata/ParamMetadata';
6import { BaseDriver } from '../BaseDriver';
7import { RoutingControllersOptions } from '../../index';
8/**
9 * Integration with express framework.
10 */
11export declare class ExpressDriver extends BaseDriver {
12 express?: any;
13 constructor(express?: any);
14 /**
15 * Initializes the things driver needs before routes and middlewares registration.
16 */
17 initialize(): void;
18 /**
19 * Registers middleware that run before controller actions.
20 */
21 registerMiddleware(middleware: MiddlewareMetadata, options: RoutingControllersOptions): void;
22 /**
23 * Registers action in the driver.
24 */
25 registerAction(actionMetadata: ActionMetadata, executeCallback: (options: Action) => any): void;
26 /**
27 * Registers all routes in the framework.
28 */
29 registerRoutes(): void;
30 /**
31 * Gets param from the request.
32 */
33 getParamFromRequest(action: Action, param: ParamMetadata): any;
34 /**
35 * Handles result of successfully executed controller action.
36 */
37 handleSuccess(result: any, action: ActionMetadata, options: Action): void;
38 /**
39 * Handles result of failed executed controller action.
40 */
41 handleError(error: any, action: ActionMetadata | undefined, options: Action): any;
42 /**
43 * Creates middlewares from the given "use"-s.
44 */
45 protected prepareMiddlewares(uses: UseMetadata[]): Function[];
46 /**
47 * Dynamically loads express module.
48 */
49 protected loadExpress(): void;
50 /**
51 * Dynamically loads body-parser module.
52 */
53 protected loadBodyParser(): any;
54 /**
55 * Dynamically loads multer module.
56 */
57 protected loadMulter(): any;
58}