@deepkit/http 1.0.1-alpha.59 → 1.0.1-alpha.63
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/coverage/clover.xml +1086 -0
- package/coverage/coverage-final.json +12 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +79 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +126 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +170 -0
- package/coverage/lcov-report/src/controllers.ts.html +113 -0
- package/coverage/lcov-report/src/decorator.ts.html +1280 -0
- package/coverage/lcov-report/src/filter.ts.html +734 -0
- package/coverage/lcov-report/src/http.ts.html +2192 -0
- package/coverage/lcov-report/src/index.html +246 -0
- package/coverage/lcov-report/src/kernel.ts.html +260 -0
- package/coverage/lcov-report/src/middleware.ts.html +428 -0
- package/coverage/lcov-report/src/model.ts.html +937 -0
- package/coverage/lcov-report/src/module.config.ts.html +89 -0
- package/coverage/lcov-report/src/module.ts.html +245 -0
- package/coverage/lcov-report/src/router.ts.html +2318 -0
- package/coverage/lcov-report/tests/index.html +111 -0
- package/coverage/lcov-report/tests/utils.ts.html +176 -0
- package/coverage/lcov.info +2225 -0
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/src/controllers.d.ts +4 -4
- package/dist/cjs/src/controllers.js +3 -0
- package/dist/cjs/src/controllers.js.map +1 -1
- package/dist/cjs/src/decorator.d.ts +29 -94
- package/dist/cjs/src/decorator.js +53 -118
- package/dist/cjs/src/decorator.js.map +1 -1
- package/dist/cjs/src/filter.d.ts +1 -0
- package/dist/cjs/src/filter.js +11 -17
- package/dist/cjs/src/filter.js.map +1 -1
- package/dist/cjs/src/http.d.ts +5 -3
- package/dist/cjs/src/http.js +91 -55
- package/dist/cjs/src/http.js.map +1 -1
- package/dist/cjs/src/kernel.d.ts +3 -3
- package/dist/cjs/src/kernel.js +5 -25
- package/dist/cjs/src/kernel.js.map +1 -1
- package/dist/cjs/src/logger.d.ts +2 -2
- package/dist/cjs/src/logger.js +4 -8
- package/dist/cjs/src/logger.js.map +1 -1
- package/dist/cjs/src/middleware.d.ts +5 -1
- package/dist/cjs/src/middleware.js +15 -3
- package/dist/cjs/src/middleware.js.map +1 -1
- package/dist/cjs/src/model.d.ts +62 -2
- package/dist/cjs/src/model.js +101 -26
- package/dist/cjs/src/model.js.map +1 -1
- package/dist/cjs/src/module.config.d.ts +3 -4
- package/dist/cjs/src/module.config.js +8 -6
- package/dist/cjs/src/module.config.js.map +1 -1
- package/dist/cjs/src/module.d.ts +2 -3
- package/dist/cjs/src/module.js +4 -2
- package/dist/cjs/src/module.js.map +1 -1
- package/dist/cjs/src/router.d.ts +24 -53
- package/dist/cjs/src/router.js +140 -159
- package/dist/cjs/src/router.js.map +1 -1
- package/dist/cjs/src/static-serving.d.ts +1 -0
- package/dist/cjs/src/static-serving.js +46 -39
- package/dist/cjs/src/static-serving.js.map +1 -1
- package/dist/cjs/src/utils.js +1 -0
- package/dist/cjs/tests/filter.spec.js +61 -47
- package/dist/cjs/tests/filter.spec.js.map +1 -1
- package/dist/cjs/tests/middleware.spec.d.ts +1 -1
- package/dist/cjs/tests/middleware.spec.js +157 -145
- package/dist/cjs/tests/middleware.spec.js.map +1 -1
- package/dist/cjs/tests/model.spec.js +4 -4
- package/dist/cjs/tests/model.spec.js.map +1 -1
- package/dist/cjs/tests/module.spec.js +4 -3
- package/dist/cjs/tests/module.spec.js.map +1 -1
- package/dist/cjs/tests/router.spec.d.ts +1 -1
- package/dist/cjs/tests/router.spec.js +298 -333
- package/dist/cjs/tests/router.spec.js.map +1 -1
- package/dist/cjs/tests/utils.js +5 -2
- package/dist/cjs/tests/utils.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/src/controllers.d.ts +4 -4
- package/dist/esm/src/controllers.js +3 -0
- package/dist/esm/src/controllers.js.map +1 -1
- package/dist/esm/src/decorator.d.ts +29 -94
- package/dist/esm/src/decorator.js +49 -114
- package/dist/esm/src/decorator.js.map +1 -1
- package/dist/esm/src/filter.d.ts +1 -0
- package/dist/esm/src/filter.js +11 -18
- package/dist/esm/src/filter.js.map +1 -1
- package/dist/esm/src/http.d.ts +5 -3
- package/dist/esm/src/http.js +89 -55
- package/dist/esm/src/http.js.map +1 -1
- package/dist/esm/src/kernel.d.ts +3 -3
- package/dist/esm/src/kernel.js +6 -27
- package/dist/esm/src/kernel.js.map +1 -1
- package/dist/esm/src/logger.d.ts +2 -2
- package/dist/esm/src/logger.js +4 -9
- package/dist/esm/src/logger.js.map +1 -1
- package/dist/esm/src/middleware.d.ts +5 -1
- package/dist/esm/src/middleware.js +12 -0
- package/dist/esm/src/middleware.js.map +1 -1
- package/dist/esm/src/model.d.ts +62 -2
- package/dist/esm/src/model.js +92 -24
- package/dist/esm/src/model.js.map +1 -1
- package/dist/esm/src/module.config.d.ts +3 -4
- package/dist/esm/src/module.config.js +6 -5
- package/dist/esm/src/module.config.js.map +1 -1
- package/dist/esm/src/module.d.ts +2 -3
- package/dist/esm/src/module.js +5 -3
- package/dist/esm/src/module.js.map +1 -1
- package/dist/esm/src/router.d.ts +24 -53
- package/dist/esm/src/router.js +136 -155
- package/dist/esm/src/router.js.map +1 -1
- package/dist/esm/src/static-serving.d.ts +1 -0
- package/dist/esm/src/static-serving.js +39 -32
- package/dist/esm/src/static-serving.js.map +1 -1
- package/dist/esm/src/utils.js +1 -0
- package/dist/esm/tests/filter.spec.js +14 -0
- package/dist/esm/tests/filter.spec.js.map +1 -1
- package/dist/esm/tests/middleware.spec.d.ts +1 -1
- package/dist/esm/tests/middleware.spec.js +60 -48
- package/dist/esm/tests/middleware.spec.js.map +1 -1
- package/dist/esm/tests/module.spec.js +1 -0
- package/dist/esm/tests/module.spec.js.map +1 -1
- package/dist/esm/tests/router.spec.d.ts +1 -1
- package/dist/esm/tests/router.spec.js +167 -202
- package/dist/esm/tests/router.spec.js.map +1 -1
- package/dist/esm/tests/utils.js +4 -1
- package/dist/esm/tests/utils.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +14 -15
- package/src/controllers.ts +3 -3
- package/src/decorator.ts +42 -131
- package/src/filter.ts +0 -2
- package/src/http.ts +35 -36
- package/src/kernel.ts +4 -5
- package/src/logger.ts +2 -4
- package/src/middleware.ts +2 -1
- package/src/model.ts +80 -8
- package/src/module.config.ts +3 -6
- package/src/module.ts +2 -2
- package/src/router.ts +121 -161
- package/src/static-serving.ts +14 -12
- package/tests/middleware.spec.ts +0 -1
- package/tests/router.spec.ts +131 -133
- package/tsconfig.json +2 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,6CAA2B;AAC3B,8CAA4B;AAC5B,+CAA6B;AAC7B,+CAA6B;AAC7B,uDAAqC;AACrC,+CAA6B;AAC7B,+CAA6B;AAC7B,sDAAoC;AACpC,oDAAkC;AAClC,mDAAiC;AACjC,+CAA6B;AAC7B,8CAA4B"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ClassType } from '@deepkit/core';
|
|
2
|
-
import {
|
|
2
|
+
import { InjectorModule } from '@deepkit/injector';
|
|
3
3
|
export declare class HttpControllers {
|
|
4
4
|
readonly controllers: {
|
|
5
5
|
controller: ClassType;
|
|
6
|
-
module:
|
|
6
|
+
module: InjectorModule<any>;
|
|
7
7
|
}[];
|
|
8
8
|
constructor(controllers?: {
|
|
9
9
|
controller: ClassType;
|
|
10
|
-
module:
|
|
10
|
+
module: InjectorModule<any>;
|
|
11
11
|
}[]);
|
|
12
|
-
add(controller: ClassType, module:
|
|
12
|
+
add(controller: ClassType, module: InjectorModule<any>): void;
|
|
13
13
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpControllers = void 0;
|
|
4
|
+
var { __ΩClassType } = require('@deepkit/core');
|
|
5
|
+
const injector_1 = require("@deepkit/injector");
|
|
4
6
|
class HttpControllers {
|
|
5
7
|
constructor(controllers = []) {
|
|
6
8
|
this.controllers = controllers;
|
|
@@ -10,4 +12,5 @@ class HttpControllers {
|
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
exports.HttpControllers = HttpControllers;
|
|
15
|
+
HttpControllers.__type = [() => __ΩClassType, 'controller', () => injector_1.InjectorModule, 'module', 'controllers', () => [], 'constructor', () => __ΩClassType, () => injector_1.InjectorModule, 'add', 'PPn!4"P"7#4$MF2%:>&"0\'Pn(2"P"7)2$"0*5'];
|
|
13
16
|
//# sourceMappingURL=controllers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controllers.js","sourceRoot":"","sources":["../../../src/controllers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controllers.js","sourceRoot":"","sources":["../../../src/controllers.ts"],"names":[],"mappings":";;;+BAA0B,eAAe;AACzC,gDAAmD;AAEnD,MAAa,eAAe;IACxB,YAA4B,cAAsE,EAAE;QAAxE,gBAAW,GAAX,WAAW,CAA6D;IACpG,CAAC;IAEM,GAAG,CAAC,UAAqB,EAAE,MAA2B;QACzD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAC,UAAU,EAAE,MAAM,EAAC,CAAC,CAAC;IAChD,CAAC;;AANL,0CAOC"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { ClassType } from '@deepkit/core';
|
|
2
|
-
import { ClassDecoratorResult,
|
|
2
|
+
import { ClassDecoratorResult, DecoratorAndFetchSignature, DualDecorator, ExtractApiDataType, ExtractClass, PropertyDecoratorFn, ReceiveType, SerializationOptions, Serializer, Type, UnionToIntersection } from '@deepkit/type';
|
|
3
3
|
import { RouteParameterResolver } from './router';
|
|
4
4
|
import { HttpMiddleware, HttpMiddlewareConfig, HttpMiddlewareFn } from './middleware';
|
|
5
|
-
export interface ControllerOptions {
|
|
6
|
-
name: string;
|
|
7
|
-
}
|
|
8
5
|
declare type HttpActionMiddleware = (() => HttpMiddlewareConfig) | ClassType<HttpMiddleware> | HttpMiddlewareFn;
|
|
9
6
|
declare class HttpController {
|
|
10
7
|
baseUrl: string;
|
|
@@ -38,18 +35,9 @@ export declare class HttpAction {
|
|
|
38
35
|
groups: string[];
|
|
39
36
|
serializer?: Serializer;
|
|
40
37
|
middlewares: (() => HttpMiddlewareConfig)[];
|
|
41
|
-
serializationOptions?:
|
|
42
|
-
parameterRegularExpressions: {
|
|
43
|
-
[name: string]: any;
|
|
44
|
-
};
|
|
38
|
+
serializationOptions?: SerializationOptions;
|
|
45
39
|
resolverForToken: Map<any, ClassType>;
|
|
46
40
|
resolverForParameterName: Map<string, ClassType>;
|
|
47
|
-
/**
|
|
48
|
-
* This is only filled when the user used @http.body() for example on an method argument.
|
|
49
|
-
*/
|
|
50
|
-
parameters: {
|
|
51
|
-
[name: string]: HttpActionParameter;
|
|
52
|
-
};
|
|
53
41
|
/**
|
|
54
42
|
* An arbitrary data container the user can use to store app specific settings/values.
|
|
55
43
|
*/
|
|
@@ -57,7 +45,7 @@ export declare class HttpAction {
|
|
|
57
45
|
responses: {
|
|
58
46
|
statusCode: number;
|
|
59
47
|
description: string;
|
|
60
|
-
type?:
|
|
48
|
+
type?: Type;
|
|
61
49
|
}[];
|
|
62
50
|
}
|
|
63
51
|
export declare class HttpDecorator {
|
|
@@ -116,11 +104,10 @@ export declare class HttpDecorator {
|
|
|
116
104
|
export declare const httpClass: ClassDecoratorResult<typeof HttpDecorator>;
|
|
117
105
|
export declare class HttpActionDecorator {
|
|
118
106
|
t: HttpAction;
|
|
119
|
-
onDecorator(target: ClassType, property: string): void;
|
|
107
|
+
onDecorator(target: ClassType, property: string | undefined, parameterIndexOrDescriptor?: any): void;
|
|
120
108
|
name(name: string): void;
|
|
121
|
-
setParameter(name: string, parameter: HttpActionParameter): void;
|
|
122
109
|
description(description: string): void;
|
|
123
|
-
serialization(options:
|
|
110
|
+
serialization(options: SerializationOptions): void;
|
|
124
111
|
serializer(serializer: Serializer): void;
|
|
125
112
|
middleware(...middlewares: HttpActionMiddleware[]): void;
|
|
126
113
|
/**
|
|
@@ -169,29 +156,28 @@ export declare class HttpActionDecorator {
|
|
|
169
156
|
ANY(path?: string): void;
|
|
170
157
|
/**
|
|
171
158
|
* Adds additional information about what HTTP status codes are available in this route.
|
|
172
|
-
* You can add additionally a description and a
|
|
173
|
-
*
|
|
174
|
-
* The class type is used for serialization for responses with the given statusCode.
|
|
159
|
+
* You can add additionally a description and a response body type.
|
|
175
160
|
*
|
|
176
|
-
*
|
|
161
|
+
* The type is used for serialization for responses with the given statusCode.
|
|
177
162
|
*
|
|
178
|
-
*
|
|
163
|
+
* This information is available in Deepkit API console.
|
|
179
164
|
*
|
|
180
165
|
* ```typescript
|
|
181
166
|
*
|
|
182
|
-
* @http.GET().response(200, 'All ok'
|
|
167
|
+
* @http.GET().response<boolean>(200, 'All ok')
|
|
183
168
|
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
169
|
+
* interface User {
|
|
170
|
+
* username: string;
|
|
186
171
|
* }
|
|
187
|
-
* @http.GET().response(200, 'User object'
|
|
172
|
+
* @http.GET().response<User>(200, 'User object')
|
|
188
173
|
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
174
|
+
* interface HttpErrorMessage {
|
|
175
|
+
* error: string;
|
|
176
|
+
* }
|
|
177
|
+
* @http.GET().response<HttpErrorMessage>(500, 'Error')
|
|
192
178
|
* ```
|
|
193
179
|
*/
|
|
194
|
-
response(statusCode: number, description?: string,
|
|
180
|
+
response<T>(statusCode: number, description?: string, type?: ReceiveType<T>): void;
|
|
195
181
|
/**
|
|
196
182
|
* Adds a parameter resolver for parameters based on the class type. Use .resolveParameterByName() for name-based resolving.
|
|
197
183
|
*
|
|
@@ -236,68 +222,17 @@ export declare class HttpActionDecorator {
|
|
|
236
222
|
* ```
|
|
237
223
|
*/
|
|
238
224
|
resolveParameterByName(name: string, resolver: ClassType<RouteParameterResolver>): void;
|
|
239
|
-
regexp(parameterName: string, regex: any): void;
|
|
240
225
|
}
|
|
241
|
-
declare
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
* }
|
|
254
|
-
*
|
|
255
|
-
* class Controller {
|
|
256
|
-
* @http.GET()
|
|
257
|
-
* myAction(@http.body() body: MyActionBody) {
|
|
258
|
-
* console.log('body', body.name);
|
|
259
|
-
* }
|
|
260
|
-
* }
|
|
261
|
-
* ```
|
|
262
|
-
*/
|
|
263
|
-
body(): void;
|
|
264
|
-
query(path?: string): void;
|
|
265
|
-
get optional(): void;
|
|
266
|
-
/**
|
|
267
|
-
* Marks the argument as query parameter. Data from the query string is parsed
|
|
268
|
-
* and deserialized to the defined type.
|
|
269
|
-
* Define a `path` if you want to parse a subset of the query string only.
|
|
270
|
-
*
|
|
271
|
-
* Note: Make sure the defined parameter type has optional properties,
|
|
272
|
-
* otherwise it's always required to pass a query string.
|
|
273
|
-
*
|
|
274
|
-
* @example
|
|
275
|
-
* ```typescript
|
|
276
|
-
* class MyActionQueries {
|
|
277
|
-
* @t.optional name?: string;
|
|
278
|
-
* }
|
|
279
|
-
*
|
|
280
|
-
* class Controller {
|
|
281
|
-
* @http.GET('my-action')
|
|
282
|
-
* myAction(@http.queries() query: MyActionQueries) {
|
|
283
|
-
* console.log('query', query.name);
|
|
284
|
-
* }
|
|
285
|
-
* }
|
|
286
|
-
*
|
|
287
|
-
* // Open via, e.g.
|
|
288
|
-
* // -> /my-action?name=Peter
|
|
289
|
-
* ```
|
|
290
|
-
*
|
|
291
|
-
*/
|
|
292
|
-
queries(path?: string): void;
|
|
293
|
-
}
|
|
294
|
-
export declare const httpAction: PropertyDecoratorResult<typeof HttpActionDecorator>;
|
|
295
|
-
export declare const httpActionParameter: PropertyDecoratorResult<typeof HttpActionParameterDecorator>;
|
|
296
|
-
export declare const http: import("@deepkit/type").Merge<Omit<import("@deepkit/type").FluidDecorator<HttpDecorator, import("@deepkit/type").ClassDecoratorFn> & ((classType: import("@deepkit/core").AbstractClassType<any>) => void) & {
|
|
297
|
-
_fetch: (classType: ClassType<any>) => HttpController | undefined;
|
|
298
|
-
} & import("@deepkit/type").FluidDecorator<HttpActionDecorator, import("@deepkit/type").PropertyDecoratorFn> & ((prototype: object, property: string, parameterIndexOrDescriptor?: any) => void) & {
|
|
299
|
-
_fetch: (classType: ClassType<any>, property: string, parameterIndexOrDescriptor?: any) => HttpAction | undefined;
|
|
300
|
-
} & import("@deepkit/type").FluidDecorator<HttpActionParameterDecorator, import("@deepkit/type").PropertyDecoratorFn> & {
|
|
301
|
-
_fetch: (classType: ClassType<any>, property: string, parameterIndexOrDescriptor?: any) => HttpActionParameter | undefined;
|
|
302
|
-
}, "t" | "_fetch">>;
|
|
226
|
+
declare type HttpActionFluidDecorator<T, D extends Function> = {
|
|
227
|
+
[name in keyof T]: name extends 'response' ? <T2>(statusCode: number, description?: string, type?: ReceiveType<T2>) => D & HttpActionFluidDecorator<T, D> : T[name] extends (...args: infer K) => any ? (...args: K) => D & HttpActionFluidDecorator<T, D> : D & HttpActionFluidDecorator<T, D> & {
|
|
228
|
+
_data: ExtractApiDataType<T>;
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
declare type HttpActionPropertyDecoratorResult = HttpActionFluidDecorator<ExtractClass<typeof HttpActionDecorator>, PropertyDecoratorFn> & DecoratorAndFetchSignature<typeof HttpActionDecorator, PropertyDecoratorFn>;
|
|
232
|
+
export declare const httpAction: HttpActionPropertyDecoratorResult;
|
|
233
|
+
declare type HttpMerge<U> = {
|
|
234
|
+
[K in keyof U]: K extends 'response' ? <T2>(statusCode: number, description?: string, type?: ReceiveType<T2>) => PropertyDecoratorFn & U : U[K] extends ((...a: infer A) => infer R) ? R extends DualDecorator ? (...a: A) => PropertyDecoratorFn & R & U : (...a: A) => R : never;
|
|
235
|
+
};
|
|
236
|
+
declare type MergedHttp<T extends any[]> = HttpMerge<Omit<UnionToIntersection<T[number]>, '_fetch' | 't'>>;
|
|
237
|
+
export declare const http: MergedHttp<[typeof httpClass, typeof httpAction]>;
|
|
303
238
|
export {};
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.http = exports.httpAction = exports.HttpActionDecorator = exports.httpClass = exports.HttpDecorator = exports.HttpAction = exports.HttpActionParameter = void 0;
|
|
4
|
+
var { __ΩClassType } = require('@deepkit/core');
|
|
5
|
+
var { __ΩSerializationOptions } = require('@deepkit/type');
|
|
6
|
+
var { __ΩRouteParameterResolver } = require('./router');
|
|
7
|
+
var { __ΩReceiveType } = require('@deepkit/type');
|
|
8
|
+
var { __ΩHttpMiddleware } = require('./middleware');
|
|
9
|
+
var { __ΩHttpMiddlewareFn } = require('./middleware');
|
|
10
|
+
var { __ΩExtractApiDataType } = require('@deepkit/type');
|
|
11
|
+
var { __ΩExtractClass } = require('@deepkit/type');
|
|
12
|
+
var { __ΩPropertyDecoratorFn } = require('@deepkit/type');
|
|
13
|
+
var { __ΩDecoratorAndFetchSignature } = require('@deepkit/type');
|
|
14
|
+
var { __ΩDualDecorator } = require('@deepkit/type');
|
|
15
|
+
var { __ΩUnionToIntersection } = require('@deepkit/type');
|
|
16
|
+
var __ΩPick = ['T', 'K', 'l+e#!e"!fRb!b"Pde""N#!'];
|
|
17
|
+
var __ΩExclude = ['T', 'U', 'l6!Re$!RPe#!e$"qk#%QRb!b"Pde"!p)'];
|
|
18
|
+
var __ΩOmit = ['T', 'K', () => __ΩPick, () => __ΩExclude, 'b!b"e!!e!!ge!"o$#o##'];
|
|
2
19
|
/*
|
|
3
20
|
* Deepkit Framework
|
|
4
21
|
* Copyright (C) 2021 Deepkit UG, Marc J. Schmidt
|
|
@@ -8,14 +25,14 @@
|
|
|
8
25
|
*
|
|
9
26
|
* You should have received a copy of the MIT License along with this program.
|
|
10
27
|
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.http = exports.httpActionParameter = exports.httpAction = exports.HttpActionDecorator = exports.httpClass = exports.HttpDecorator = exports.HttpAction = exports.HttpActionParameter = void 0;
|
|
13
28
|
const core_1 = require("@deepkit/core");
|
|
14
29
|
const type_1 = require("@deepkit/type");
|
|
15
30
|
const middleware_1 = require("./middleware");
|
|
31
|
+
var __ΩHttpActionMiddleware = [() => middleware_1.HttpMiddlewareConfig, '', () => __ΩClassType, () => __ΩHttpMiddleware, () => __ΩHttpMiddlewareFn, 'PPP7!/"n$o#"n%J'];
|
|
16
32
|
function isMiddlewareClassTypeOrFn(v) {
|
|
17
|
-
return core_1.isClass(v) || !type_1.isDecoratorContext(middleware_1.httpMiddleware, v);
|
|
33
|
+
return (0, core_1.isClass)(v) || !(0, type_1.isDecoratorContext)(middleware_1.httpMiddleware, v);
|
|
18
34
|
}
|
|
35
|
+
isMiddlewareClassTypeOrFn.__type = [() => __ΩHttpActionMiddleware, 'v', 'isMiddlewareClassTypeOrFn', 'Pn!2"!/#'];
|
|
19
36
|
class HttpController {
|
|
20
37
|
constructor() {
|
|
21
38
|
this.baseUrl = '';
|
|
@@ -26,7 +43,7 @@ class HttpController {
|
|
|
26
43
|
this.resolverForParameterName = new Map();
|
|
27
44
|
}
|
|
28
45
|
getUrl(action) {
|
|
29
|
-
return core_1.urlJoin('/', this.baseUrl, action.path);
|
|
46
|
+
return (0, core_1.urlJoin)('/', this.baseUrl, action.path);
|
|
30
47
|
}
|
|
31
48
|
addAction(action) {
|
|
32
49
|
this.actions.add(action);
|
|
@@ -51,6 +68,7 @@ class HttpController {
|
|
|
51
68
|
throw new Error(`No action with methodName ${methodName} found`);
|
|
52
69
|
}
|
|
53
70
|
}
|
|
71
|
+
HttpController.__type = ['baseUrl', function () { return ''; }, 'groups', function () { return []; }, () => middleware_1.HttpMiddlewareConfig, '', 'middlewares', function () { return []; }, () => __ΩClassType, 'resolverForToken', function () { return new Map(); }, () => __ΩClassType, 'resolverForParameterName', function () { return new Map(); }, () => HttpAction, 'action', 'getUrl', () => HttpAction, 'addAction', () => HttpAction, 'getActions', 'methodName', 'removeAction', () => HttpAction, 'getAction', '&3!>"&F3#>$PP7%/&F3\'>("n)E3*>+&n,E3->.PP7/20&01PP7220"03PP74D05P&26$07P&26P78095'];
|
|
54
72
|
class HttpActionParameter {
|
|
55
73
|
constructor() {
|
|
56
74
|
this.name = '';
|
|
@@ -58,6 +76,7 @@ class HttpActionParameter {
|
|
|
58
76
|
}
|
|
59
77
|
}
|
|
60
78
|
exports.HttpActionParameter = HttpActionParameter;
|
|
79
|
+
HttpActionParameter.__type = ['name', function () { return ''; }, "body", "query", "queries", 'type', 'typePath', 'optional', function () { return false; }, '&3!>"P.#.$.%J3&8&3\'8)3(>)5'];
|
|
61
80
|
class HttpAction {
|
|
62
81
|
constructor() {
|
|
63
82
|
this.name = '';
|
|
@@ -68,13 +87,8 @@ class HttpAction {
|
|
|
68
87
|
this.methodName = '';
|
|
69
88
|
this.groups = [];
|
|
70
89
|
this.middlewares = [];
|
|
71
|
-
this.parameterRegularExpressions = {};
|
|
72
90
|
this.resolverForToken = new Map();
|
|
73
91
|
this.resolverForParameterName = new Map();
|
|
74
|
-
/**
|
|
75
|
-
* This is only filled when the user used @http.body() for example on an method argument.
|
|
76
|
-
*/
|
|
77
|
-
this.parameters = {};
|
|
78
92
|
/**
|
|
79
93
|
* An arbitrary data container the user can use to store app specific settings/values.
|
|
80
94
|
*/
|
|
@@ -83,6 +97,7 @@ class HttpAction {
|
|
|
83
97
|
}
|
|
84
98
|
}
|
|
85
99
|
exports.HttpAction = HttpAction;
|
|
100
|
+
HttpAction.__type = ['name', function () { return ''; }, 'description', function () { return ''; }, 'category', function () { return ''; }, 'path', function () { return ''; }, 'httpMethods', function () { return []; }, 'methodName', function () { return ''; }, 'groups', function () { return []; }, () => type_1.Serializer, 'serializer', () => middleware_1.HttpMiddlewareConfig, '', 'middlewares', function () { return []; }, () => __ΩSerializationOptions, 'serializationOptions', () => __ΩClassType, 'resolverForToken', function () { return new Map(); }, () => __ΩClassType, 'resolverForParameterName', function () { return new Map(); }, 'statusCode', 'type', 'responses', function () { return []; }, '&3!>"&3#>$&3%>&&3\'>(&F3)>*&3+>,&F3->.P7/308PP71/2F33>4n5368"n7E38>9&n:E3;><P\'4=&4#"4>8MF3?>@5'];
|
|
86
101
|
class HttpDecorator {
|
|
87
102
|
constructor() {
|
|
88
103
|
this.t = new HttpController;
|
|
@@ -94,7 +109,7 @@ class HttpDecorator {
|
|
|
94
109
|
this.t.groups.push(...group);
|
|
95
110
|
}
|
|
96
111
|
middleware(...middlewares) {
|
|
97
|
-
this.t.middlewares.push(...middlewares.map(v => isMiddlewareClassTypeOrFn(v) ? middleware_1.httpMiddleware.for(v) : v));
|
|
112
|
+
this.t.middlewares.push(...middlewares.map(Object.assign(v => isMiddlewareClassTypeOrFn(v) ? middleware_1.httpMiddleware.for(v) : v, { __type: ['v', '', 'P"2!"/"'] })));
|
|
98
113
|
}
|
|
99
114
|
/**
|
|
100
115
|
* Adds a parameter resolver for parameters based on the class type. Use .resolveParameterByName() for name-based resolving.
|
|
@@ -151,21 +166,21 @@ class HttpDecorator {
|
|
|
151
166
|
}
|
|
152
167
|
}
|
|
153
168
|
exports.HttpDecorator = HttpDecorator;
|
|
154
|
-
|
|
169
|
+
HttpDecorator.__type = ['baseUrl', () => "", 'controller', 'group', () => __ΩHttpActionMiddleware, 'middlewares', 'middleware', () => __ΩClassType, 'classType', () => __ΩClassType, () => __ΩRouteParameterResolver, 'resolver', 'resolveParameter', 'name', () => __ΩClassType, () => __ΩRouteParameterResolver, 'resolveParameterByName', () => HttpAction, 'action', 'setAction', 'P&2!>""0#P&@2$"0$Pn%@2&"0\'PPn(&"J2)n+o*"2,"0-P&2.n0o/"2,"01PP7223"045'];
|
|
170
|
+
exports.httpClass = (0, type_1.createClassDecoratorContext)(HttpDecorator);
|
|
155
171
|
class HttpActionDecorator {
|
|
156
172
|
constructor() {
|
|
157
173
|
this.t = new HttpAction;
|
|
158
174
|
}
|
|
159
|
-
onDecorator(target, property) {
|
|
175
|
+
onDecorator(target, property, parameterIndexOrDescriptor) {
|
|
176
|
+
if (!property)
|
|
177
|
+
return;
|
|
160
178
|
this.t.methodName = property;
|
|
161
179
|
exports.httpClass.setAction(this.t)(target);
|
|
162
180
|
}
|
|
163
181
|
name(name) {
|
|
164
182
|
this.t.name = name;
|
|
165
183
|
}
|
|
166
|
-
setParameter(name, parameter) {
|
|
167
|
-
this.t.parameters[name] = parameter;
|
|
168
|
-
}
|
|
169
184
|
description(description) {
|
|
170
185
|
this.t.description = description;
|
|
171
186
|
}
|
|
@@ -176,7 +191,7 @@ class HttpActionDecorator {
|
|
|
176
191
|
this.t.serializer = serializer;
|
|
177
192
|
}
|
|
178
193
|
middleware(...middlewares) {
|
|
179
|
-
this.t.middlewares.push(...middlewares.map(v => isMiddlewareClassTypeOrFn(v) ? middleware_1.httpMiddleware.for(v) : v));
|
|
194
|
+
this.t.middlewares.push(...middlewares.map(Object.assign(v => isMiddlewareClassTypeOrFn(v) ? middleware_1.httpMiddleware.for(v) : v, { __type: ['v', '', 'P"2!"/"'] })));
|
|
180
195
|
}
|
|
181
196
|
/**
|
|
182
197
|
* Allows to change the HttpAction object and composite multiple properties into one function.
|
|
@@ -247,12 +262,12 @@ class HttpActionDecorator {
|
|
|
247
262
|
this.t.path = path;
|
|
248
263
|
}
|
|
249
264
|
OPTIONS(path = '') {
|
|
250
|
-
this.t.httpMethods.push('
|
|
265
|
+
this.t.httpMethods.push('OPTIONS');
|
|
251
266
|
if (path)
|
|
252
267
|
this.t.path = path;
|
|
253
268
|
}
|
|
254
269
|
TRACE(path = '') {
|
|
255
|
-
this.t.httpMethods.push('
|
|
270
|
+
this.t.httpMethods.push('TRACE');
|
|
256
271
|
if (path)
|
|
257
272
|
this.t.path = path;
|
|
258
273
|
}
|
|
@@ -268,31 +283,29 @@ class HttpActionDecorator {
|
|
|
268
283
|
}
|
|
269
284
|
/**
|
|
270
285
|
* Adds additional information about what HTTP status codes are available in this route.
|
|
271
|
-
* You can add additionally a description and a
|
|
272
|
-
*
|
|
273
|
-
* The class type is used for serialization for responses with the given statusCode.
|
|
286
|
+
* You can add additionally a description and a response body type.
|
|
274
287
|
*
|
|
275
|
-
*
|
|
288
|
+
* The type is used for serialization for responses with the given statusCode.
|
|
276
289
|
*
|
|
277
|
-
*
|
|
290
|
+
* This information is available in Deepkit API console.
|
|
278
291
|
*
|
|
279
292
|
* ```typescript
|
|
280
293
|
*
|
|
281
|
-
* @http.GET().response(200, 'All ok'
|
|
294
|
+
* @http.GET().response<boolean>(200, 'All ok')
|
|
282
295
|
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
296
|
+
* interface User {
|
|
297
|
+
* username: string;
|
|
285
298
|
* }
|
|
286
|
-
* @http.GET().response(200, 'User object'
|
|
287
|
-
*
|
|
299
|
+
* @http.GET().response<User>(200, 'User object')
|
|
288
300
|
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
301
|
+
* interface HttpErrorMessage {
|
|
302
|
+
* error: string;
|
|
303
|
+
* }
|
|
304
|
+
* @http.GET().response<HttpErrorMessage>(500, 'Error')
|
|
291
305
|
* ```
|
|
292
306
|
*/
|
|
293
|
-
response(statusCode, description = '',
|
|
294
|
-
|
|
295
|
-
this.t.responses.push({ statusCode, description, type });
|
|
307
|
+
response(statusCode, description = '', type) {
|
|
308
|
+
this.t.responses.push({ statusCode, description, type: type ? (0, type_1.resolveReceiveType)(type) : undefined });
|
|
296
309
|
}
|
|
297
310
|
/**
|
|
298
311
|
* Adds a parameter resolver for parameters based on the class type. Use .resolveParameterByName() for name-based resolving.
|
|
@@ -342,91 +355,13 @@ class HttpActionDecorator {
|
|
|
342
355
|
resolveParameterByName(name, resolver) {
|
|
343
356
|
this.t.resolverForParameterName.set(name, resolver);
|
|
344
357
|
}
|
|
345
|
-
regexp(parameterName, regex) {
|
|
346
|
-
this.t.parameterRegularExpressions[parameterName] = regex;
|
|
347
|
-
}
|
|
348
358
|
}
|
|
349
359
|
exports.HttpActionDecorator = HttpActionDecorator;
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if (parameterIndex === undefined)
|
|
358
|
-
throw new Error('@http action parameter decorator can only be used on method arguments.');
|
|
359
|
-
const schema = type_1.getClassSchema(target);
|
|
360
|
-
const property = schema.getMethodProperties(propertyName)[parameterIndex];
|
|
361
|
-
this.t.name = property.name;
|
|
362
|
-
if (this.t.typePath === undefined) {
|
|
363
|
-
this.t.typePath = property.name;
|
|
364
|
-
}
|
|
365
|
-
exports.httpAction.setParameter(property.name, this.t)(target.prototype, propertyName);
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Marks the argument as body parameter. Data from the client sent in the body
|
|
369
|
-
* will be tried to parsed (JSON/form data) and deserialized to the defined type.
|
|
370
|
-
* Make sure the class type as a schema assigned.
|
|
371
|
-
*
|
|
372
|
-
* @example
|
|
373
|
-
* ```typescript
|
|
374
|
-
* class MyActionBody {
|
|
375
|
-
* @t name!: string;
|
|
376
|
-
* }
|
|
377
|
-
*
|
|
378
|
-
* class Controller {
|
|
379
|
-
* @http.GET()
|
|
380
|
-
* myAction(@http.body() body: MyActionBody) {
|
|
381
|
-
* console.log('body', body.name);
|
|
382
|
-
* }
|
|
383
|
-
* }
|
|
384
|
-
* ```
|
|
385
|
-
*/
|
|
386
|
-
body() {
|
|
387
|
-
this.t.type = 'body';
|
|
388
|
-
this.t.typePath = ''; //root
|
|
389
|
-
}
|
|
390
|
-
query(path) {
|
|
391
|
-
this.t.typePath = path; //undefined === propertyName
|
|
392
|
-
this.t.type = 'query';
|
|
393
|
-
}
|
|
394
|
-
get optional() {
|
|
395
|
-
this.t.optional = true;
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
/**
|
|
399
|
-
* Marks the argument as query parameter. Data from the query string is parsed
|
|
400
|
-
* and deserialized to the defined type.
|
|
401
|
-
* Define a `path` if you want to parse a subset of the query string only.
|
|
402
|
-
*
|
|
403
|
-
* Note: Make sure the defined parameter type has optional properties,
|
|
404
|
-
* otherwise it's always required to pass a query string.
|
|
405
|
-
*
|
|
406
|
-
* @example
|
|
407
|
-
* ```typescript
|
|
408
|
-
* class MyActionQueries {
|
|
409
|
-
* @t.optional name?: string;
|
|
410
|
-
* }
|
|
411
|
-
*
|
|
412
|
-
* class Controller {
|
|
413
|
-
* @http.GET('my-action')
|
|
414
|
-
* myAction(@http.queries() query: MyActionQueries) {
|
|
415
|
-
* console.log('query', query.name);
|
|
416
|
-
* }
|
|
417
|
-
* }
|
|
418
|
-
*
|
|
419
|
-
* // Open via, e.g.
|
|
420
|
-
* // -> /my-action?name=Peter
|
|
421
|
-
* ```
|
|
422
|
-
*
|
|
423
|
-
*/
|
|
424
|
-
queries(path = '') {
|
|
425
|
-
this.t.typePath = path; //'' === root
|
|
426
|
-
this.t.type = 'queries';
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
exports.httpAction = type_1.createPropertyDecoratorContext(HttpActionDecorator);
|
|
430
|
-
exports.httpActionParameter = type_1.createPropertyDecoratorContext(HttpActionParameterDecorator);
|
|
431
|
-
exports.http = type_1.mergeDecorator(exports.httpClass, exports.httpAction, exports.httpActionParameter);
|
|
360
|
+
HttpActionDecorator.__type = [() => __ΩClassType, 'target', 'property', 'parameterIndexOrDescriptor', 'onDecorator', 'name', 'description', () => __ΩSerializationOptions, 'options', 'serialization', () => type_1.Serializer, 'serializer', () => __ΩHttpActionMiddleware, 'middlewares', 'middleware', () => HttpAction, 'action', '', 'use', 'value', 'data', 'category', 'group', 'path', () => "", 'GET', () => "", 'HEAD', () => "", 'POST', () => "", 'PUT', () => "", 'DELETE', () => "", 'OPTIONS', () => "", 'TRACE', () => "", 'PATCH', () => "", 'ANY', 'statusCode', () => "", () => __ΩReceiveType, 'type', 'response', () => __ΩClassType, 'classType', () => __ΩClassType, () => __ΩRouteParameterResolver, 'resolver', 'resolveParameter', () => __ΩClassType, () => __ΩRouteParameterResolver, 'resolveParameterByName', 'Pn!2"P&-J2#"2$8"0%P&2&"0&P&2\'"0\'Pn(2)"0*PP7+2,"0,Pn-@2."0/PPP7021$/223"03P&2&"24"05P&26"06P&@27"07P&28>9"0:P&28>;"0<P&28>="0>P&28>?"0@P&28>A"0BP&28>C"0DP&28>E"0FP&28>G"0HP&28>I"0JP\'2K&2\'>L"oM"2N8"0OPPnP&"J2QnSoR"2T"0UP&2&nWoV"2T"0X5'];
|
|
361
|
+
var __ΩHttpActionFluidDecorator = ['T', 'D', "response", 'statusCode', 'description', () => __ΩReceiveType, 'type', 0, '', 'args', 0, 0, () => __ΩExtractApiDataType, '_data', 'l\u00A1P\'2$&2%8"o&"2\'8Pe)"e)!e)"o(#K/)RPe#!@2*Pe+"e+!e+"o+#K/)RPe*"e*!e*"o,#Pe+!o-"4.MKRPde(!e%!fPh"!@2*"/)qkC[QRPe#!.#qk#tQRPde#!p\u008DRb!b"Pde"!gN\u0099!'];
|
|
362
|
+
var __ΩHttpActionPropertyDecoratorResult = [() => __ΩHttpActionFluidDecorator, () => __ΩExtractClass, () => HttpActionDecorator, () => __ΩPropertyDecoratorFn, () => __ΩDecoratorAndFetchSignature, () => HttpActionDecorator, () => __ΩPropertyDecoratorFn, 'Pi#o""n$o!#i&n\'o%#K'];
|
|
363
|
+
exports.httpAction = (0, type_1.createPropertyDecoratorContext)(HttpActionDecorator);
|
|
364
|
+
var __ΩHttpMerge = ['U', "response", 'statusCode', 'description', () => __ΩReceiveType, 'type', () => __ΩPropertyDecoratorFn, '', 'a', () => __ΩDualDecorator, () => __ΩPropertyDecoratorFn, 'l\u00A3P\'2#&2$8"o%"2&8Pn\'e)!K/(RPe\'!@2)Pn+e&!e/!K/(RPe\'!@2)e%!/(RPe#!n*qk<PQRPde#"p]R!RPdde(!e%!fPh"!@2)h""/(qkiqQRPe#!."qk#sQRPde#!p\u008FRb!Pde"!gN\u009B!'];
|
|
365
|
+
var __ΩMergedHttp = ['T', () => __ΩHttpMerge, () => __ΩOmit, () => __ΩUnionToIntersection, "_fetch", "t", 'b!e!!\'fo$"P.%.&Jo##o""'];
|
|
366
|
+
exports.http = (0, type_1.mergeDecorator)(exports.httpClass, exports.httpAction);
|
|
432
367
|
//# sourceMappingURL=decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../src/decorator.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../src/decorator.ts"],"names":[],"mappings":";;;+BAU4C,eAAe;0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,EAAE,kBAAU,CAA6D,CAAC"}
|
package/dist/cjs/src/filter.d.ts
CHANGED
package/dist/cjs/src/filter.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.HttpRouteFilter = exports.HttpRouterFilterResolver = exports.HttpRouteFilterModel = void 0;
|
|
3
|
+
exports.HttpRouteFilter = exports.HttpRouterFilterResolver = exports.HttpRouteFilterModel = exports.__ΩHttpRouteFilterRoute = void 0;
|
|
4
|
+
var { __ΩClassType } = require('@deepkit/core');
|
|
5
|
+
const app_1 = require("@deepkit/app");
|
|
13
6
|
const router_1 = require("./router");
|
|
14
|
-
|
|
7
|
+
var __ΩHttpRouteFilterRoute = ['path', 'pathRegExp', "GET", "HEAD", "POST", "PATCH", "PUT", "DELETE", "OPTIONS", "TRACE", 'httpMethod', 'category', 'group', 'P&4!8A4"8P.#.$.%.&.\'.(.).*J4+8&4,8&4-8M'];
|
|
8
|
+
exports.__ΩHttpRouteFilterRoute = __ΩHttpRouteFilterRoute;
|
|
15
9
|
class HttpRouteFilterModel {
|
|
16
10
|
constructor() {
|
|
17
11
|
this.controllers = [];
|
|
@@ -37,6 +31,7 @@ class HttpRouteFilterModel {
|
|
|
37
31
|
}
|
|
38
32
|
}
|
|
39
33
|
exports.HttpRouteFilterModel = HttpRouteFilterModel;
|
|
34
|
+
HttpRouteFilterModel.__type = [() => __ΩClassType, 'controllers', function () { return []; }, () => __ΩClassType, 'excludeControllers', function () { return []; }, () => __ΩHttpRouteFilterRoute, 'routes', function () { return []; }, () => __ΩHttpRouteFilterRoute, 'excludeRoutes', function () { return []; }, 'routeNames', function () { return []; }, 'excludeRouteNames', function () { return []; }, () => app_1.AppModule, 'modules', function () { return []; }, () => app_1.AppModule, 'excludeModules', function () { return []; }, () => __ΩClassType, () => app_1.AppModule, 'moduleClasses', function () { return []; }, () => __ΩClassType, () => app_1.AppModule, 'excludeModuleClasses', function () { return []; }, 'reset', 'n!F3">#n$F3%>&n\'F3(>)n*F3+>,&F3->.&F3/>0P"71F32>3P"74F35>6P"78o7"F39>:P"7<o;"F3=>>P"0?5'];
|
|
40
35
|
function match(routeConfig, route) {
|
|
41
36
|
if (route.httpMethod && routeConfig.httpMethods.includes(route.httpMethod))
|
|
42
37
|
return true;
|
|
@@ -52,7 +47,8 @@ function match(routeConfig, route) {
|
|
|
52
47
|
}
|
|
53
48
|
return false;
|
|
54
49
|
}
|
|
55
|
-
|
|
50
|
+
match.__type = [() => router_1.RouteConfig, 'routeConfig', () => __ΩHttpRouteFilterRoute, 'route', 'match', 'PP7!2"n#2$)/%'];
|
|
51
|
+
class HttpRouterFilterResolver {
|
|
56
52
|
constructor(router) {
|
|
57
53
|
this.router = router;
|
|
58
54
|
}
|
|
@@ -152,12 +148,9 @@ let HttpRouterFilterResolver = class HttpRouterFilterResolver {
|
|
|
152
148
|
}
|
|
153
149
|
return result;
|
|
154
150
|
}
|
|
155
|
-
}
|
|
156
|
-
HttpRouterFilterResolver = __decorate([
|
|
157
|
-
injector_1.injectable,
|
|
158
|
-
__metadata("design:paramtypes", [router_1.Router])
|
|
159
|
-
], HttpRouterFilterResolver);
|
|
151
|
+
}
|
|
160
152
|
exports.HttpRouterFilterResolver = HttpRouterFilterResolver;
|
|
153
|
+
HttpRouterFilterResolver.__type = [() => router_1.Router, 'router', 'constructor', () => HttpRouteFilterModel, 'filter', () => router_1.RouteConfig, 'resolve', 'PP7!2"<"0#PP7$2%P7&F0\'5'];
|
|
161
154
|
/**
|
|
162
155
|
* A class to describe a filter for routes.
|
|
163
156
|
*/
|
|
@@ -211,4 +204,5 @@ class HttpRouteFilter {
|
|
|
211
204
|
}
|
|
212
205
|
}
|
|
213
206
|
exports.HttpRouteFilter = HttpRouteFilter;
|
|
207
|
+
HttpRouteFilter.__type = ['reset', () => __ΩClassType, 'controllers', 'forControllers', () => __ΩClassType, 'excludeControllers', () => __ΩHttpRouteFilterRoute, 'routes', 'forRoutes', () => __ΩHttpRouteFilterRoute, 'excludeRoutes', 'names', 'forRouteNames', 'excludeRouteNames', () => app_1.AppModule, 'modules', 'forModules', () => app_1.AppModule, 'excludeModules', () => __ΩClassType, () => app_1.AppModule, 'moduleClasses', 'forModuleClasses', () => __ΩClassType, () => app_1.AppModule, 'excludeModuleClasses', 'P!0!Pn"@2#!0$Pn%@2#!0&Pn\'@2(!0)Pn*@2(!0+P&@2,!0-P&@2,!0.PP"7/@20!01PP"72@20!03PP"75o4"@26!07PP"79o8"@26!0:5'];
|
|
214
208
|
//# sourceMappingURL=filter.js.map
|