@deepkit/http 1.0.1-alpha.71 → 1.0.1-alpha.74
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 +125 -39
- 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 +59 -27
- 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 +292 -96
- 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 +112 -39
- 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 +51 -19
- package/dist/esm/src/model.js.map +1 -1
- package/dist/esm/src/module.js +6 -4
- package/dist/esm/src/module.js.map +1 -1
- package/dist/esm/src/router.d.ts +84 -11
- package/dist/esm/src/router.js +291 -97
- 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 +83 -15
- package/src/kernel.ts +2 -2
- package/src/model.ts +35 -6
- package/src/module.ts +5 -3
- package/src/router.ts +298 -77
- 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
|
@@ -3,7 +3,7 @@ import { ClassDecoratorResult, DecoratorAndFetchSignature, DualDecorator, Extrac
|
|
|
3
3
|
import { RouteParameterResolver } from './router';
|
|
4
4
|
import { HttpMiddleware, HttpMiddlewareConfig, HttpMiddlewareFn } from './middleware';
|
|
5
5
|
declare type HttpActionMiddleware = (() => HttpMiddlewareConfig) | ClassType<HttpMiddleware> | HttpMiddlewareFn;
|
|
6
|
-
declare class HttpController {
|
|
6
|
+
export declare class HttpController {
|
|
7
7
|
baseUrl: string;
|
|
8
8
|
actions: Set<HttpAction>;
|
|
9
9
|
groups: string[];
|
|
@@ -48,7 +48,7 @@ export declare class HttpAction {
|
|
|
48
48
|
type?: Type;
|
|
49
49
|
}[];
|
|
50
50
|
}
|
|
51
|
-
export declare class
|
|
51
|
+
export declare class HttpControllerDecorator {
|
|
52
52
|
t: HttpController;
|
|
53
53
|
controller(baseUrl?: string): void;
|
|
54
54
|
group(...group: string[]): void;
|
|
@@ -101,7 +101,7 @@ export declare class HttpDecorator {
|
|
|
101
101
|
resolveParameterByName(name: string, resolver: ClassType<RouteParameterResolver>): void;
|
|
102
102
|
setAction(action: HttpAction): void;
|
|
103
103
|
}
|
|
104
|
-
export declare const httpClass: ClassDecoratorResult<typeof
|
|
104
|
+
export declare const httpClass: ClassDecoratorResult<typeof HttpControllerDecorator>;
|
|
105
105
|
export declare class HttpActionDecorator {
|
|
106
106
|
t: HttpAction;
|
|
107
107
|
onDecorator(target: ClassType, property: string | undefined, parameterIndexOrDescriptor?: any): void;
|
|
@@ -164,17 +164,17 @@ export declare class HttpActionDecorator {
|
|
|
164
164
|
*
|
|
165
165
|
* ```typescript
|
|
166
166
|
*
|
|
167
|
-
*
|
|
167
|
+
* http.GET().response<boolean>(200, 'All ok')
|
|
168
168
|
*
|
|
169
169
|
* interface User {
|
|
170
170
|
* username: string;
|
|
171
171
|
* }
|
|
172
|
-
*
|
|
172
|
+
* http.GET().response<User>(200, 'User object')
|
|
173
173
|
*
|
|
174
174
|
* interface HttpErrorMessage {
|
|
175
175
|
* error: string;
|
|
176
176
|
* }
|
|
177
|
-
*
|
|
177
|
+
* http.GET().response<HttpErrorMessage>(500, 'Error')
|
|
178
178
|
* ```
|
|
179
179
|
*/
|
|
180
180
|
response<T>(statusCode: number, description?: string, type?: ReceiveType<T>): void;
|
|
@@ -234,5 +234,7 @@ declare type HttpMerge<U> = {
|
|
|
234
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
235
|
};
|
|
236
236
|
declare type MergedHttp<T extends any[]> = HttpMerge<Omit<UnionToIntersection<T[number]>, '_fetch' | 't'>>;
|
|
237
|
+
export declare type HttpDecorator = PropertyDecoratorFn & HttpActionFluidDecorator<HttpActionDecorator, PropertyDecoratorFn>;
|
|
237
238
|
export declare const http: MergedHttp<[typeof httpClass, typeof httpAction]>;
|
|
238
239
|
export {};
|
|
240
|
+
export declare type __ΩHttpDecorator = any[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.http = exports.httpAction = exports.HttpActionDecorator = exports.httpClass = exports.
|
|
3
|
+
exports.http = exports.__ΩHttpDecorator = exports.httpAction = exports.HttpActionDecorator = exports.httpClass = exports.HttpControllerDecorator = exports.HttpAction = exports.HttpActionParameter = exports.HttpController = void 0;
|
|
4
4
|
const { __ΩClassType } = require('@deepkit/core');
|
|
5
5
|
const { __ΩSerializationOptions } = require('@deepkit/type');
|
|
6
6
|
const { __ΩRouteParameterResolver } = require('./router');
|
|
@@ -13,6 +13,10 @@ const { __ΩPropertyDecoratorFn } = require('@deepkit/type');
|
|
|
13
13
|
const { __ΩDecoratorAndFetchSignature } = require('@deepkit/type');
|
|
14
14
|
const { __ΩDualDecorator } = require('@deepkit/type');
|
|
15
15
|
const { __ΩUnionToIntersection } = require('@deepkit/type');
|
|
16
|
+
function __assignType(fn, args) {
|
|
17
|
+
fn.__type = args;
|
|
18
|
+
return fn;
|
|
19
|
+
}
|
|
16
20
|
const __ΩPick = ['T', 'K', 'l+e#!e"!fRb!b"Pde""N#!'];
|
|
17
21
|
const __ΩExclude = ['T', 'U', 'l6!Re$!RPe#!e$"qk#%QRb!b"Pde"!p)'];
|
|
18
22
|
const __ΩOmit = ['T', 'K', () => __ΩPick, () => __ΩExclude, 'b!b"e!!e!!ge!"o$#o##'];
|
|
@@ -68,6 +72,7 @@ class HttpController {
|
|
|
68
72
|
throw new Error(`No action with methodName ${methodName} found`);
|
|
69
73
|
}
|
|
70
74
|
}
|
|
75
|
+
exports.HttpController = HttpController;
|
|
71
76
|
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'];
|
|
72
77
|
class HttpActionParameter {
|
|
73
78
|
constructor() {
|
|
@@ -98,7 +103,7 @@ class HttpAction {
|
|
|
98
103
|
}
|
|
99
104
|
exports.HttpAction = HttpAction;
|
|
100
105
|
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'];
|
|
101
|
-
class
|
|
106
|
+
class HttpControllerDecorator {
|
|
102
107
|
constructor() {
|
|
103
108
|
this.t = new HttpController;
|
|
104
109
|
}
|
|
@@ -109,7 +114,7 @@ class HttpDecorator {
|
|
|
109
114
|
this.t.groups.push(...group);
|
|
110
115
|
}
|
|
111
116
|
middleware(...middlewares) {
|
|
112
|
-
this.t.middlewares.push(...middlewares.map(
|
|
117
|
+
this.t.middlewares.push(...middlewares.map(__assignType(v => isMiddlewareClassTypeOrFn(v) ? middleware_1.httpMiddleware.for(v) : v, ['v', '', 'P"2!"/"'])));
|
|
113
118
|
}
|
|
114
119
|
/**
|
|
115
120
|
* Adds a parameter resolver for parameters based on the class type. Use .resolveParameterByName() for name-based resolving.
|
|
@@ -165,9 +170,9 @@ class HttpDecorator {
|
|
|
165
170
|
this.t.addAction(action);
|
|
166
171
|
}
|
|
167
172
|
}
|
|
168
|
-
exports.
|
|
169
|
-
|
|
170
|
-
exports.httpClass = (0, type_1.createClassDecoratorContext)(
|
|
173
|
+
exports.HttpControllerDecorator = HttpControllerDecorator;
|
|
174
|
+
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'];
|
|
175
|
+
exports.httpClass = (0, type_1.createClassDecoratorContext)(HttpControllerDecorator);
|
|
171
176
|
class HttpActionDecorator {
|
|
172
177
|
constructor() {
|
|
173
178
|
this.t = new HttpAction;
|
|
@@ -175,6 +180,8 @@ class HttpActionDecorator {
|
|
|
175
180
|
onDecorator(target, property, parameterIndexOrDescriptor) {
|
|
176
181
|
if (!property)
|
|
177
182
|
return;
|
|
183
|
+
if (target === Object)
|
|
184
|
+
return;
|
|
178
185
|
this.t.methodName = property;
|
|
179
186
|
exports.httpClass.setAction(this.t)(target);
|
|
180
187
|
}
|
|
@@ -191,7 +198,7 @@ class HttpActionDecorator {
|
|
|
191
198
|
this.t.serializer = serializer;
|
|
192
199
|
}
|
|
193
200
|
middleware(...middlewares) {
|
|
194
|
-
this.t.middlewares.push(...middlewares.map(
|
|
201
|
+
this.t.middlewares.push(...middlewares.map(__assignType(v => isMiddlewareClassTypeOrFn(v) ? middleware_1.httpMiddleware.for(v) : v, ['v', '', 'P"2!"/"'])));
|
|
195
202
|
}
|
|
196
203
|
/**
|
|
197
204
|
* Allows to change the HttpAction object and composite multiple properties into one function.
|
|
@@ -291,20 +298,48 @@ class HttpActionDecorator {
|
|
|
291
298
|
*
|
|
292
299
|
* ```typescript
|
|
293
300
|
*
|
|
294
|
-
*
|
|
301
|
+
* http.GET().response<boolean>(200, 'All ok')
|
|
295
302
|
*
|
|
296
303
|
* interface User {
|
|
297
304
|
* username: string;
|
|
298
305
|
* }
|
|
299
|
-
*
|
|
306
|
+
* http.GET().response<User>(200, 'User object')
|
|
300
307
|
*
|
|
301
308
|
* interface HttpErrorMessage {
|
|
302
309
|
* error: string;
|
|
303
310
|
* }
|
|
304
|
-
*
|
|
311
|
+
* http.GET().response<HttpErrorMessage>(500, 'Error')
|
|
305
312
|
* ```
|
|
306
313
|
*/
|
|
307
|
-
response(statusCode, description
|
|
314
|
+
response(statusCode, description, type) {
|
|
315
|
+
var _a;
|
|
316
|
+
if (description === void 0) { description = ''; }
|
|
317
|
+
if (type === void 0) { type = (_a = this.
|
|
318
|
+
/**
|
|
319
|
+
* Adds additional information about what HTTP status codes are available in this route.
|
|
320
|
+
* You can add additionally a description and a response body type.
|
|
321
|
+
*
|
|
322
|
+
* The type is used for serialization for responses with the given statusCode.
|
|
323
|
+
*
|
|
324
|
+
* This information is available in Deepkit API console.
|
|
325
|
+
*
|
|
326
|
+
* ```typescript
|
|
327
|
+
*
|
|
328
|
+
* http.GET().response<boolean>(200, 'All ok')
|
|
329
|
+
*
|
|
330
|
+
* interface User {
|
|
331
|
+
* username: string;
|
|
332
|
+
* }
|
|
333
|
+
* http.GET().response<User>(200, 'User object')
|
|
334
|
+
*
|
|
335
|
+
* interface HttpErrorMessage {
|
|
336
|
+
* error: string;
|
|
337
|
+
* }
|
|
338
|
+
* http.GET().response<HttpErrorMessage>(500, 'Error')
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
response.Ω) === null || _a === void 0 ? void 0 : _a[0]; }
|
|
342
|
+
this.response.Ω = undefined;
|
|
308
343
|
this.t.responses.push({ statusCode, description, type: type ? (0, type_1.resolveReceiveType)(type) : undefined });
|
|
309
344
|
}
|
|
310
345
|
/**
|
|
@@ -358,10 +393,12 @@ class HttpActionDecorator {
|
|
|
358
393
|
}
|
|
359
394
|
exports.HttpActionDecorator = HttpActionDecorator;
|
|
360
395
|
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
|
-
const __ΩHttpActionFluidDecorator = ['T', 'D', "response", 'statusCode', 'description', () => __ΩReceiveType, 'type',
|
|
396
|
+
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!'];
|
|
362
397
|
const __ΩHttpActionPropertyDecoratorResult = [() => __ΩHttpActionFluidDecorator, () => __ΩExtractClass, () => HttpActionDecorator, () => __ΩPropertyDecoratorFn, () => __ΩDecoratorAndFetchSignature, () => HttpActionDecorator, () => __ΩPropertyDecoratorFn, 'Pi#o""n$o!#i&n\'o%#K'];
|
|
363
398
|
exports.httpAction = (0, type_1.createPropertyDecoratorContext)(HttpActionDecorator);
|
|
364
399
|
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!'];
|
|
365
400
|
const __ΩMergedHttp = ['T', () => __ΩHttpMerge, () => __ΩOmit, () => __ΩUnionToIntersection, "_fetch", "t", 'b!e!!\'fo$"P.%.&Jo##o""'];
|
|
401
|
+
const __ΩHttpDecorator = [() => __ΩPropertyDecoratorFn, () => __ΩHttpActionFluidDecorator, () => HttpActionDecorator, () => __ΩPropertyDecoratorFn, 'Pn!P7#n$o"#K'];
|
|
402
|
+
exports.__ΩHttpDecorator = __ΩHttpDecorator;
|
|
366
403
|
exports.http = (0, type_1.mergeDecorator)(exports.httpClass, exports.httpAction);
|
|
367
404
|
//# sourceMappingURL=decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../src/decorator.ts"],"names":[],"mappings":";;;iCAU4C,eAAe;4CAkBpD,eAAe;8CACiB,UAAU;mCAD1C,eAAe;sCAEiE,cAAc;wCAAd,cAAc;0CAF9F,eAAe;oCAAf,eAAe;2CAAf,eAAe;kDAAf,eAAe;qCAAf,eAAe;2CAAf,eAAe
|
|
1
|
+
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../src/decorator.ts"],"names":[],"mappings":";;;iCAU4C,eAAe;4CAkBpD,eAAe;8CACiB,UAAU;mCAD1C,eAAe;sCAEiE,cAAc;wCAAd,cAAc;0CAF9F,eAAe;oCAAf,eAAe;2CAAf,eAAe;kDAAf,eAAe;qCAAf,eAAe;2CAAf,eAAe;;;;;;;;AA5BtB;;;;;;;;GAQG;AAEH,wCAA4D;AAC5D,wCAiBuB;AAEvB,6CAAsG;;AAItG,SAAS,yBAAyB,CAAC,CAAuB;IACtD,OAAO,IAAA,cAAO,EAAC,CAAC,CAAC,IAAI,CAAC,IAAA,yBAAkB,EAAC,2BAAc,EAAE,CAAC,CAAC,CAAC;AAChE,CAAC;;AAED,MAAa,cAAc;IAA3B;QACI,YAAO,GAAW,EAAE,CAAC;QACrB,YAAO,GAAG,IAAI,GAAG,EAAc,CAAC;QAChC,W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AI,CAAC;IACjC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;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,IAAA,yBAAkB,EAAC,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;;AArML,kDAsMC;;;;AAUY,QAAA,UAAU,GAAsC,IAAA,qCAA8B,EAAC,mBAAmB,CAAC,CAAC;;;;;AAQpG,QAAA,IAAI,GAAsD,IAAA,qBAAc,EAAC,iBAAS,EAAE,kBAAU,CAA6D,CAAC"}
|
package/dist/cjs/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/cjs/src/filter.js
CHANGED
|
@@ -58,9 +58,9 @@ class HttpRouterFilterResolver {
|
|
|
58
58
|
resolve(filter) {
|
|
59
59
|
const result = [];
|
|
60
60
|
outer: for (const routeConfig of this.router.getRoutes()) {
|
|
61
|
-
if (filter.controllers.length && !filter.controllers.includes(routeConfig.action.controller))
|
|
61
|
+
if (filter.controllers.length && routeConfig.action.type === 'controller' && !filter.controllers.includes(routeConfig.action.controller))
|
|
62
62
|
continue;
|
|
63
|
-
if (filter.excludeControllers.length && filter.excludeControllers.includes(routeConfig.action.controller))
|
|
63
|
+
if (filter.excludeControllers.length && routeConfig.action.type === 'controller' && filter.excludeControllers.includes(routeConfig.action.controller))
|
|
64
64
|
continue;
|
|
65
65
|
if (filter.modules.length) {
|
|
66
66
|
if (!routeConfig.module)
|
|
@@ -150,7 +150,7 @@ class HttpRouterFilterResolver {
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
exports.HttpRouterFilterResolver = HttpRouterFilterResolver;
|
|
153
|
-
HttpRouterFilterResolver.__type = [() => router_1.
|
|
153
|
+
HttpRouterFilterResolver.__type = [() => router_1.HttpRouter, 'router', 'constructor', () => HttpRouteFilterModel, 'filter', () => router_1.RouteConfig, 'resolve', 'PP7!2"<"0#PP7$2%P7&F0\'5'];
|
|
154
154
|
/**
|
|
155
155
|
* A class to describe a filter for routes.
|
|
156
156
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../src/filter.ts"],"names":[],"mappings":";;;iCAA0B,eAAe;AACzC,sCAAyC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AAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,GAAG,OAAyB;QACnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,cAAc,CAAC,GAAG,OAAyB;QACvC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,gBAAgB,CAAC,GAAG,aAA0C;QAC1D,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,oBAAoB,CAAC,GAAG,aAA0C;QAC9D,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;IAChB,CAAC;;AAxDL,0CAyDC"}
|
package/dist/cjs/src/http.d.ts
CHANGED
|
@@ -4,10 +4,11 @@ import { OutgoingHttpHeaders, ServerResponse } from 'http';
|
|
|
4
4
|
import { HttpRequest, 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;
|