@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
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import { __ΩClassType as __ΩClassType } from '@deepkit/core';
|
|
1
2
|
import { isClass } from '@deepkit/core';
|
|
3
|
+
import { AppModule } from '@deepkit/app';
|
|
2
4
|
import { createFreeDecoratorContext } from '@deepkit/type';
|
|
5
|
+
import { HttpRequest, HttpResponse } from './model';
|
|
6
|
+
import { InjectorModule } from '@deepkit/injector';
|
|
7
|
+
var __ΩHttpMiddlewareFn = [() => HttpRequest, 'req', () => HttpResponse, 'res', 'err', '', 'next', 'PP7!2"P7#2$P"2%8$/&2\'P$$`J/&'];
|
|
8
|
+
export { __ΩHttpMiddlewareFn as __ΩHttpMiddlewareFn };
|
|
9
|
+
var __ΩHttpMiddleware = [() => __ΩHttpMiddlewareFn, 'execute', 'Pn!4"M'];
|
|
10
|
+
export { __ΩHttpMiddleware as __ΩHttpMiddleware };
|
|
11
|
+
var __ΩHttpMiddlewareRoute = ['path', 'pathRegExp', "GET", "HEAD", "POST", "PATCH", "PUT", "DELETE", "OPTIONS", "TRACE", 'httpMethod', 'category', 'excludeCategory', 'group', 'excludeGroup', 'P&4!8A4"8P.#.$.%.&.\'.(.).*J4+8&4,8&4-8&4.8&4/8M'];
|
|
12
|
+
export { __ΩHttpMiddlewareRoute as __ΩHttpMiddlewareRoute };
|
|
3
13
|
export class HttpMiddlewareConfig {
|
|
4
14
|
constructor() {
|
|
5
15
|
this.middlewares = [];
|
|
@@ -23,6 +33,7 @@ export class HttpMiddlewareConfig {
|
|
|
23
33
|
return classTypes;
|
|
24
34
|
}
|
|
25
35
|
}
|
|
36
|
+
HttpMiddlewareConfig.__type = ['name', () => __ΩHttpMiddlewareFn, () => __ΩClassType, () => __ΩHttpMiddleware, 'middlewares', function () { return []; }, () => __ΩHttpMiddlewareRoute, 'routes', function () { return []; }, () => __ΩHttpMiddlewareRoute, 'excludeRoutes', function () { return []; }, 'order', function () { return 0; }, () => __ΩClassType, 'controllers', function () { return []; }, () => __ΩClassType, 'excludeControllers', function () { return []; }, 'routeNames', function () { return []; }, 'excludeRouteNames', function () { return []; }, 'timeout', function () { return 4000; }, () => InjectorModule, 'modules', function () { return []; }, 'selfModule', function () { return false; }, () => __ΩClassType, 'getClassTypes', '&3!8Pn"n$o#"JF3%>&n\'F3(>)n*F3+>,\'3->.n/F30>1n2F33>4&F35>6&F37>8\'39>:P"7;F3<>=)3>>?Pn@F0A5'];
|
|
26
37
|
export class HttpMiddlewareApi {
|
|
27
38
|
constructor() {
|
|
28
39
|
this.t = new HttpMiddlewareConfig;
|
|
@@ -74,5 +85,6 @@ export class HttpMiddlewareApi {
|
|
|
74
85
|
this.t.selfModule = true;
|
|
75
86
|
}
|
|
76
87
|
}
|
|
88
|
+
HttpMiddlewareApi.__type = ['name', () => __ΩHttpMiddlewareFn, () => __ΩClassType, () => __ΩHttpMiddleware, 'middlewares', 'for', () => __ΩHttpMiddlewareRoute, 'routes', 'forRoutes', () => __ΩHttpMiddlewareRoute, 'excludeRoutes', 'names', 'forRouteNames', 'excludeRouteNames', 'timeout', () => __ΩClassType, 'controllers', 'forControllers', () => __ΩClassType, 'excludeControllers', 'order', () => AppModule, 'modules', 'forModules', 'forSelfModules', 'P&2!"0!PPn"n$o#"J@2%"0&Pn\'@2("0)Pn*@2("0+P&@2,"0-P&@2,"0.P\'2/"0/Pn0@21"02Pn3@21"04P\'25"05PP"76@27"08P"095'];
|
|
77
89
|
export const httpMiddleware = createFreeDecoratorContext(HttpMiddlewareApi);
|
|
78
90
|
//# sourceMappingURL=middleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/middleware.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/middleware.ts"],"names":[],"mappings":"6CAAmC,eAAe;AAAlD,OAAO,EAAa,OAAO,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;;;;;;;AAkBnD,MAAM,OAAO,oBAAoB;IAAjC;QAEI,gBAAW,GAAqD,EAAE,CAAC;QAEnE,WAAM,GAA0B,EAAE,CAAC;QACnC,kBAAa,GAA0B,EAAE,CAAC;QAE1C,UAAK,GAAW,CAAC,CAAC;QAElB,gBAAW,GAAgB,EAAE,CAAC;QAC9B,uBAAkB,GAAgB,EAAE,CAAC;QAErC,eAAU,GAAa,EAAE,CAAC;QAC1B,sBAAiB,GAAa,EAAE,CAAC;QAEjC,YAAO,GAAW,IAAK,CAAC;QAExB,YAAO,GAA0B,EAAE,CAAC;QAEpC,eAAU,GAAY,KAAK,CAAC;KAU/B;IARG,aAAa;QACT,MAAM,UAAU,GAAgB,EAAE,CAAC;QACnC,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE;YACvC,IAAI,OAAO,CAAC,UAAU,CAAC;gBAAE,UAAU,CAAC,I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AAC,CAAC,KAAK,GAAG,KAAK,CAAC;IACzB,CAAC;IAED,UAAU,CAAC,GAAG,OAAyB;QACnC,IAAI,CAAC,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,cAAc;QACV,IAAI,CAAC,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;IAC7B,CAAC;;;AAGL,MAAM,CAAC,MAAM,cAAc,GAAG,0BAA0B,CAAC,iBAAiB,CAAC,CAAC"}
|
package/dist/esm/src/model.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
3
|
import { UploadedFile } from './router';
|
|
4
|
+
import { Type, ValidationErrorItem } from '@deepkit/type';
|
|
4
5
|
export declare class HttpResponse extends ServerResponse {
|
|
5
6
|
status(code: number): void;
|
|
6
7
|
}
|
|
@@ -10,6 +11,56 @@ export declare type HttpRequestQuery = {
|
|
|
10
11
|
export declare type HttpRequestResolvedParameters = {
|
|
11
12
|
[name: string]: any;
|
|
12
13
|
};
|
|
14
|
+
export declare class BodyValidationError {
|
|
15
|
+
readonly errors: ValidationErrorItem[];
|
|
16
|
+
constructor(errors?: ValidationErrorItem[]);
|
|
17
|
+
hasErrors(prefix?: string): boolean;
|
|
18
|
+
getErrors(prefix?: string): ValidationErrorItem[];
|
|
19
|
+
getErrorsForPath(path: string): ValidationErrorItem[];
|
|
20
|
+
getErrorMessageForPath(path: string): string;
|
|
21
|
+
}
|
|
22
|
+
export declare class ValidatedBody<T> {
|
|
23
|
+
error: BodyValidationError;
|
|
24
|
+
value?: T | undefined;
|
|
25
|
+
constructor(error: BodyValidationError, value?: T | undefined);
|
|
26
|
+
valid(): this is {
|
|
27
|
+
value: T;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export declare type HttpBody<T> = T & {
|
|
31
|
+
__meta?: ['httpBody'];
|
|
32
|
+
};
|
|
33
|
+
export declare type HttpBodyValidation<T> = ValidatedBody<T> & {
|
|
34
|
+
__meta?: ['httpBodyValidation'];
|
|
35
|
+
};
|
|
36
|
+
export declare type HttpQuery<T, Options extends {
|
|
37
|
+
name?: string;
|
|
38
|
+
} = {}> = T & {
|
|
39
|
+
__meta?: ['httpQuery', Options];
|
|
40
|
+
};
|
|
41
|
+
export declare type HttpQueries<T, Options extends {
|
|
42
|
+
name?: string;
|
|
43
|
+
} = {}> = T & {
|
|
44
|
+
__meta?: ['httpQueries', Options];
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* For all parameters used in the URL path, a regular expression of /[^/]+/ is used. To change that, use getRegExp.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
*
|
|
52
|
+
* class Controller {
|
|
53
|
+
* @http.GET('/user/:username')
|
|
54
|
+
* route(username: HttpRegExp<string, '.*'>) {
|
|
55
|
+
* //username is string
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare type HttpRegExp<T, Pattern extends string> = T & {
|
|
61
|
+
__meta?: ['httpRegExp', Pattern];
|
|
62
|
+
};
|
|
63
|
+
export declare function getRegExp(type: Type): string | undefined;
|
|
13
64
|
export declare class RequestBuilder {
|
|
14
65
|
protected path: string;
|
|
15
66
|
protected method: string;
|
|
@@ -49,6 +100,8 @@ export declare class HttpRequest extends IncomingMessage {
|
|
|
49
100
|
static GET(path: string): RequestBuilder;
|
|
50
101
|
static POST(path: string): RequestBuilder;
|
|
51
102
|
static OPTIONS(path: string): RequestBuilder;
|
|
103
|
+
static TRACE(path: string): RequestBuilder;
|
|
104
|
+
static HEAD(path: string): RequestBuilder;
|
|
52
105
|
static PATCH(path: string): RequestBuilder;
|
|
53
106
|
static PUT(path: string): RequestBuilder;
|
|
54
107
|
static DELETE(path: string): RequestBuilder;
|
|
@@ -60,6 +113,13 @@ export declare class MemoryHttpResponse extends HttpResponse {
|
|
|
60
113
|
body: Buffer;
|
|
61
114
|
get json(): any;
|
|
62
115
|
get bodyString(): string;
|
|
63
|
-
write(chunk: any, encoding: any, callback?: any):
|
|
64
|
-
end(chunk: any, encoding?: any, callback?: any):
|
|
116
|
+
write(chunk: any, encoding: any, callback?: any): any;
|
|
117
|
+
end(chunk: any, encoding?: any, callback?: any): any;
|
|
65
118
|
}
|
|
119
|
+
export declare type __ΩHttpRequestQuery = any[];
|
|
120
|
+
export declare type __ΩHttpRequestResolvedParameters = any[];
|
|
121
|
+
export declare type __ΩHttpBody = any[];
|
|
122
|
+
export declare type __ΩHttpBodyValidation = any[];
|
|
123
|
+
export declare type __ΩHttpQuery = any[];
|
|
124
|
+
export declare type __ΩHttpQueries = any[];
|
|
125
|
+
export declare type __ΩHttpRegExp = any[];
|
package/dist/esm/src/model.js
CHANGED
|
@@ -8,14 +8,70 @@
|
|
|
8
8
|
* You should have received a copy of the MIT License along with this program.
|
|
9
9
|
*/
|
|
10
10
|
import { IncomingMessage, ServerResponse } from 'http';
|
|
11
|
+
import { UploadedFile } from './router';
|
|
11
12
|
import * as querystring from 'querystring';
|
|
12
13
|
import { Writable } from 'stream';
|
|
14
|
+
import { metaAnnotation, ValidationErrorItem } from '@deepkit/type';
|
|
13
15
|
export class HttpResponse extends ServerResponse {
|
|
14
16
|
status(code) {
|
|
15
17
|
this.writeHead(code);
|
|
16
18
|
this.end();
|
|
17
19
|
}
|
|
18
20
|
}
|
|
21
|
+
HttpResponse.__type = ['code', 'status', 'P\'2!"0"5'];
|
|
22
|
+
var __ΩHttpRequestQuery = ['P&&LM'];
|
|
23
|
+
export { __ΩHttpRequestQuery as __ΩHttpRequestQuery };
|
|
24
|
+
var __ΩHttpRequestResolvedParameters = ['P&"LM'];
|
|
25
|
+
export { __ΩHttpRequestResolvedParameters as __ΩHttpRequestResolvedParameters };
|
|
26
|
+
export class BodyValidationError {
|
|
27
|
+
constructor(errors = []) {
|
|
28
|
+
this.errors = errors;
|
|
29
|
+
}
|
|
30
|
+
hasErrors(prefix) {
|
|
31
|
+
return this.getErrors(prefix).length > 0;
|
|
32
|
+
}
|
|
33
|
+
getErrors(prefix) {
|
|
34
|
+
if (prefix)
|
|
35
|
+
return this.errors.filter(Object.assign(v => v.path.startsWith(prefix), { __type: ['v', '', 'P"2!"/"'] }));
|
|
36
|
+
return this.errors;
|
|
37
|
+
}
|
|
38
|
+
getErrorsForPath(path) {
|
|
39
|
+
return this.errors.filter(Object.assign(v => v.path === path, { __type: ['v', '', 'P"2!"/"'] }));
|
|
40
|
+
}
|
|
41
|
+
getErrorMessageForPath(path) {
|
|
42
|
+
return this.getErrorsForPath(path).map(Object.assign(v => v.message, { __type: ['v', '', 'P"2!"/"'] })).join(', ');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
BodyValidationError.__type = [() => ValidationErrorItem, 'errors', () => [], 'constructor', 'prefix', 'hasErrors', () => ValidationErrorItem, 'getErrors', 'path', () => ValidationErrorItem, 'getErrorsForPath', 'getErrorMessageForPath', 'PP7!F2":>#"0$P&2%8)0&P&2%8P7\'F0(P&2)P7*F0+P&2)&0,5'];
|
|
46
|
+
export class ValidatedBody {
|
|
47
|
+
constructor(error, value) {
|
|
48
|
+
this.error = error;
|
|
49
|
+
this.value = value;
|
|
50
|
+
}
|
|
51
|
+
valid() {
|
|
52
|
+
return this.value !== undefined;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
ValidatedBody.__type = ['T', () => BodyValidationError, 'error', 'value', 'constructor', 'valid', 'b!PP7"2#:e"!2$8:"0%P!0&5'];
|
|
56
|
+
var __ΩHttpBody = ['T', "httpBody", '__meta', 'b!Pe"!PP."G4#8MK'];
|
|
57
|
+
export { __ΩHttpBody as __ΩHttpBody };
|
|
58
|
+
var __ΩHttpBodyValidation = ['T', () => ValidatedBody, "httpBodyValidation", '__meta', 'b!PPe#!7"PP.#G4$8MK'];
|
|
59
|
+
export { __ΩHttpBodyValidation as __ΩHttpBodyValidation };
|
|
60
|
+
var __ΩHttpQuery = ['T', 'Options', "httpQuery", '__meta', 'b!PMc"Pe"!PP.#e$"G4$8MK'];
|
|
61
|
+
export { __ΩHttpQuery as __ΩHttpQuery };
|
|
62
|
+
var __ΩHttpQueries = ['T', 'Options', "httpQueries", '__meta', 'b!PMc"Pe"!PP.#e$"G4$8MK'];
|
|
63
|
+
export { __ΩHttpQueries as __ΩHttpQueries };
|
|
64
|
+
var __ΩHttpRegExp = ['T', 'Pattern', "httpRegExp", '__meta', 'b!b"Pe"!PP.#e$"G4$8MK'];
|
|
65
|
+
export { __ΩHttpRegExp as __ΩHttpRegExp };
|
|
66
|
+
export function getRegExp(type) {
|
|
67
|
+
const options = metaAnnotation.getForName(type, 'httpRegExp');
|
|
68
|
+
if (!options || !options[0])
|
|
69
|
+
return;
|
|
70
|
+
if (options[0].kind !== 13 /* literal */ || 'string' !== typeof options[0].literal)
|
|
71
|
+
return;
|
|
72
|
+
return options[0].literal;
|
|
73
|
+
}
|
|
74
|
+
getRegExp.__type = ['type', 'getRegExp', 'P"2!P&-J/"'];
|
|
19
75
|
export class RequestBuilder {
|
|
20
76
|
constructor(path, method = 'GET') {
|
|
21
77
|
this.path = path;
|
|
@@ -30,37 +86,40 @@ export class RequestBuilder {
|
|
|
30
86
|
return this.path;
|
|
31
87
|
}
|
|
32
88
|
build() {
|
|
89
|
+
var _a;
|
|
33
90
|
const headers = this._headers;
|
|
34
91
|
const method = this.method;
|
|
35
92
|
const url = this.getUrl();
|
|
36
93
|
const bodyContent = this.contentBuffer;
|
|
37
94
|
const writable = new Writable({
|
|
38
|
-
write(chunk, encoding, callback) {
|
|
95
|
+
write: Object.assign(function write(chunk, encoding, callback) {
|
|
39
96
|
-callback();
|
|
40
|
-
},
|
|
41
|
-
writev(chunks, callback) {
|
|
97
|
+
}, { __type: ['chunk', 'encoding', 'callback', 'write', 'P"2!"2""2#"/$'] }),
|
|
98
|
+
writev: Object.assign(function writev(chunks, callback) {
|
|
42
99
|
callback();
|
|
43
|
-
}
|
|
100
|
+
}, { __type: ['chunks', 'callback', 'writev', 'P"2!"2""/#'] })
|
|
44
101
|
});
|
|
45
|
-
const request = new (class extends HttpRequest {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
_read(size) {
|
|
55
|
-
if (!this.done) {
|
|
56
|
-
this.push(bodyContent);
|
|
57
|
-
process.nextTick(() => {
|
|
58
|
-
this.emit('end');
|
|
59
|
-
});
|
|
60
|
-
this.done = true;
|
|
102
|
+
const request = new (_a = class extends HttpRequest {
|
|
103
|
+
constructor() {
|
|
104
|
+
super(...arguments);
|
|
105
|
+
this.url = url;
|
|
106
|
+
this.method = method;
|
|
107
|
+
this.position = 0;
|
|
108
|
+
this.headers = headers;
|
|
109
|
+
this.done = false;
|
|
61
110
|
}
|
|
62
|
-
|
|
63
|
-
|
|
111
|
+
_read(size) {
|
|
112
|
+
if (!this.done) {
|
|
113
|
+
this.push(bodyContent);
|
|
114
|
+
process.nextTick(() => {
|
|
115
|
+
this.emit('end');
|
|
116
|
+
});
|
|
117
|
+
this.done = true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
_a.__type = ['size', '_read', 'P\'2!"0"5'],
|
|
122
|
+
_a)(writable);
|
|
64
123
|
return request;
|
|
65
124
|
}
|
|
66
125
|
headers(headers) {
|
|
@@ -92,6 +151,7 @@ export class RequestBuilder {
|
|
|
92
151
|
return this;
|
|
93
152
|
}
|
|
94
153
|
}
|
|
154
|
+
RequestBuilder.__type = [() => Buffer, 'contentBuffer', function () { return Buffer.alloc(0); }, '_headers', function () { return {}; }, 'queryPath', 'path', 'method', () => "GET", 'constructor', 'getUrl', () => HttpRequest, 'build', 'headers', 'name', 'value', 'header', 'body', 'json', () => Buffer, 'query', 'P7!3"<>#P&&LM3$<>%&3&8<P&2\'<&2(<>)"0*P"0+PP7,0-PP&&LM2.!0.P&2/P&\'J20!01P%22!03PP&P74J22!02P"25!055'];
|
|
95
155
|
export class HttpRequest extends IncomingMessage {
|
|
96
156
|
constructor() {
|
|
97
157
|
super(...arguments);
|
|
@@ -110,6 +170,12 @@ export class HttpRequest extends IncomingMessage {
|
|
|
110
170
|
static OPTIONS(path) {
|
|
111
171
|
return new RequestBuilder(path, 'OPTIONS');
|
|
112
172
|
}
|
|
173
|
+
static TRACE(path) {
|
|
174
|
+
return new RequestBuilder(path, 'TRACE');
|
|
175
|
+
}
|
|
176
|
+
static HEAD(path) {
|
|
177
|
+
return new RequestBuilder(path, 'HEAD');
|
|
178
|
+
}
|
|
113
179
|
static PATCH(path) {
|
|
114
180
|
return new RequestBuilder(path, 'PATCH');
|
|
115
181
|
}
|
|
@@ -126,9 +192,10 @@ export class HttpRequest extends IncomingMessage {
|
|
|
126
192
|
return this.method || 'GET';
|
|
127
193
|
}
|
|
128
194
|
getRemoteAddress() {
|
|
129
|
-
return this.
|
|
195
|
+
return this.socket.remoteAddress || '';
|
|
130
196
|
}
|
|
131
197
|
}
|
|
198
|
+
HttpRequest.__type = ['store', function () { return {}; }, () => UploadedFile, 'uploadedFiles', function () { return {}; }, 'body', 'path', () => RequestBuilder, 'GET', () => RequestBuilder, 'POST', () => RequestBuilder, 'OPTIONS', () => RequestBuilder, 'TRACE', () => RequestBuilder, 'HEAD', () => RequestBuilder, 'PATCH', () => RequestBuilder, 'PUT', () => RequestBuilder, 'DELETE', 'getUrl', 'getMethod', 'getRemoteAddress', 'P&"LM3!>"P&P7#LM3$>%P&"LM3&8P&2\'P7(0)P&2\'P7*0+P&2\'P7,0-P&2\'P7.0/P&2\'P7001P&2\'P7203P&2\'P7405P&2\'P7607P&08P&09P&0:5'];
|
|
132
199
|
export class MemoryHttpResponse extends HttpResponse {
|
|
133
200
|
constructor() {
|
|
134
201
|
super(...arguments);
|
|
@@ -177,8 +244,9 @@ export class MemoryHttpResponse extends HttpResponse {
|
|
|
177
244
|
}
|
|
178
245
|
this.body = Buffer.concat([this.body, chunk]);
|
|
179
246
|
}
|
|
180
|
-
super.end(chunk, encoding, callback);
|
|
247
|
+
return super.end(chunk, encoding, callback);
|
|
181
248
|
// if (callback) callback();
|
|
182
249
|
}
|
|
183
250
|
}
|
|
251
|
+
MemoryHttpResponse.__type = [() => Buffer, 'body', function () { return Buffer.alloc(0); }, 'chunk', 'encoding', 'callback', 'write', 'end', 'P7!3">#!!P"2$"2%"2&8"0\'P"2$"2%8"2&8"0(5'];
|
|
184
252
|
//# sourceMappingURL=model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/model.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/model.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,WAAW,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,cAAc,EAAwB,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE1F,MAAM,OAAO,YAAa,SAAQ,cAAc;IAC5C,MAAM,CAAC,IAAY;QACf,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;;;;;;;AAML,MAAM,OAAO,mBAAmB;IAC5B,YACoB,SAAgC,EAAE;QAAlC,WAAM,GAAN,MAAM,CAA4B;IAEtD,CAAC;IAED,SAAS,CAAC,MAAe;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAA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AAK,CAAC;YACjB,KAAK,GAAG,IAAI,CAAC;YACb,QAAQ,GAAG,IAAI,CAAC;SACnB;aAAM,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;YACvC,QAAQ,GAAG,QAAQ,CAAC;YACpB,QAAQ,GAAG,IAAI,CAAC;SACnB;QAED,IAAI,KAAK,EAAE;YACP,IAAI,QAAQ,KAAK,OAAO,KAAK,EAAE;gBAC3B,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,IAAI,MAAM,CAAC,CAAC;aAClD;YACD,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;SACjD;QACD,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC5C,4BAA4B;IAChC,CAAC;;wEAtDqB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}>;
|
|
1
|
+
export declare class HttpConfig {
|
|
2
|
+
debug: boolean;
|
|
3
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
1
|
+
export class HttpConfig {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.debug = false;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
HttpConfig.__type = ['debug', function () { return false; }, ')3!>"5'];
|
|
6
7
|
//# sourceMappingURL=module.config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.config.js","sourceRoot":"","sources":["../../../src/module.config.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"module.config.js","sourceRoot":"","sources":["../../../src/module.config.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAU;IAAvB;QACI,UAAK,GAAY,KAAK,CAAC;KAC1B;;mDADoB,KAAK"}
|
package/dist/esm/src/module.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { HttpConfig } from './module.config';
|
|
1
2
|
import { AppModule } from '@deepkit/app';
|
|
2
3
|
import { HttpControllers } from './controllers';
|
|
3
4
|
import '@deepkit/type';
|
|
4
5
|
import { ClassType } from '@deepkit/core';
|
|
5
|
-
declare const HttpModule_base: import("@deepkit/app").AppModuleClass<
|
|
6
|
-
debug: import("@deepkit/type").FieldDecoratorResult<boolean>;
|
|
7
|
-
}>>;
|
|
6
|
+
declare const HttpModule_base: import("@deepkit/app").AppModuleClass<HttpConfig>;
|
|
8
7
|
export declare class HttpModule extends HttpModule_base {
|
|
9
8
|
protected httpControllers: HttpControllers;
|
|
10
9
|
process(): void;
|
package/dist/esm/src/module.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { __ΩClassType as __ΩClassType } from '@deepkit/core';
|
|
1
2
|
import { HttpListener, HttpResultFormatter, httpWorkflow } from './http';
|
|
2
|
-
import {
|
|
3
|
-
import { createModule } from '@deepkit/app';
|
|
3
|
+
import { HttpConfig } from './module.config';
|
|
4
|
+
import { AppModule, createModule } from '@deepkit/app';
|
|
4
5
|
import { Router } from './router';
|
|
5
6
|
import { HttpKernel } from './kernel';
|
|
6
7
|
import { HttpRouterFilterResolver } from './filter';
|
|
@@ -10,7 +11,7 @@ import { HttpRequest, HttpResponse } from './model';
|
|
|
10
11
|
import '@deepkit/type';
|
|
11
12
|
import { httpClass } from './decorator';
|
|
12
13
|
export class HttpModule extends createModule({
|
|
13
|
-
config:
|
|
14
|
+
config: HttpConfig,
|
|
14
15
|
providers: [
|
|
15
16
|
Router,
|
|
16
17
|
HttpKernel,
|
|
@@ -53,4 +54,5 @@ export class HttpModule extends createModule({
|
|
|
53
54
|
this.httpControllers.add(controller, module);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
57
|
+
HttpModule.__type = ['process', () => AppModule, 'module', () => __ΩClassType, 'controller', 'processController', 'P"0!PP"7"2#n$2%"0&5'];
|
|
56
58
|
//# sourceMappingURL=module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../src/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../src/module.ts"],"names":[],"mappings":"6CAU0B,eAAe;AAVzC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,OAAO,UAAW,SAAQ,YAAY,CAAC;IACzC,MAAM,EAAE,UAAU;IAClB,SAAS,EAAE;QACP,MAAM;QACN,UAAU;QACV,mBAAmB;QACnB,wBAAwB;QACxB,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE;QACxC,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE;QACvC,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,MAAM,CAAC,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAC,EAAE;KACtE;IACD,SAAS,EAAE;QACP,YAAY;KACf;IACD,SAAS,EAAE;QACP,YAAY;KACf;IACD,OAAO,EAAE;QACL,MAAM;QACN,UAAU;QACV,mBAAmB;QACnB,wBAAwB;QACxB,YAAY;QACZ,WAAW;QACX,eAAe;QACf,MAAM;KACT;CACJ,CAAC;IA3BF;;QA4Bc,oBAAe,GAAG,IAAI,eAAe,CAAC;KAanD;IAXG,OAAO;QACH,IAAI,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;IACnF,CAAC;IAED,iBAAiB,CAAC,MAAsB,EAAE,UAAqB;QAC3D,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAChD,IAAI,CAAC,UAAU;YAAE,OAAO;QAExB,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC;YAAE,MAAM,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QAC/F,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC"}
|
package/dist/esm/src/router.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
1
|
import { ClassType, CompilerContext } from '@deepkit/core';
|
|
3
|
-
import {
|
|
2
|
+
import { ReflectionParameter, SerializationOptions, Serializer, Type } from '@deepkit/type';
|
|
4
3
|
import { HttpRequest, HttpRequestQuery, HttpRequestResolvedParameters } from './model';
|
|
5
|
-
import { InjectorContext, TagRegistry } from '@deepkit/injector';
|
|
6
|
-
import {
|
|
4
|
+
import { InjectorContext, InjectorModule, TagRegistry } from '@deepkit/injector';
|
|
5
|
+
import { LoggerInterface } from '@deepkit/logger';
|
|
7
6
|
import { HttpControllers } from './controllers';
|
|
8
|
-
import {
|
|
7
|
+
import { MiddlewareRegistry } from '@deepkit/app';
|
|
9
8
|
import { HttpMiddlewareConfig, HttpMiddlewareFn } from './middleware';
|
|
10
9
|
export declare type RouteParameterResolverForInjector = ((injector: InjectorContext) => any[] | Promise<any[]>);
|
|
11
10
|
interface ResolvedController {
|
|
@@ -43,19 +42,10 @@ export declare class UploadedFile {
|
|
|
43
42
|
lastModifiedDate: Date | null;
|
|
44
43
|
}
|
|
45
44
|
export interface RouteControllerAction {
|
|
46
|
-
module?:
|
|
45
|
+
module?: InjectorModule<any>;
|
|
47
46
|
controller: ClassType;
|
|
48
47
|
methodName: string;
|
|
49
48
|
}
|
|
50
|
-
export interface RouteParameterConfig {
|
|
51
|
-
type?: 'body' | 'query' | 'queries';
|
|
52
|
-
/**
|
|
53
|
-
* undefined = propertyName, '' === root, else given path
|
|
54
|
-
*/
|
|
55
|
-
typePath?: string;
|
|
56
|
-
optional: boolean;
|
|
57
|
-
name: string;
|
|
58
|
-
}
|
|
59
49
|
export declare class RouteConfig {
|
|
60
50
|
readonly name: string;
|
|
61
51
|
readonly httpMethods: string[];
|
|
@@ -63,77 +53,54 @@ export declare class RouteConfig {
|
|
|
63
53
|
readonly action: RouteControllerAction;
|
|
64
54
|
internal: boolean;
|
|
65
55
|
baseUrl: string;
|
|
66
|
-
parameterRegularExpressions: {
|
|
67
|
-
[name: string]: any;
|
|
68
|
-
};
|
|
69
56
|
responses: {
|
|
70
57
|
statusCode: number;
|
|
71
58
|
description: string;
|
|
72
|
-
type?:
|
|
59
|
+
type?: Type;
|
|
73
60
|
}[];
|
|
74
61
|
description: string;
|
|
75
62
|
groups: string[];
|
|
76
63
|
category: string;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*/
|
|
80
|
-
returnSchema?: PropertySchema;
|
|
81
|
-
serializationOptions?: JitConverterOptions;
|
|
64
|
+
returnType?: Type;
|
|
65
|
+
serializationOptions?: SerializationOptions;
|
|
82
66
|
serializer?: Serializer;
|
|
83
67
|
/**
|
|
84
68
|
* When assigned defines where this route came from.
|
|
85
69
|
*/
|
|
86
|
-
module?:
|
|
70
|
+
module?: InjectorModule<any>;
|
|
87
71
|
resolverForToken: Map<any, ClassType>;
|
|
88
72
|
middlewares: {
|
|
89
73
|
config: HttpMiddlewareConfig;
|
|
90
|
-
module:
|
|
74
|
+
module: InjectorModule<any>;
|
|
91
75
|
}[];
|
|
92
76
|
resolverForParameterName: Map<string, ClassType>;
|
|
93
77
|
/**
|
|
94
78
|
* An arbitrary data container the user can use to store app specific settings/values.
|
|
95
79
|
*/
|
|
96
80
|
data: Map<any, any>;
|
|
97
|
-
parameters: {
|
|
98
|
-
[name: string]: RouteParameterConfig;
|
|
99
|
-
};
|
|
100
81
|
constructor(name: string, httpMethods: string[], path: string, action: RouteControllerAction, internal?: boolean);
|
|
101
|
-
getSchemaForResponse(statusCode: number):
|
|
82
|
+
getSchemaForResponse(statusCode: number): Type | undefined;
|
|
102
83
|
getFullPath(): string;
|
|
103
84
|
}
|
|
104
|
-
/**
|
|
105
|
-
* When this class is injected into a route, then validation errors are not automatically thrown (using onHttpControllerValidationError event),
|
|
106
|
-
* but injected to the route itself. The user is then responsible to handle the errors.
|
|
107
|
-
*
|
|
108
|
-
* Note: The body parameter is still passed, however it might contain now invalid data. The BodyValidation tells what data is invalid.
|
|
109
|
-
*/
|
|
110
|
-
export declare class BodyValidation {
|
|
111
|
-
readonly errors: ValidationFailedItem[];
|
|
112
|
-
constructor(errors?: ValidationFailedItem[]);
|
|
113
|
-
hasErrors(prefix?: string): boolean;
|
|
114
|
-
getErrors(prefix?: string): ValidationFailedItem[];
|
|
115
|
-
getErrorsForPath(path: string): ValidationFailedItem[];
|
|
116
|
-
getErrorMessageForPath(path: string): string;
|
|
117
|
-
}
|
|
118
85
|
declare class ParsedRoute {
|
|
119
86
|
routeConfig: RouteConfig;
|
|
120
87
|
regex?: string;
|
|
121
|
-
customValidationErrorHandling?: ParsedRouteParameter;
|
|
122
88
|
pathParameterNames: {
|
|
123
89
|
[name: string]: number;
|
|
124
90
|
};
|
|
125
91
|
protected parameters: ParsedRouteParameter[];
|
|
126
92
|
constructor(routeConfig: RouteConfig);
|
|
127
|
-
addParameter(property:
|
|
93
|
+
addParameter(property: ReflectionParameter): ParsedRouteParameter;
|
|
128
94
|
getParameters(): ParsedRouteParameter[];
|
|
129
95
|
getParameter(name: string): ParsedRouteParameter;
|
|
130
96
|
}
|
|
131
97
|
declare class ParsedRouteParameter {
|
|
132
|
-
|
|
133
|
-
config?: RouteParameterConfig | undefined;
|
|
98
|
+
parameter: ReflectionParameter;
|
|
134
99
|
regexPosition?: number;
|
|
135
|
-
constructor(
|
|
100
|
+
constructor(parameter: ReflectionParameter);
|
|
136
101
|
get body(): boolean;
|
|
102
|
+
get bodyValidation(): boolean;
|
|
103
|
+
getType(): Type;
|
|
137
104
|
get query(): boolean;
|
|
138
105
|
get queries(): boolean;
|
|
139
106
|
get typePath(): string | undefined;
|
|
@@ -170,16 +137,16 @@ export declare class Router {
|
|
|
170
137
|
}) => string;
|
|
171
138
|
protected routes: RouteConfig[];
|
|
172
139
|
private parseBody;
|
|
173
|
-
constructor(controllers: HttpControllers, logger:
|
|
140
|
+
constructor(controllers: HttpControllers, logger: LoggerInterface, tagRegistry: TagRegistry, middlewareRegistry?: MiddlewareRegistry);
|
|
174
141
|
getRoutes(): RouteConfig[];
|
|
175
142
|
static forControllers(controllers: (ClassType | {
|
|
176
|
-
module:
|
|
143
|
+
module: InjectorModule<any>;
|
|
177
144
|
controller: ClassType;
|
|
178
|
-
})[], tagRegistry?: TagRegistry, middlewareRegistry?: MiddlewareRegistry, module?:
|
|
145
|
+
})[], tagRegistry?: TagRegistry, middlewareRegistry?: MiddlewareRegistry, module?: InjectorModule<any>): Router;
|
|
179
146
|
protected getRouteCode(compiler: CompilerContext, routeConfig: RouteConfig): string;
|
|
180
147
|
protected getRouteUrlResolveCode(compiler: CompilerContext, routeConfig: RouteConfig): string;
|
|
181
148
|
addRoute(routeConfig: RouteConfig): void;
|
|
182
|
-
addRouteForController(controller: ClassType, module:
|
|
149
|
+
addRouteForController(controller: ClassType, module: InjectorModule<any>): void;
|
|
183
150
|
protected build(): (request: HttpRequest) => ResolvedController | undefined;
|
|
184
151
|
protected buildUrlResolver(): any;
|
|
185
152
|
resolveUrl(routeName: string, parameters?: {
|
|
@@ -189,3 +156,7 @@ export declare class Router {
|
|
|
189
156
|
resolve(method: string, url: string): ResolvedController | undefined;
|
|
190
157
|
}
|
|
191
158
|
export {};
|
|
159
|
+
export declare type __ΩRouteParameterResolverForInjector = any[];
|
|
160
|
+
export declare type __ΩRouteControllerAction = any[];
|
|
161
|
+
export declare type __ΩRouteParameterResolver = any[];
|
|
162
|
+
export declare type __ΩRouteParameterResolverContext = any[];
|