1 | import { ValidatorOptions } from 'class-validator';
|
2 | import { ClassTransformOptions } from 'class-transformer';
|
3 | import { CurrentUserChecker } from '../CurrentUserChecker';
|
4 | import { AuthorizationChecker } from '../AuthorizationChecker';
|
5 | import { ActionMetadata } from '../metadata/ActionMetadata';
|
6 | import { ParamMetadata } from '../metadata/ParamMetadata';
|
7 | import { MiddlewareMetadata } from '../metadata/MiddlewareMetadata';
|
8 | import { Action } from '../Action';
|
9 | import { RoutingControllersOptions } from '../RoutingControllersOptions';
|
10 | /**
|
11 | * Base driver functionality for all other drivers.
|
12 | * Abstract layer to organize controllers integration with different http server implementations.
|
13 | */
|
14 | export declare abstract class BaseDriver {
|
15 | /**
|
16 | * Reference to the underlying framework app object.
|
17 | */
|
18 | app: any;
|
19 | /**
|
20 | * Indicates if class-transformer should be used or not.
|
21 | */
|
22 | useClassTransformer: boolean;
|
23 | /**
|
24 | * Indicates if class-validator should be used or not.
|
25 | */
|
26 | enableValidation: boolean;
|
27 | /**
|
28 | * Global class transformer options passed to class-transformer during classToPlain operation.
|
29 | * This operation is being executed when server returns response to user.
|
30 | */
|
31 | classToPlainTransformOptions: ClassTransformOptions;
|
32 | /**
|
33 | * Global class-validator options passed during validate operation.
|
34 | */
|
35 | validationOptions: ValidatorOptions;
|
36 | /**
|
37 | * Global class transformer options passed to class-transformer during plainToClass operation.
|
38 | * This operation is being executed when parsing user parameters.
|
39 | */
|
40 | plainToClassTransformOptions: ClassTransformOptions;
|
41 | /**
|
42 | * Indicates if default routing-controllers error handler should be used or not.
|
43 | */
|
44 | isDefaultErrorHandlingEnabled: boolean;
|
45 | /**
|
46 | * Indicates if routing-controllers should operate in development mode.
|
47 | */
|
48 | developmentMode: boolean;
|
49 | /**
|
50 | * Global application prefix.
|
51 | */
|
52 | routePrefix: string;
|
53 | /**
|
54 | * Indicates if cors are enabled.
|
55 | * This requires installation of additional module (cors for express and @koa/cors for koa).
|
56 | */
|
57 | cors?: boolean | Object;
|
58 | /**
|
59 | * Map of error overrides.
|
60 | */
|
61 | errorOverridingMap: {
|
62 | [key: string]: any;
|
63 | };
|
64 | /**
|
65 | * Special function used to check user authorization roles per request.
|
66 | * Must return true or promise with boolean true resolved for authorization to succeed.
|
67 | */
|
68 | authorizationChecker?: AuthorizationChecker;
|
69 | /**
|
70 | * Special function used to get currently authorized user.
|
71 | */
|
72 | currentUserChecker?: CurrentUserChecker;
|
73 | protected transformResult(result: any, action: ActionMetadata, options: Action): any;
|
74 | protected processJsonError(error: any): any;
|
75 | protected processTextError(error: any): any;
|
76 | protected merge(obj1: any, obj2: any): any;
|
77 | /**
|
78 | * Initializes the things driver needs before routes and middleware registration.
|
79 | */
|
80 | abstract initialize(): void;
|
81 | /**
|
82 | * Registers given middleware.
|
83 | */
|
84 | abstract registerMiddleware(middleware: MiddlewareMetadata, options: RoutingControllersOptions): void;
|
85 | /**
|
86 | * Registers action in the driver.
|
87 | */
|
88 | abstract registerAction(action: ActionMetadata, executeCallback: (options: Action) => any): void;
|
89 | /**
|
90 | * Registers all routes in the framework.
|
91 | */
|
92 | abstract registerRoutes(): void;
|
93 | /**
|
94 | * Gets param from the request.
|
95 | */
|
96 | abstract getParamFromRequest(actionOptions: Action, param: ParamMetadata): any;
|
97 | /**
|
98 | * Defines an algorithm of how to handle error during executing controller action.
|
99 | */
|
100 | abstract handleError(error: any, action: ActionMetadata, options: Action): any;
|
101 | /**
|
102 | * Defines an algorithm of how to handle success result of executing controller action.
|
103 | */
|
104 | abstract handleSuccess(result: any, action: ActionMetadata, options: Action): void;
|
105 | }
|