resting-squirrel-controller 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +224 -224
- package/dist/controller.d.ts +257 -257
- package/dist/controller.js +373 -379
- package/dist/controller.js.map +1 -1
- package/dist/decorators/controller-options.d.ts +17 -17
- package/dist/decorators/controller-options.js +15 -15
- package/dist/decorators/deprecated.d.ts +3 -3
- package/dist/decorators/deprecated.js +10 -10
- package/dist/decorators/methods.d.ts +6 -6
- package/dist/decorators/methods.js +107 -107
- package/dist/decorators/options.d.ts +25 -25
- package/dist/decorators/options.js +17 -17
- package/dist/decorators/resource.d.ts +3 -3
- package/dist/decorators/resource.js +7 -7
- package/dist/decorators/version.d.ts +3 -3
- package/dist/decorators/version.js +7 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/utils.d.ts +194 -193
- package/dist/utils.js +31 -31
- package/package.json +66 -66
- package/index.js +0 -1
- package/tslint.json +0 -78
package/dist/controller.d.ts
CHANGED
|
@@ -1,257 +1,257 @@
|
|
|
1
|
-
import { Application, Field, IRequest, IResponse, IRouteOptions, Response, RouteAuth } from 'resting-squirrel';
|
|
2
|
-
import { ArgsDto, BaseDto, RequestDto, ResponseDto } from 'resting-squirrel-dto';
|
|
3
|
-
import { IOptions, RSDtoType } from './decorators/options';
|
|
4
|
-
export interface IStore {
|
|
5
|
-
__endpoints__: Array<IEndpoint>;
|
|
6
|
-
__options__: {
|
|
7
|
-
[propertyKey: string]: IOptions;
|
|
8
|
-
};
|
|
9
|
-
__deprecated__: Array<string>;
|
|
10
|
-
}
|
|
11
|
-
export interface IEndpoint {
|
|
12
|
-
method: 'get' | 'put' | 'post' | 'delete' | 'head';
|
|
13
|
-
route: string;
|
|
14
|
-
callback: (req: IRequest, res: any) => void | Promise<any>;
|
|
15
|
-
propertyKey: string;
|
|
16
|
-
}
|
|
17
|
-
declare class E {
|
|
18
|
-
/**
|
|
19
|
-
* The endpoint is executed with `PUT` method.
|
|
20
|
-
*/
|
|
21
|
-
static put: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
22
|
-
/**
|
|
23
|
-
* The endpoint is executed with `GET` method.
|
|
24
|
-
*/
|
|
25
|
-
static get: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
26
|
-
/**
|
|
27
|
-
* The endpoint is executed with `POST` method.
|
|
28
|
-
*/
|
|
29
|
-
static post: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
30
|
-
/**
|
|
31
|
-
* The endpoint is executed with `DELETE` method.
|
|
32
|
-
*/
|
|
33
|
-
static delete: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
34
|
-
/**
|
|
35
|
-
* The endpoint is executed with `HEAD` method.
|
|
36
|
-
*/
|
|
37
|
-
static head: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
38
|
-
/**
|
|
39
|
-
* Defines options to the endpoint.
|
|
40
|
-
*/
|
|
41
|
-
static options: (options: Partial<IOptions<{
|
|
42
|
-
[key: string]: any;
|
|
43
|
-
}>>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
44
|
-
/**
|
|
45
|
-
* Define specific option to the endpoint.
|
|
46
|
-
*/
|
|
47
|
-
static option: <K extends keyof IOptions<{
|
|
48
|
-
[key: string]: any;
|
|
49
|
-
}>>(option: K, value: IOptions<{
|
|
50
|
-
[key: string]: any;
|
|
51
|
-
}>[K]) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
52
|
-
/**
|
|
53
|
-
* Sets the `auth` option of the endpoint.
|
|
54
|
-
*/
|
|
55
|
-
static auth: (auth: RouteAuth) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
56
|
-
/**
|
|
57
|
-
* Sets the `params` option to the endpoint using DTO classes.
|
|
58
|
-
*/
|
|
59
|
-
static params: (params: RSDtoType | typeof BaseDto | typeof RequestDto, optionalParams?: Array<string>, omit?: Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
60
|
-
/**
|
|
61
|
-
* Sets the `response` option to the endpoint using DTO classes.
|
|
62
|
-
*/
|
|
63
|
-
static response: (response: RSDtoType | typeof BaseDto | typeof ResponseDto | Response.Base, omit?: Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
64
|
-
/**
|
|
65
|
-
* Sets the `params` and `response` options to the endpoint using DTO classes.
|
|
66
|
-
*/
|
|
67
|
-
static dto: (dto: RSDtoType | typeof BaseDto, optionalParams?: Array<string>, omitParams?: Array<string>, omitResponse?: Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
68
|
-
/**
|
|
69
|
-
* Sets the `errors` option to the endpoint.
|
|
70
|
-
*/
|
|
71
|
-
static errors: (errors: IOptions['errors']) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
72
|
-
/**
|
|
73
|
-
* Sets the `description` option to the endpoint.
|
|
74
|
-
*/
|
|
75
|
-
static description: (description: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
76
|
-
/**
|
|
77
|
-
* Sets the `hideDocs` option to `true` to the endpoint.
|
|
78
|
-
*/
|
|
79
|
-
static hideDocs: (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
80
|
-
/**
|
|
81
|
-
* Sets the `args` option to the endpoint.
|
|
82
|
-
*/
|
|
83
|
-
static args: (args: Array<Field> | typeof ArgsDto) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
84
|
-
/**
|
|
85
|
-
* Sets the `requireApiKey` option to the endpoint.
|
|
86
|
-
*/
|
|
87
|
-
static requireApiKey: (requireApiKey: boolean) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
88
|
-
/**
|
|
89
|
-
* Sets the `excludedApiKey` option to the endpoint.
|
|
90
|
-
*/
|
|
91
|
-
static excludedApiKeys: (excludedApiKeys: (() => Promise<Array<string>>) | Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
92
|
-
/**
|
|
93
|
-
* Sets the `timeout` option to the endpoint.
|
|
94
|
-
*/
|
|
95
|
-
static timeout: (timeout: number) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
96
|
-
/**
|
|
97
|
-
* Sets the `props` option to the endpoint.
|
|
98
|
-
*/
|
|
99
|
-
static props: <IProps = {
|
|
100
|
-
[key: string]: any;
|
|
101
|
-
}>(props: IProps) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
102
|
-
/**
|
|
103
|
-
* Sets the endpoint as empty. It returns 204 status code.
|
|
104
|
-
*/
|
|
105
|
-
static emptyResponse: (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
106
|
-
/**
|
|
107
|
-
* Sets the endpoint as deprecated.
|
|
108
|
-
*/
|
|
109
|
-
static deprecated: (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
110
|
-
static redirect: (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
111
|
-
}
|
|
112
|
-
export default class Controller {
|
|
113
|
-
/**
|
|
114
|
-
* Sets the version to the `Controller` class. All endpoints will have this version.
|
|
115
|
-
*/
|
|
116
|
-
static version: (version: number) => (target: typeof Controller) => void;
|
|
117
|
-
/**
|
|
118
|
-
* @alias version
|
|
119
|
-
*/
|
|
120
|
-
static v: (version: number) => (target: typeof Controller) => void;
|
|
121
|
-
static controllerOptions: (options: Partial<import("./decorators/controller-options").IOptions<{
|
|
122
|
-
[key: string]: any;
|
|
123
|
-
}>>) => (target: typeof Controller) => void;
|
|
124
|
-
static resource: (resource: string) => (target: typeof Controller) => void;
|
|
125
|
-
static Endpoint: typeof E;
|
|
126
|
-
/**
|
|
127
|
-
* Marks the endpoint on the method as deprecated.
|
|
128
|
-
* @deprecated
|
|
129
|
-
*/
|
|
130
|
-
static deprecated: (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
131
|
-
/**
|
|
132
|
-
* The endpoint is executed with `PUT` method.
|
|
133
|
-
* @deprecated
|
|
134
|
-
*/
|
|
135
|
-
static put: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
136
|
-
/**
|
|
137
|
-
* The endpoint is executed with `GET` method.
|
|
138
|
-
* @deprecated
|
|
139
|
-
*/
|
|
140
|
-
static get: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
141
|
-
/**
|
|
142
|
-
* The endpoint is executed with `POST` method.
|
|
143
|
-
* @deprecated
|
|
144
|
-
*/
|
|
145
|
-
static post: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
146
|
-
/**
|
|
147
|
-
* The endpoint is executed with `DELETE` method.
|
|
148
|
-
* @deprecated
|
|
149
|
-
*/
|
|
150
|
-
static delete: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
151
|
-
/**
|
|
152
|
-
* Defines options to the endpoint.
|
|
153
|
-
* @deprecated
|
|
154
|
-
*/
|
|
155
|
-
static options: (options: Partial<IOptions<{
|
|
156
|
-
[key: string]: any;
|
|
157
|
-
}>>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
158
|
-
/**
|
|
159
|
-
* Define specific option to the endpoint.
|
|
160
|
-
* @deprecated
|
|
161
|
-
*/
|
|
162
|
-
static option: <K extends keyof IOptions<{
|
|
163
|
-
[key: string]: any;
|
|
164
|
-
}>>(option: K, value: IOptions<{
|
|
165
|
-
[key: string]: any;
|
|
166
|
-
}>[K]) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
167
|
-
/**
|
|
168
|
-
* Sets the `auth` option of the endpoint.
|
|
169
|
-
* @deprecated
|
|
170
|
-
*/
|
|
171
|
-
static auth: (auth: RouteAuth) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
172
|
-
/**
|
|
173
|
-
* Sets the `params` option to the endpoint using DTO classes.
|
|
174
|
-
* @deprecated
|
|
175
|
-
*/
|
|
176
|
-
static params: (params: RSDtoType | typeof BaseDto | typeof RequestDto, optionalParams?: Array<string>, omit?: Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
177
|
-
/**
|
|
178
|
-
* Sets the `response` option to the endpoint using DTO classes.
|
|
179
|
-
* @deprecated
|
|
180
|
-
*/
|
|
181
|
-
static response: (response: RSDtoType | typeof BaseDto | typeof ResponseDto | Response.Base, omit?: Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
182
|
-
/**
|
|
183
|
-
* Sets the `params` and `response` options to the endpoint using DTO classes.
|
|
184
|
-
* @deprecated
|
|
185
|
-
*/
|
|
186
|
-
static dto: (dto: RSDtoType | typeof BaseDto, optionalParams?: Array<string>, omitParams?: Array<string>, omitResponse?: Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
187
|
-
/**
|
|
188
|
-
* Sets the `errors` option to the endpoint.
|
|
189
|
-
* @deprecated
|
|
190
|
-
*/
|
|
191
|
-
static errors: (errors: IOptions['errors']) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
192
|
-
/**
|
|
193
|
-
* Sets the `description` option to the endpoint.
|
|
194
|
-
* @deprecated
|
|
195
|
-
*/
|
|
196
|
-
static description: (description: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
197
|
-
/**
|
|
198
|
-
* Sets the `hideDocs` option to `true` to the endpoint.
|
|
199
|
-
* @deprecated
|
|
200
|
-
*/
|
|
201
|
-
static hideDocs: (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
202
|
-
/**
|
|
203
|
-
* Sets the `args` option to the endpoint.
|
|
204
|
-
* @deprecated
|
|
205
|
-
*/
|
|
206
|
-
static args: (args: Array<Field> | typeof ArgsDto) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
207
|
-
/**
|
|
208
|
-
* Sets the `requireApiKey` option to the endpoint.
|
|
209
|
-
* @deprecated
|
|
210
|
-
*/
|
|
211
|
-
static requireApiKey: (requireApiKey: boolean) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
212
|
-
/**
|
|
213
|
-
* Sets the `excludedApiKey` option to the endpoint.
|
|
214
|
-
* @deprecated
|
|
215
|
-
*/
|
|
216
|
-
static excludedApiKeys: (excludedApiKeys: (() => Promise<Array<string>>) | Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
217
|
-
/**
|
|
218
|
-
* Sets the `timeout` option to the endpoint.
|
|
219
|
-
* @deprecated
|
|
220
|
-
*/
|
|
221
|
-
static timeout: (timeout: number) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
222
|
-
/**
|
|
223
|
-
* Sets the `props` option to the endpoint.
|
|
224
|
-
* @deprecated
|
|
225
|
-
*/
|
|
226
|
-
static props: <IProps = {
|
|
227
|
-
[key: string]: any;
|
|
228
|
-
}>(props: IProps) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
229
|
-
/**
|
|
230
|
-
* Sets the endpoint as empty. It returns 204 status code.
|
|
231
|
-
* @deprecated
|
|
232
|
-
*/
|
|
233
|
-
static emptyResponse: (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
234
|
-
private static _controllers;
|
|
235
|
-
/**
|
|
236
|
-
* Registers all found controllers in the directory to the application.
|
|
237
|
-
*
|
|
238
|
-
* @param app The instance of the application.
|
|
239
|
-
* @param directory Path to the directory where the controllers are located.
|
|
240
|
-
*/
|
|
241
|
-
static registerDirectory(app: Application, directory: string): Promise<void>;
|
|
242
|
-
static register(app: Application): void;
|
|
243
|
-
static getControllers(): Controller[];
|
|
244
|
-
private _app;
|
|
245
|
-
constructor(app: Application);
|
|
246
|
-
register(): void;
|
|
247
|
-
beforeExecution(req: IRequest, res: IResponse): Promise<void>;
|
|
248
|
-
getEndpoints(): Array<IEndpoint>;
|
|
249
|
-
getVersion(): number;
|
|
250
|
-
getResource(): string;
|
|
251
|
-
getOptions(propertyKey: string): IRouteOptions;
|
|
252
|
-
isDeprecated(propertyKey: string): boolean;
|
|
253
|
-
getRoute(route: string): string;
|
|
254
|
-
private _getParamsArray;
|
|
255
|
-
private _getResponseArray;
|
|
256
|
-
}
|
|
257
|
-
export {};
|
|
1
|
+
import { Application, Field, IRequest, IResponse, IRouteOptions, Response, RouteAuth } from 'resting-squirrel';
|
|
2
|
+
import { ArgsDto, BaseDto, RequestDto, ResponseDto } from 'resting-squirrel-dto';
|
|
3
|
+
import { IOptions, RSDtoType } from './decorators/options';
|
|
4
|
+
export interface IStore {
|
|
5
|
+
__endpoints__: Array<IEndpoint>;
|
|
6
|
+
__options__: {
|
|
7
|
+
[propertyKey: string]: IOptions;
|
|
8
|
+
};
|
|
9
|
+
__deprecated__: Array<string>;
|
|
10
|
+
}
|
|
11
|
+
export interface IEndpoint {
|
|
12
|
+
method: 'get' | 'put' | 'post' | 'delete' | 'head';
|
|
13
|
+
route: string;
|
|
14
|
+
callback: (req: IRequest, res: any) => void | Promise<any>;
|
|
15
|
+
propertyKey: string;
|
|
16
|
+
}
|
|
17
|
+
declare class E {
|
|
18
|
+
/**
|
|
19
|
+
* The endpoint is executed with `PUT` method.
|
|
20
|
+
*/
|
|
21
|
+
static put: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
22
|
+
/**
|
|
23
|
+
* The endpoint is executed with `GET` method.
|
|
24
|
+
*/
|
|
25
|
+
static get: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
26
|
+
/**
|
|
27
|
+
* The endpoint is executed with `POST` method.
|
|
28
|
+
*/
|
|
29
|
+
static post: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
30
|
+
/**
|
|
31
|
+
* The endpoint is executed with `DELETE` method.
|
|
32
|
+
*/
|
|
33
|
+
static delete: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
34
|
+
/**
|
|
35
|
+
* The endpoint is executed with `HEAD` method.
|
|
36
|
+
*/
|
|
37
|
+
static head: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
38
|
+
/**
|
|
39
|
+
* Defines options to the endpoint.
|
|
40
|
+
*/
|
|
41
|
+
static options: (options: Partial<IOptions<{
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}>>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
44
|
+
/**
|
|
45
|
+
* Define specific option to the endpoint.
|
|
46
|
+
*/
|
|
47
|
+
static option: <K extends keyof IOptions<{
|
|
48
|
+
[key: string]: any;
|
|
49
|
+
}>>(option: K, value: IOptions<{
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
}>[K]) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
52
|
+
/**
|
|
53
|
+
* Sets the `auth` option of the endpoint.
|
|
54
|
+
*/
|
|
55
|
+
static auth: (auth: RouteAuth) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
56
|
+
/**
|
|
57
|
+
* Sets the `params` option to the endpoint using DTO classes.
|
|
58
|
+
*/
|
|
59
|
+
static params: (params: RSDtoType | typeof BaseDto | typeof RequestDto, optionalParams?: Array<string>, omit?: Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
60
|
+
/**
|
|
61
|
+
* Sets the `response` option to the endpoint using DTO classes.
|
|
62
|
+
*/
|
|
63
|
+
static response: (response: RSDtoType | typeof BaseDto | typeof ResponseDto | Response.Base, omit?: Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
64
|
+
/**
|
|
65
|
+
* Sets the `params` and `response` options to the endpoint using DTO classes.
|
|
66
|
+
*/
|
|
67
|
+
static dto: (dto: RSDtoType | typeof BaseDto, optionalParams?: Array<string>, omitParams?: Array<string>, omitResponse?: Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
68
|
+
/**
|
|
69
|
+
* Sets the `errors` option to the endpoint.
|
|
70
|
+
*/
|
|
71
|
+
static errors: (errors: IOptions['errors']) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
72
|
+
/**
|
|
73
|
+
* Sets the `description` option to the endpoint.
|
|
74
|
+
*/
|
|
75
|
+
static description: (description: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
76
|
+
/**
|
|
77
|
+
* Sets the `hideDocs` option to `true` to the endpoint.
|
|
78
|
+
*/
|
|
79
|
+
static hideDocs: (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
80
|
+
/**
|
|
81
|
+
* Sets the `args` option to the endpoint.
|
|
82
|
+
*/
|
|
83
|
+
static args: (args: Array<Field> | typeof ArgsDto) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
84
|
+
/**
|
|
85
|
+
* Sets the `requireApiKey` option to the endpoint.
|
|
86
|
+
*/
|
|
87
|
+
static requireApiKey: (requireApiKey: boolean) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
88
|
+
/**
|
|
89
|
+
* Sets the `excludedApiKey` option to the endpoint.
|
|
90
|
+
*/
|
|
91
|
+
static excludedApiKeys: (excludedApiKeys: (() => Promise<Array<string>>) | Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
92
|
+
/**
|
|
93
|
+
* Sets the `timeout` option to the endpoint.
|
|
94
|
+
*/
|
|
95
|
+
static timeout: (timeout: number) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
96
|
+
/**
|
|
97
|
+
* Sets the `props` option to the endpoint.
|
|
98
|
+
*/
|
|
99
|
+
static props: <IProps = {
|
|
100
|
+
[key: string]: any;
|
|
101
|
+
}>(props: IProps) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
102
|
+
/**
|
|
103
|
+
* Sets the endpoint as empty. It returns 204 status code.
|
|
104
|
+
*/
|
|
105
|
+
static emptyResponse: (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
106
|
+
/**
|
|
107
|
+
* Sets the endpoint as deprecated.
|
|
108
|
+
*/
|
|
109
|
+
static deprecated: (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
110
|
+
static redirect: (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
111
|
+
}
|
|
112
|
+
export default class Controller {
|
|
113
|
+
/**
|
|
114
|
+
* Sets the version to the `Controller` class. All endpoints will have this version.
|
|
115
|
+
*/
|
|
116
|
+
static version: (version: number) => (target: typeof Controller) => void;
|
|
117
|
+
/**
|
|
118
|
+
* @alias version
|
|
119
|
+
*/
|
|
120
|
+
static v: (version: number) => (target: typeof Controller) => void;
|
|
121
|
+
static controllerOptions: (options: Partial<import("./decorators/controller-options").IOptions<{
|
|
122
|
+
[key: string]: any;
|
|
123
|
+
}>>) => (target: typeof Controller) => void;
|
|
124
|
+
static resource: (resource: string) => (target: typeof Controller) => void;
|
|
125
|
+
static Endpoint: typeof E;
|
|
126
|
+
/**
|
|
127
|
+
* Marks the endpoint on the method as deprecated.
|
|
128
|
+
* @deprecated
|
|
129
|
+
*/
|
|
130
|
+
static deprecated: (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
131
|
+
/**
|
|
132
|
+
* The endpoint is executed with `PUT` method.
|
|
133
|
+
* @deprecated
|
|
134
|
+
*/
|
|
135
|
+
static put: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
136
|
+
/**
|
|
137
|
+
* The endpoint is executed with `GET` method.
|
|
138
|
+
* @deprecated
|
|
139
|
+
*/
|
|
140
|
+
static get: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
141
|
+
/**
|
|
142
|
+
* The endpoint is executed with `POST` method.
|
|
143
|
+
* @deprecated
|
|
144
|
+
*/
|
|
145
|
+
static post: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
146
|
+
/**
|
|
147
|
+
* The endpoint is executed with `DELETE` method.
|
|
148
|
+
* @deprecated
|
|
149
|
+
*/
|
|
150
|
+
static delete: (endpoint: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
151
|
+
/**
|
|
152
|
+
* Defines options to the endpoint.
|
|
153
|
+
* @deprecated
|
|
154
|
+
*/
|
|
155
|
+
static options: (options: Partial<IOptions<{
|
|
156
|
+
[key: string]: any;
|
|
157
|
+
}>>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
158
|
+
/**
|
|
159
|
+
* Define specific option to the endpoint.
|
|
160
|
+
* @deprecated
|
|
161
|
+
*/
|
|
162
|
+
static option: <K extends keyof IOptions<{
|
|
163
|
+
[key: string]: any;
|
|
164
|
+
}>>(option: K, value: IOptions<{
|
|
165
|
+
[key: string]: any;
|
|
166
|
+
}>[K]) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
167
|
+
/**
|
|
168
|
+
* Sets the `auth` option of the endpoint.
|
|
169
|
+
* @deprecated
|
|
170
|
+
*/
|
|
171
|
+
static auth: (auth: RouteAuth) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
172
|
+
/**
|
|
173
|
+
* Sets the `params` option to the endpoint using DTO classes.
|
|
174
|
+
* @deprecated
|
|
175
|
+
*/
|
|
176
|
+
static params: (params: RSDtoType | typeof BaseDto | typeof RequestDto, optionalParams?: Array<string>, omit?: Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
177
|
+
/**
|
|
178
|
+
* Sets the `response` option to the endpoint using DTO classes.
|
|
179
|
+
* @deprecated
|
|
180
|
+
*/
|
|
181
|
+
static response: (response: RSDtoType | typeof BaseDto | typeof ResponseDto | Response.Base, omit?: Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
182
|
+
/**
|
|
183
|
+
* Sets the `params` and `response` options to the endpoint using DTO classes.
|
|
184
|
+
* @deprecated
|
|
185
|
+
*/
|
|
186
|
+
static dto: (dto: RSDtoType | typeof BaseDto, optionalParams?: Array<string>, omitParams?: Array<string>, omitResponse?: Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
187
|
+
/**
|
|
188
|
+
* Sets the `errors` option to the endpoint.
|
|
189
|
+
* @deprecated
|
|
190
|
+
*/
|
|
191
|
+
static errors: (errors: IOptions['errors']) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
192
|
+
/**
|
|
193
|
+
* Sets the `description` option to the endpoint.
|
|
194
|
+
* @deprecated
|
|
195
|
+
*/
|
|
196
|
+
static description: (description: string) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
197
|
+
/**
|
|
198
|
+
* Sets the `hideDocs` option to `true` to the endpoint.
|
|
199
|
+
* @deprecated
|
|
200
|
+
*/
|
|
201
|
+
static hideDocs: (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
202
|
+
/**
|
|
203
|
+
* Sets the `args` option to the endpoint.
|
|
204
|
+
* @deprecated
|
|
205
|
+
*/
|
|
206
|
+
static args: (args: Array<Field> | typeof ArgsDto) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
207
|
+
/**
|
|
208
|
+
* Sets the `requireApiKey` option to the endpoint.
|
|
209
|
+
* @deprecated
|
|
210
|
+
*/
|
|
211
|
+
static requireApiKey: (requireApiKey: boolean) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
212
|
+
/**
|
|
213
|
+
* Sets the `excludedApiKey` option to the endpoint.
|
|
214
|
+
* @deprecated
|
|
215
|
+
*/
|
|
216
|
+
static excludedApiKeys: (excludedApiKeys: (() => Promise<Array<string>>) | Array<string>) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
217
|
+
/**
|
|
218
|
+
* Sets the `timeout` option to the endpoint.
|
|
219
|
+
* @deprecated
|
|
220
|
+
*/
|
|
221
|
+
static timeout: (timeout: number) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
222
|
+
/**
|
|
223
|
+
* Sets the `props` option to the endpoint.
|
|
224
|
+
* @deprecated
|
|
225
|
+
*/
|
|
226
|
+
static props: <IProps = {
|
|
227
|
+
[key: string]: any;
|
|
228
|
+
}>(props: IProps) => (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
229
|
+
/**
|
|
230
|
+
* Sets the endpoint as empty. It returns 204 status code.
|
|
231
|
+
* @deprecated
|
|
232
|
+
*/
|
|
233
|
+
static emptyResponse: (target: Controller, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
234
|
+
private static _controllers;
|
|
235
|
+
/**
|
|
236
|
+
* Registers all found controllers in the directory to the application.
|
|
237
|
+
*
|
|
238
|
+
* @param app The instance of the application.
|
|
239
|
+
* @param directory Path to the directory where the controllers are located.
|
|
240
|
+
*/
|
|
241
|
+
static registerDirectory(app: Application, directory: string): Promise<void>;
|
|
242
|
+
static register(app: Application): void;
|
|
243
|
+
static getControllers(): Controller[];
|
|
244
|
+
private _app;
|
|
245
|
+
constructor(app: Application);
|
|
246
|
+
register(): void;
|
|
247
|
+
beforeExecution(req: IRequest, res: IResponse): Promise<void>;
|
|
248
|
+
getEndpoints(): Array<IEndpoint>;
|
|
249
|
+
getVersion(): number;
|
|
250
|
+
getResource(): string;
|
|
251
|
+
getOptions(propertyKey: string): IRouteOptions;
|
|
252
|
+
isDeprecated(propertyKey: string): boolean;
|
|
253
|
+
getRoute(route: string): string;
|
|
254
|
+
private _getParamsArray;
|
|
255
|
+
private _getResponseArray;
|
|
256
|
+
}
|
|
257
|
+
export {};
|