UNPKG

3.39 kBTypeScriptView Raw
1import { ClassTransformOptions } from 'class-transformer';
2import { ValidatorOptions } from 'class-validator';
3import { AuthorizationChecker } from './AuthorizationChecker';
4import { CurrentUserChecker } from './CurrentUserChecker';
5/**
6 * Routing controller initialization options.
7 */
8export interface RoutingControllersOptions {
9 /**
10 * Indicates if cors are enabled.
11 * This requires installation of additional module (cors for express and kcors for koa).
12 */
13 cors?: boolean | Object;
14 /**
15 * Global route prefix, for example '/api'.
16 */
17 routePrefix?: string;
18 /**
19 * List of controllers to register in the framework or directories from where to import all your controllers.
20 */
21 controllers?: Function[] | string[];
22 /**
23 * List of middlewares to register in the framework or directories from where to import all your middlewares.
24 */
25 middlewares?: Function[] | string[];
26 /**
27 * List of interceptors to register in the framework or directories from where to import all your interceptors.
28 */
29 interceptors?: Function[] | string[];
30 /**
31 * Indicates if class-transformer should be used to perform serialization / deserialization.
32 */
33 classTransformer?: boolean;
34 /**
35 * Global class transformer options passed to class-transformer during classToPlain operation.
36 * This operation is being executed when server returns response to user.
37 */
38 classToPlainTransformOptions?: ClassTransformOptions;
39 /**
40 * Global class transformer options passed to class-transformer during plainToClass operation.
41 * This operation is being executed when parsing user parameters.
42 */
43 plainToClassTransformOptions?: ClassTransformOptions;
44 /**
45 * Indicates if class-validator should be used to auto validate objects injected into params.
46 * You can also directly pass validator options to enable validator with a given options.
47 */
48 validation?: boolean | ValidatorOptions;
49 /**
50 * Indicates if development mode is enabled.
51 * By default its enabled if your NODE_ENV is not equal to "production".
52 */
53 development?: boolean;
54 /**
55 * Indicates if default routing-controller's error handler is enabled or not.
56 * Enabled by default.
57 */
58 defaultErrorHandler?: boolean;
59 /**
60 * Map of error overrides.
61 */
62 errorOverridingMap?: {
63 [key: string]: any;
64 };
65 /**
66 * Special function used to check user authorization roles per request.
67 * Must return true or promise with boolean true resolved for authorization to succeed.
68 */
69 authorizationChecker?: AuthorizationChecker;
70 /**
71 * Special function used to get currently authorized user.
72 */
73 currentUserChecker?: CurrentUserChecker;
74 /**
75 * Default settings
76 */
77 defaults?: {
78 /**
79 * If set, all null responses will return specified status code by default
80 */
81 nullResultCode?: number;
82 /**
83 * If set, all undefined responses will return specified status code by default
84 */
85 undefinedResultCode?: number;
86 /**
87 * Default param options
88 */
89 paramOptions?: {
90 /**
91 * If true, all non-set parameters will be required by default
92 */
93 required?: boolean;
94 };
95 };
96}