@deepkit/http 1.0.1-alpha.68 → 1.0.1-alpha.72
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/dist/cjs/src/decorator.d.ts +8 -6
- package/dist/cjs/src/decorator.js +49 -12
- package/dist/cjs/src/decorator.js.map +1 -1
- package/dist/cjs/src/filter.d.ts +3 -3
- package/dist/cjs/src/filter.js +3 -3
- package/dist/cjs/src/filter.js.map +1 -1
- package/dist/cjs/src/http.d.ts +49 -11
- package/dist/cjs/src/http.js +128 -37
- package/dist/cjs/src/http.js.map +1 -1
- package/dist/cjs/src/kernel.d.ts +3 -3
- package/dist/cjs/src/kernel.js +1 -1
- package/dist/cjs/src/kernel.js.map +1 -1
- package/dist/cjs/src/model.d.ts +11 -3
- package/dist/cjs/src/model.js +58 -26
- package/dist/cjs/src/model.js.map +1 -1
- package/dist/cjs/src/module.js +5 -3
- package/dist/cjs/src/module.js.map +1 -1
- package/dist/cjs/src/router.d.ts +84 -11
- package/dist/cjs/src/router.js +280 -94
- package/dist/cjs/src/router.js.map +1 -1
- package/dist/cjs/src/static-serving.js +15 -8
- package/dist/cjs/src/static-serving.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/src/decorator.d.ts +8 -6
- package/dist/esm/src/decorator.js +47 -11
- package/dist/esm/src/decorator.js.map +1 -1
- package/dist/esm/src/filter.d.ts +3 -3
- package/dist/esm/src/filter.js +4 -4
- package/dist/esm/src/filter.js.map +1 -1
- package/dist/esm/src/http.d.ts +49 -11
- package/dist/esm/src/http.js +101 -23
- package/dist/esm/src/http.js.map +1 -1
- package/dist/esm/src/kernel.d.ts +3 -3
- package/dist/esm/src/kernel.js +2 -2
- package/dist/esm/src/kernel.js.map +1 -1
- package/dist/esm/src/model.d.ts +11 -3
- package/dist/esm/src/model.js +47 -15
- package/dist/esm/src/model.js.map +1 -1
- package/dist/esm/src/module.js +5 -3
- package/dist/esm/src/module.js.map +1 -1
- package/dist/esm/src/router.d.ts +84 -11
- package/dist/esm/src/router.js +278 -94
- package/dist/esm/src/router.js.map +1 -1
- package/dist/esm/src/static-serving.js +16 -9
- package/dist/esm/src/static-serving.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +17 -14
- package/src/decorator.ts +9 -6
- package/src/filter.ts +4 -4
- package/src/http.ts +88 -15
- package/src/kernel.ts +2 -2
- package/src/model.ts +35 -6
- package/src/module.ts +5 -3
- package/src/router.ts +286 -73
- package/src/static-serving.ts +6 -3
- package/coverage/clover.xml +0 -1086
- package/coverage/coverage-final.json +0 -12
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -79
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -126
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -170
- package/coverage/lcov-report/src/controllers.ts.html +0 -113
- package/coverage/lcov-report/src/decorator.ts.html +0 -1280
- package/coverage/lcov-report/src/filter.ts.html +0 -734
- package/coverage/lcov-report/src/http.ts.html +0 -2192
- package/coverage/lcov-report/src/index.html +0 -246
- package/coverage/lcov-report/src/kernel.ts.html +0 -260
- package/coverage/lcov-report/src/middleware.ts.html +0 -428
- package/coverage/lcov-report/src/model.ts.html +0 -937
- package/coverage/lcov-report/src/module.config.ts.html +0 -89
- package/coverage/lcov-report/src/module.ts.html +0 -245
- package/coverage/lcov-report/src/router.ts.html +0 -2318
- package/coverage/lcov-report/tests/index.html +0 -111
- package/coverage/lcov-report/tests/utils.ts.html +0 -176
- package/coverage/lcov.info +0 -2225
- package/dist/cjs/tests/filter.spec.d.ts +0 -1
- package/dist/cjs/tests/filter.spec.js +0 -251
- package/dist/cjs/tests/filter.spec.js.map +0 -1
- package/dist/cjs/tests/middleware.spec.d.ts +0 -1
- package/dist/cjs/tests/middleware.spec.js +0 -471
- package/dist/cjs/tests/middleware.spec.js.map +0 -1
- package/dist/cjs/tests/model.spec.d.ts +0 -1
- package/dist/cjs/tests/model.spec.js +0 -23
- package/dist/cjs/tests/model.spec.js.map +0 -1
- package/dist/cjs/tests/module.spec.d.ts +0 -1
- package/dist/cjs/tests/module.spec.js +0 -46
- package/dist/cjs/tests/module.spec.js.map +0 -1
- package/dist/cjs/tests/router.spec.d.ts +0 -1
- package/dist/cjs/tests/router.spec.js +0 -987
- package/dist/cjs/tests/router.spec.js.map +0 -1
- package/dist/cjs/tests/utils.d.ts +0 -8
- package/dist/cjs/tests/utils.js +0 -30
- package/dist/cjs/tests/utils.js.map +0 -1
- package/dist/esm/tests/filter.spec.d.ts +0 -1
- package/dist/esm/tests/filter.spec.js +0 -249
- package/dist/esm/tests/filter.spec.js.map +0 -1
- package/dist/esm/tests/middleware.spec.d.ts +0 -1
- package/dist/esm/tests/middleware.spec.js +0 -469
- package/dist/esm/tests/middleware.spec.js.map +0 -1
- package/dist/esm/tests/model.spec.d.ts +0 -1
- package/dist/esm/tests/model.spec.js +0 -21
- package/dist/esm/tests/model.spec.js.map +0 -1
- package/dist/esm/tests/module.spec.d.ts +0 -1
- package/dist/esm/tests/module.spec.js +0 -44
- package/dist/esm/tests/module.spec.js.map +0 -1
- package/dist/esm/tests/router.spec.d.ts +0 -1
- package/dist/esm/tests/router.spec.js +0 -985
- package/dist/esm/tests/router.spec.js.map +0 -1
- package/dist/esm/tests/utils.d.ts +0 -8
- package/dist/esm/tests/utils.js +0 -26
- package/dist/esm/tests/utils.js.map +0 -1
- package/tests/filter.spec.ts +0 -181
- package/tests/middleware.spec.ts +0 -440
- package/tests/model.spec.ts +0 -26
- package/tests/module.spec.ts +0 -32
- package/tests/router.spec.ts +0 -781
- package/tests/utils.ts +0 -32
|
@@ -10,6 +10,10 @@ import { __ΩPropertyDecoratorFn as __ΩPropertyDecoratorFn } from '@deepkit/typ
|
|
|
10
10
|
import { __ΩDecoratorAndFetchSignature as __ΩDecoratorAndFetchSignature } from '@deepkit/type';
|
|
11
11
|
import { __ΩDualDecorator as __ΩDualDecorator } from '@deepkit/type';
|
|
12
12
|
import { __ΩUnionToIntersection as __ΩUnionToIntersection } from '@deepkit/type';
|
|
13
|
+
function __assignType(fn, args) {
|
|
14
|
+
fn.__type = args;
|
|
15
|
+
return fn;
|
|
16
|
+
}
|
|
13
17
|
const __ΩPick = ['T', 'K', 'l+e#!e"!fRb!b"Pde""N#!'];
|
|
14
18
|
const __ΩExclude = ['T', 'U', 'l6!Re$!RPe#!e$"qk#%QRb!b"Pde"!p)'];
|
|
15
19
|
const __ΩOmit = ['T', 'K', () => __ΩPick, () => __ΩExclude, 'b!b"e!!e!!ge!"o$#o##'];
|
|
@@ -30,7 +34,7 @@ function isMiddlewareClassTypeOrFn(v) {
|
|
|
30
34
|
return isClass(v) || !isDecoratorContext(httpMiddleware, v);
|
|
31
35
|
}
|
|
32
36
|
isMiddlewareClassTypeOrFn.__type = [() => __ΩHttpActionMiddleware, 'v', 'isMiddlewareClassTypeOrFn', 'Pn!2"!/#'];
|
|
33
|
-
class HttpController {
|
|
37
|
+
export class HttpController {
|
|
34
38
|
constructor() {
|
|
35
39
|
this.baseUrl = '';
|
|
36
40
|
this.actions = new Set();
|
|
@@ -93,7 +97,7 @@ export class HttpAction {
|
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
99
|
HttpAction.__type = ['name', function () { return ''; }, 'description', function () { return ''; }, 'category', function () { return ''; }, 'path', function () { return ''; }, 'httpMethods', function () { return []; }, 'methodName', function () { return ''; }, 'groups', function () { return []; }, () => Serializer, 'serializer', () => 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'];
|
|
96
|
-
export class
|
|
100
|
+
export class HttpControllerDecorator {
|
|
97
101
|
constructor() {
|
|
98
102
|
this.t = new HttpController;
|
|
99
103
|
}
|
|
@@ -104,7 +108,7 @@ export class HttpDecorator {
|
|
|
104
108
|
this.t.groups.push(...group);
|
|
105
109
|
}
|
|
106
110
|
middleware(...middlewares) {
|
|
107
|
-
this.t.middlewares.push(...middlewares.map(
|
|
111
|
+
this.t.middlewares.push(...middlewares.map(__assignType(v => isMiddlewareClassTypeOrFn(v) ? httpMiddleware.for(v) : v, ['v', '', 'P"2!"/"'])));
|
|
108
112
|
}
|
|
109
113
|
/**
|
|
110
114
|
* Adds a parameter resolver for parameters based on the class type. Use .resolveParameterByName() for name-based resolving.
|
|
@@ -160,8 +164,8 @@ export class HttpDecorator {
|
|
|
160
164
|
this.t.addAction(action);
|
|
161
165
|
}
|
|
162
166
|
}
|
|
163
|
-
|
|
164
|
-
export const httpClass = createClassDecoratorContext(
|
|
167
|
+
HttpControllerDecorator.__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'];
|
|
168
|
+
export const httpClass = createClassDecoratorContext(HttpControllerDecorator);
|
|
165
169
|
export class HttpActionDecorator {
|
|
166
170
|
constructor() {
|
|
167
171
|
this.t = new HttpAction;
|
|
@@ -169,6 +173,8 @@ export class HttpActionDecorator {
|
|
|
169
173
|
onDecorator(target, property, parameterIndexOrDescriptor) {
|
|
170
174
|
if (!property)
|
|
171
175
|
return;
|
|
176
|
+
if (target === Object)
|
|
177
|
+
return;
|
|
172
178
|
this.t.methodName = property;
|
|
173
179
|
httpClass.setAction(this.t)(target);
|
|
174
180
|
}
|
|
@@ -185,7 +191,7 @@ export class HttpActionDecorator {
|
|
|
185
191
|
this.t.serializer = serializer;
|
|
186
192
|
}
|
|
187
193
|
middleware(...middlewares) {
|
|
188
|
-
this.t.middlewares.push(...middlewares.map(
|
|
194
|
+
this.t.middlewares.push(...middlewares.map(__assignType(v => isMiddlewareClassTypeOrFn(v) ? httpMiddleware.for(v) : v, ['v', '', 'P"2!"/"'])));
|
|
189
195
|
}
|
|
190
196
|
/**
|
|
191
197
|
* Allows to change the HttpAction object and composite multiple properties into one function.
|
|
@@ -285,20 +291,48 @@ export class HttpActionDecorator {
|
|
|
285
291
|
*
|
|
286
292
|
* ```typescript
|
|
287
293
|
*
|
|
288
|
-
*
|
|
294
|
+
* http.GET().response<boolean>(200, 'All ok')
|
|
289
295
|
*
|
|
290
296
|
* interface User {
|
|
291
297
|
* username: string;
|
|
292
298
|
* }
|
|
293
|
-
*
|
|
299
|
+
* http.GET().response<User>(200, 'User object')
|
|
294
300
|
*
|
|
295
301
|
* interface HttpErrorMessage {
|
|
296
302
|
* error: string;
|
|
297
303
|
* }
|
|
298
|
-
*
|
|
304
|
+
* http.GET().response<HttpErrorMessage>(500, 'Error')
|
|
299
305
|
* ```
|
|
300
306
|
*/
|
|
301
|
-
response(statusCode, description
|
|
307
|
+
response(statusCode, description, type) {
|
|
308
|
+
var _a;
|
|
309
|
+
if (description === void 0) { description = ''; }
|
|
310
|
+
if (type === void 0) { type = (_a = this.
|
|
311
|
+
/**
|
|
312
|
+
* Adds additional information about what HTTP status codes are available in this route.
|
|
313
|
+
* You can add additionally a description and a response body type.
|
|
314
|
+
*
|
|
315
|
+
* The type is used for serialization for responses with the given statusCode.
|
|
316
|
+
*
|
|
317
|
+
* This information is available in Deepkit API console.
|
|
318
|
+
*
|
|
319
|
+
* ```typescript
|
|
320
|
+
*
|
|
321
|
+
* http.GET().response<boolean>(200, 'All ok')
|
|
322
|
+
*
|
|
323
|
+
* interface User {
|
|
324
|
+
* username: string;
|
|
325
|
+
* }
|
|
326
|
+
* http.GET().response<User>(200, 'User object')
|
|
327
|
+
*
|
|
328
|
+
* interface HttpErrorMessage {
|
|
329
|
+
* error: string;
|
|
330
|
+
* }
|
|
331
|
+
* http.GET().response<HttpErrorMessage>(500, 'Error')
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
response.Ω) === null || _a === void 0 ? void 0 : _a[0]; }
|
|
335
|
+
this.response.Ω = undefined;
|
|
302
336
|
this.t.responses.push({ statusCode, description, type: type ? resolveReceiveType(type) : undefined });
|
|
303
337
|
}
|
|
304
338
|
/**
|
|
@@ -351,10 +385,12 @@ export class HttpActionDecorator {
|
|
|
351
385
|
}
|
|
352
386
|
}
|
|
353
387
|
HttpActionDecorator.__type = [() => __ΩClassType, 'target', 'property', 'parameterIndexOrDescriptor', 'onDecorator', 'name', 'description', () => __ΩSerializationOptions, 'options', 'serialization', () => 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'];
|
|
354
|
-
const __ΩHttpActionFluidDecorator = ['T', 'D', "response", 'statusCode', 'description', () => __ΩReceiveType, 'type',
|
|
388
|
+
const __ΩHttpActionFluidDecorator = ['T', 'D', "response", 'statusCode', 'description', () => __ΩReceiveType, 'type', () => __ΩHttpActionFluidDecorator, '', 'args', () => __ΩHttpActionFluidDecorator, () => __ΩHttpActionFluidDecorator, () => __Ω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!'];
|
|
355
389
|
const __ΩHttpActionPropertyDecoratorResult = [() => __ΩHttpActionFluidDecorator, () => __ΩExtractClass, () => HttpActionDecorator, () => __ΩPropertyDecoratorFn, () => __ΩDecoratorAndFetchSignature, () => HttpActionDecorator, () => __ΩPropertyDecoratorFn, 'Pi#o""n$o!#i&n\'o%#K'];
|
|
356
390
|
export const httpAction = createPropertyDecoratorContext(HttpActionDecorator);
|
|
357
391
|
const __Ω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!'];
|
|
358
392
|
const __ΩMergedHttp = ['T', () => __ΩHttpMerge, () => __ΩOmit, () => __ΩUnionToIntersection, "_fetch", "t", 'b!e!!\'fo$"P.%.&Jo##o""'];
|
|
393
|
+
const __ΩHttpDecorator = [() => __ΩPropertyDecoratorFn, () => __ΩHttpActionFluidDecorator, () => HttpActionDecorator, () => __ΩPropertyDecoratorFn, 'Pn!P7#n$o"#K'];
|
|
394
|
+
export { __ΩHttpDecorator as __ΩHttpDecorator };
|
|
359
395
|
export const http = mergeDecorator(httpClass, httpAction);
|
|
360
396
|
//# sourceMappingURL=decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../src/decorator.ts"],"names":[],"mappings":"6CAU4C,eAAe;mEAkBpD,eAAe;uEACiB,UAAU;iDAD1C,eAAe;uDAEiE,cAAc;2DAAd,cAAc;+DAF9F,eAAe;mDAAf,eAAe;iEAAf,eAAe;+EAAf,eAAe;qDAAf,eAAe;iEAAf,eAAe
|
|
1
|
+
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../src/decorator.ts"],"names":[],"mappings":"6CAU4C,eAAe;mEAkBpD,eAAe;uEACiB,UAAU;iDAD1C,eAAe;uDAEiE,cAAc;2DAAd,cAAc;+DAF9F,eAAe;mDAAf,eAAe;iEAAf,eAAe;+EAAf,eAAe;qDAAf,eAAe;iEAAf,eAAe;;;;;;;;AA5BtB;;;;;;;;GAQG;AAEH,OAAO,EAAa,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAEH,2BAA2B,EAC3B,8BAA8B,EAK9B,kBAAkB,EAClB,cAAc,EAGd,kBAAkB,EAElB,UAAU,EAGb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAkB,oBAAoB,EAAoB,MAAM,cAAc,CAAC;;AAItG,SAAS,yBAAyB,CAAC,CAAuB;IACtD,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;AAChE,CAAC;;AAED,MAAM,OAAO,cAAc;IAA3B;QACI,YAAO,GAAW,EAAE,CAAC;QACrB,YAAO,GAAG,IAAI,GAAG,EAAc,CAAC;QACh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;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAI,UAAkB,EAAE,WAAwB,EAAE,IAAqB;;oCAA/C,EAAA,gBAAwB;6BAAE,EAAA;QAvB1D;;;;;;;;;;;;;;;;;;;;;;WAsBG;QACH,QAAQ,8CAAuE;aAA/E,QAAQ;QACJ,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;KACzG;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,gBAAgB,CAAC,SAAmC,EAAE,QAA2C;QAC7F,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACrD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,sBAAsB,CAAC,IAAY,EAAE,QAA2C;QAC5E,IAAI,CAAC,CAAC,CAAC,wBAAwB,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACxD,CAAC;;;;;AAWL,MAAM,CAAC,MAAM,UAAU,GAAsC,8BAA8B,CAAC,mBAAmB,CAAC,CAAC;;;;;AAQjH,MAAM,CAAC,MAAM,IAAI,GAAsD,cAAc,CAAC,SAAS,EAAE,UAAU,CAA6D,CAAC"}
|
package/dist/esm/src/filter.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClassType } from '@deepkit/core';
|
|
2
2
|
import { AppModule } from '@deepkit/app';
|
|
3
|
-
import { RouteConfig,
|
|
3
|
+
import { RouteConfig, HttpRouter } from './router';
|
|
4
4
|
export interface HttpRouteFilterRoute {
|
|
5
5
|
path?: string;
|
|
6
6
|
pathRegExp?: RegExp;
|
|
@@ -22,8 +22,8 @@ export declare class HttpRouteFilterModel {
|
|
|
22
22
|
reset(): void;
|
|
23
23
|
}
|
|
24
24
|
export declare class HttpRouterFilterResolver {
|
|
25
|
-
protected router:
|
|
26
|
-
constructor(router:
|
|
25
|
+
protected router: HttpRouter;
|
|
26
|
+
constructor(router: HttpRouter);
|
|
27
27
|
/**
|
|
28
28
|
* Resolves
|
|
29
29
|
*/
|
package/dist/esm/src/filter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __ΩClassType as __ΩClassType } from '@deepkit/core';
|
|
2
2
|
import { AppModule } from '@deepkit/app';
|
|
3
|
-
import { RouteConfig,
|
|
3
|
+
import { RouteConfig, HttpRouter } from './router';
|
|
4
4
|
const __ΩHttpRouteFilterRoute = ['path', 'pathRegExp', "GET", "HEAD", "POST", "PATCH", "PUT", "DELETE", "OPTIONS", "TRACE", 'httpMethod', 'category', 'group', 'P&4!8A4"8P.#.$.%.&.\'.(.).*J4+8&4,8&4-8M'];
|
|
5
5
|
export { __ΩHttpRouteFilterRoute as __ΩHttpRouteFilterRoute };
|
|
6
6
|
export class HttpRouteFilterModel {
|
|
@@ -54,9 +54,9 @@ export class HttpRouterFilterResolver {
|
|
|
54
54
|
resolve(filter) {
|
|
55
55
|
const result = [];
|
|
56
56
|
outer: for (const routeConfig of this.router.getRoutes()) {
|
|
57
|
-
if (filter.controllers.length && !filter.controllers.includes(routeConfig.action.controller))
|
|
57
|
+
if (filter.controllers.length && routeConfig.action.type === 'controller' && !filter.controllers.includes(routeConfig.action.controller))
|
|
58
58
|
continue;
|
|
59
|
-
if (filter.excludeControllers.length && filter.excludeControllers.includes(routeConfig.action.controller))
|
|
59
|
+
if (filter.excludeControllers.length && routeConfig.action.type === 'controller' && filter.excludeControllers.includes(routeConfig.action.controller))
|
|
60
60
|
continue;
|
|
61
61
|
if (filter.modules.length) {
|
|
62
62
|
if (!routeConfig.module)
|
|
@@ -145,7 +145,7 @@ export class HttpRouterFilterResolver {
|
|
|
145
145
|
return result;
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
HttpRouterFilterResolver.__type = [() =>
|
|
148
|
+
HttpRouterFilterResolver.__type = [() => HttpRouter, 'router', 'constructor', () => HttpRouteFilterModel, 'filter', () => RouteConfig, 'resolve', 'PP7!2"<"0#PP7$2%P7&F0\'5'];
|
|
149
149
|
/**
|
|
150
150
|
* A class to describe a filter for routes.
|
|
151
151
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../src/filter.ts"],"names":[],"mappings":"6CAA0B,eAAe;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../src/filter.ts"],"names":[],"mappings":"6CAA0B,eAAe;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;;;AAUnD,MAAM,OAAO,oBAAoB;IAAjC;QACI,gBAAW,GAAgB,EAAE,CAAC;QAC9B,uBAAkB,GAAgB,EAAE,CAAC;QAErC,WAAM,GAA2B,EAAE,CAAC;QACpC,kBAAa,GAA2B,EAAE,CAAC;QAE3C,eAAU,GAAa,EAAE,CAAC;QAC1B,sBAAiB,GAAa,EAAE,CAAC;QAEjC,YAAO,GAAqB,EAAE,CAAC;QAC/B,mBAAc,GAAqB,EAAE,CAAC;QAEtC,kBAAa,GAAgC,EAAE,CAAC;QAChD,yBAAoB,GAAgC,EAAE,CAAC;KAe1D;IAbG,KAAK;QACD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;QAE7B,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QAExB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,iBAAiB,GA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ttpRequest, HttpResponse } from './model';
|
|
5
5
|
import { InjectorContext } from '@deepkit/injector';
|
|
6
6
|
import { LoggerInterface } from '@deepkit/logger';
|
|
7
|
-
import { RouteConfig, RouteParameterResolverForInjector
|
|
7
|
+
import { HttpRouter, RouteConfig, RouteParameterResolverForInjector } from './router';
|
|
8
8
|
import { WorkflowEvent } from '@deepkit/workflow';
|
|
9
9
|
import type { ElementStruct } from '@deepkit/template';
|
|
10
10
|
import { Stopwatch } from '@deepkit/stopwatch';
|
|
11
|
+
import stream from 'stream';
|
|
11
12
|
export declare function isElementStruct(v: any): v is ElementStruct;
|
|
12
13
|
export declare class Redirect {
|
|
13
14
|
statusCode: number;
|
|
@@ -28,22 +29,49 @@ export declare class HttpError<T extends number> extends CustomError {
|
|
|
28
29
|
constructor(message: string, httpCode: T);
|
|
29
30
|
}
|
|
30
31
|
export declare function createHttpError<T extends number>(code: T, defaultMessage?: string): ClassType<HttpError<T>>;
|
|
31
|
-
declare const HttpNotFoundError_base: ClassType<HttpError<404>>;
|
|
32
|
-
export declare class HttpNotFoundError extends HttpNotFoundError_base {
|
|
33
|
-
}
|
|
34
32
|
declare const HttpBadRequestError_base: ClassType<HttpError<400>>;
|
|
35
33
|
export declare class HttpBadRequestError extends HttpBadRequestError_base {
|
|
36
34
|
}
|
|
35
|
+
declare const HttpUnauthorizedError_base: ClassType<HttpError<401>>;
|
|
36
|
+
export declare class HttpUnauthorizedError extends HttpUnauthorizedError_base {
|
|
37
|
+
}
|
|
37
38
|
declare const HttpAccessDeniedError_base: ClassType<HttpError<403>>;
|
|
38
39
|
export declare class HttpAccessDeniedError extends HttpAccessDeniedError_base {
|
|
39
40
|
}
|
|
41
|
+
declare const HttpNotFoundError_base: ClassType<HttpError<404>>;
|
|
42
|
+
export declare class HttpNotFoundError extends HttpNotFoundError_base {
|
|
43
|
+
}
|
|
44
|
+
declare const HttpMethodNotAllowedError_base: ClassType<HttpError<405>>;
|
|
45
|
+
export declare class HttpMethodNotAllowedError extends HttpMethodNotAllowedError_base {
|
|
46
|
+
}
|
|
47
|
+
declare const HttpNotAcceptableError_base: ClassType<HttpError<406>>;
|
|
48
|
+
export declare class HttpNotAcceptableError extends HttpNotAcceptableError_base {
|
|
49
|
+
}
|
|
50
|
+
declare const HttpTimeoutError_base: ClassType<HttpError<408>>;
|
|
51
|
+
export declare class HttpTimeoutError extends HttpTimeoutError_base {
|
|
52
|
+
}
|
|
53
|
+
declare const HttpConflictError_base: ClassType<HttpError<409>>;
|
|
54
|
+
export declare class HttpConflictError extends HttpConflictError_base {
|
|
55
|
+
}
|
|
56
|
+
declare const HttpGoneError_base: ClassType<HttpError<410>>;
|
|
57
|
+
export declare class HttpGoneError extends HttpGoneError_base {
|
|
58
|
+
}
|
|
59
|
+
declare const HttpTooManyRequestsError_base: ClassType<HttpError<429>>;
|
|
60
|
+
export declare class HttpTooManyRequestsError extends HttpTooManyRequestsError_base {
|
|
61
|
+
}
|
|
62
|
+
declare const HttpInternalServerError_base: ClassType<HttpError<500>>;
|
|
63
|
+
export declare class HttpInternalServerError extends HttpInternalServerError_base {
|
|
64
|
+
}
|
|
65
|
+
declare const HttpNotImplementedError_base: ClassType<HttpError<501>>;
|
|
66
|
+
export declare class HttpNotImplementedError extends HttpNotImplementedError_base {
|
|
67
|
+
}
|
|
40
68
|
export declare class HttpWorkflowEvent {
|
|
41
69
|
injectorContext: InjectorContext;
|
|
42
70
|
request: HttpRequest;
|
|
43
71
|
response: HttpResponse;
|
|
44
|
-
|
|
72
|
+
propagationStopped: boolean;
|
|
45
73
|
stopPropagation(): void;
|
|
46
|
-
|
|
74
|
+
isPropagationStopped(): boolean;
|
|
47
75
|
nextState?: any;
|
|
48
76
|
nextStateEvent?: any;
|
|
49
77
|
clearNext(): void;
|
|
@@ -173,11 +201,19 @@ export declare class BaseResponse {
|
|
|
173
201
|
autoSerializing: boolean;
|
|
174
202
|
constructor(_statusCode?: number | undefined, _headers?: OutgoingHttpHeaders);
|
|
175
203
|
status(code: number): this;
|
|
204
|
+
/**
|
|
205
|
+
* Per default a JSONResponse is serialized using the return type specified at the route.
|
|
206
|
+
* This disables that behaviour so that JSON.stringify is run on the result directly.
|
|
207
|
+
*/
|
|
176
208
|
disableAutoSerializing(): this;
|
|
177
209
|
header(name: string, value: string | number): this;
|
|
178
210
|
headers(headers: OutgoingHttpHeaders): this;
|
|
179
211
|
contentType(type: string): this;
|
|
180
212
|
}
|
|
213
|
+
export declare class Response extends BaseResponse {
|
|
214
|
+
content: string | Uint8Array;
|
|
215
|
+
constructor(content: string | Uint8Array, contentType: string, statusCode?: number);
|
|
216
|
+
}
|
|
181
217
|
export declare class HtmlResponse extends BaseResponse {
|
|
182
218
|
html: string;
|
|
183
219
|
constructor(html: string, statusCode?: number);
|
|
@@ -186,35 +222,37 @@ export declare class JSONResponse extends BaseResponse {
|
|
|
186
222
|
json: any;
|
|
187
223
|
constructor(json: any, statusCode?: number);
|
|
188
224
|
}
|
|
189
|
-
export declare type SupportedHttpResult = undefined | null | number | string | JSONResponse | HtmlResponse | HttpResponse | ServerResponse | Redirect | Uint8Array | Error;
|
|
225
|
+
export declare type SupportedHttpResult = undefined | null | number | string | Response | JSONResponse | HtmlResponse | HttpResponse | ServerResponse | stream.Readable | Redirect | Uint8Array | Error;
|
|
190
226
|
export interface HttpResultFormatterContext {
|
|
191
227
|
request: HttpRequest;
|
|
192
228
|
response: HttpResponse;
|
|
193
229
|
route?: RouteConfig;
|
|
194
230
|
}
|
|
195
231
|
export declare class HttpResultFormatter {
|
|
196
|
-
protected router:
|
|
232
|
+
protected router: HttpRouter;
|
|
197
233
|
protected jsonContentType: string;
|
|
198
234
|
protected htmlContentType: string;
|
|
199
|
-
constructor(router:
|
|
235
|
+
constructor(router: HttpRouter);
|
|
200
236
|
protected setContentTypeIfNotSetAlready(response: HttpResponse, contentType: string): void;
|
|
201
237
|
handleError(error: Error, context: HttpResultFormatterContext): void;
|
|
202
238
|
handleUndefined(result: undefined | null, context: HttpResultFormatterContext): void;
|
|
203
239
|
handleRedirect(result: Redirect, context: HttpResultFormatterContext): void;
|
|
204
240
|
handleUnknown(result: any, context: HttpResultFormatterContext): void;
|
|
205
241
|
handleHtmlResponse(result: HtmlResponse, context: HttpResultFormatterContext): void;
|
|
242
|
+
handleGenericResponse(result: Response, context: HttpResultFormatterContext): void;
|
|
206
243
|
handleJSONResponse(result: JSONResponse, context: HttpResultFormatterContext): void;
|
|
207
244
|
handleTypeEntity<T>(classType: ClassType<T>, instance: T, context: HttpResultFormatterContext, route?: RouteConfig): void;
|
|
245
|
+
handleStream(stream: stream.Readable, context: HttpResultFormatterContext): void;
|
|
208
246
|
handleBinary(result: Uint8Array, context: HttpResultFormatterContext): void;
|
|
209
247
|
handleResponse(context: HttpResultFormatterContext): void;
|
|
210
248
|
handle(result: SupportedHttpResult, context: HttpResultFormatterContext): void;
|
|
211
249
|
}
|
|
212
250
|
export declare class HttpListener {
|
|
213
|
-
protected router:
|
|
251
|
+
protected router: HttpRouter;
|
|
214
252
|
protected logger: LoggerInterface;
|
|
215
253
|
protected resultFormatter: HttpResultFormatter;
|
|
216
254
|
protected stopwatch?: Stopwatch | undefined;
|
|
217
|
-
constructor(router:
|
|
255
|
+
constructor(router: HttpRouter, logger: LoggerInterface, resultFormatter: HttpResultFormatter, stopwatch?: Stopwatch | undefined);
|
|
218
256
|
onRequest(event: typeof httpWorkflow.onRequest.event): void;
|
|
219
257
|
onRoute(event: typeof httpWorkflow.onRoute.event): Promise<void>;
|
|
220
258
|
onRouteForward(event: typeof httpWorkflow.onRoute.event): void;
|