@deepkit/http 1.0.1-alpha.16 → 1.0.1-alpha.160
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/CHANGELOG.md +236 -0
- package/dist/cjs/index.d.ts +14 -10
- package/dist/cjs/index.js +19 -11
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/src/controllers.d.ts +10 -3
- package/dist/cjs/src/controllers.js +7 -3
- package/dist/cjs/src/controllers.js.map +1 -1
- package/dist/cjs/src/decorator.d.ts +144 -70
- package/dist/cjs/src/decorator.js +277 -102
- package/dist/cjs/src/decorator.js.map +1 -1
- package/dist/cjs/src/filter.d.ts +49 -0
- package/dist/cjs/src/filter.js +215 -0
- package/dist/cjs/src/filter.js.map +1 -0
- package/dist/cjs/src/http-app.d.ts +8 -0
- package/dist/cjs/src/http-app.js +16 -0
- package/dist/cjs/src/http-app.js.map +1 -0
- package/dist/cjs/src/http.d.ts +131 -32
- package/dist/cjs/src/http.js +523 -122
- package/dist/cjs/src/http.js.map +1 -1
- package/dist/cjs/src/kernel.d.ts +50 -9
- package/dist/cjs/src/kernel.js +109 -98
- package/dist/cjs/src/kernel.js.map +1 -1
- package/dist/cjs/src/logger.d.ts +3 -3
- package/dist/cjs/src/logger.js +9 -12
- package/dist/cjs/src/logger.js.map +1 -1
- package/dist/cjs/src/middleware.d.ts +61 -0
- package/dist/cjs/src/middleware.js +95 -0
- package/dist/cjs/src/middleware.js.map +1 -0
- package/dist/cjs/src/model.d.ts +270 -4
- package/dist/cjs/src/model.js +401 -3
- package/dist/cjs/src/model.js.map +1 -1
- package/dist/cjs/src/module.config.d.ts +149 -4
- package/dist/cjs/src/module.config.js +11 -6
- package/dist/cjs/src/module.config.js.map +1 -1
- package/dist/cjs/src/module.d.ts +14 -32
- package/dist/cjs/src/module.js +122 -7
- package/dist/cjs/src/module.js.map +1 -1
- package/dist/cjs/src/request-parser.d.ts +37 -0
- package/dist/cjs/src/request-parser.js +382 -0
- package/dist/cjs/src/request-parser.js.map +1 -0
- package/dist/cjs/src/router.d.ts +174 -75
- package/dist/cjs/src/router.js +469 -288
- package/dist/cjs/src/router.js.map +1 -1
- package/dist/cjs/src/static-serving.d.ts +32 -4
- package/dist/cjs/src/static-serving.js +115 -71
- package/dist/cjs/src/static-serving.js.map +1 -1
- package/dist/cjs/src/utils.js +2 -2
- package/dist/cjs/src/utils.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -2916
- package/dist/esm/index.d.ts +14 -10
- package/dist/esm/index.js +14 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/src/controllers.d.ts +10 -3
- package/dist/esm/src/controllers.js +7 -3
- package/dist/esm/src/controllers.js.map +1 -1
- package/dist/esm/src/decorator.d.ts +144 -70
- package/dist/esm/src/decorator.js +272 -99
- package/dist/esm/src/decorator.js.map +1 -1
- package/dist/esm/src/filter.d.ts +49 -0
- package/dist/esm/src/filter.js +209 -0
- package/dist/esm/src/filter.js.map +1 -0
- package/dist/esm/src/http-app.d.ts +8 -0
- package/dist/esm/src/http-app.js +12 -0
- package/dist/esm/src/http-app.js.map +1 -0
- package/dist/esm/src/http.d.ts +131 -32
- package/dist/esm/src/http.js +504 -121
- package/dist/esm/src/http.js.map +1 -1
- package/dist/esm/src/kernel.d.ts +50 -9
- package/dist/esm/src/kernel.js +110 -100
- package/dist/esm/src/kernel.js.map +1 -1
- package/dist/esm/src/logger.d.ts +3 -3
- package/dist/esm/src/logger.js +7 -11
- package/dist/esm/src/logger.js.map +1 -1
- package/dist/esm/src/middleware.d.ts +61 -0
- package/dist/esm/src/middleware.js +90 -0
- package/dist/esm/src/middleware.js.map +1 -0
- package/dist/esm/src/model.d.ts +270 -4
- package/dist/esm/src/model.js +357 -1
- package/dist/esm/src/model.js.map +1 -1
- package/dist/esm/src/module.config.d.ts +149 -4
- package/dist/esm/src/module.config.js +9 -5
- package/dist/esm/src/module.config.js.map +1 -1
- package/dist/esm/src/module.d.ts +14 -32
- package/dist/esm/src/module.js +121 -7
- package/dist/esm/src/module.js.map +1 -1
- package/dist/esm/src/request-parser.d.ts +37 -0
- package/dist/esm/src/request-parser.js +372 -0
- package/dist/esm/src/request-parser.js.map +1 -0
- package/dist/esm/src/router.d.ts +174 -75
- package/dist/esm/src/router.js +463 -285
- package/dist/esm/src/router.js.map +1 -1
- package/dist/esm/src/static-serving.d.ts +32 -4
- package/dist/esm/src/static-serving.js +107 -65
- package/dist/esm/src/static-serving.js.map +1 -1
- package/dist/esm/src/utils.js +1 -0
- package/dist/esm/src/utils.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -2916
- package/index.ts +14 -10
- package/package.json +30 -19
- package/src/controllers.ts +4 -3
- package/src/decorator.ts +242 -104
- package/src/filter.ts +224 -0
- package/src/http-app.ts +11 -0
- package/src/http.ts +501 -100
- package/src/kernel.ts +128 -80
- package/src/logger.ts +4 -6
- package/src/middleware.ts +116 -0
- package/src/model.ts +516 -5
- package/src/module.config.ts +168 -5
- package/src/module.ts +120 -7
- package/src/request-parser.ts +430 -0
- package/src/router.ts +546 -317
- package/src/static-serving.ts +120 -50
- package/src/utils.ts +0 -2
- package/tsconfig.esm.json +7 -7
- package/tsconfig.json +18 -11
- package/tsconfig.spec.json +8 -0
- package/dist/cjs/tests/router.spec.d.ts +0 -1
- package/dist/cjs/tests/router.spec.js +0 -481
- package/dist/cjs/tests/router.spec.js.map +0 -1
- package/dist/esm/tests/router.spec.d.ts +0 -1
- package/dist/esm/tests/router.spec.js +0 -479
- package/dist/esm/tests/router.spec.js.map +0 -1
- package/tests/router.spec.ts +0 -347
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
const __ΩOmit = ['T', 'K', () => __ΩPick, () => __ΩExclude, 'Omit', 'b!b"e!!e!!ge!"o$#o##w%y'];
|
|
2
|
+
const __ΩPick = ['T', 'K', 'Pick', 'l+e#!e"!fRb!b"Pde""N#!w#y'];
|
|
3
|
+
const __ΩExclude = ['T', 'U', 'Exclude', 'l6!Re$!RPe#!e$"qk#%QRb!b"Pde"!p)w#y'];
|
|
4
|
+
/*@ts-ignore*/
|
|
5
|
+
import { __ΩClassType } from '@deepkit/core';
|
|
6
|
+
/*@ts-ignore*/
|
|
7
|
+
import { __ΩSerializationOptions } from '@deepkit/type';
|
|
8
|
+
/*@ts-ignore*/
|
|
9
|
+
import { __ΩRouteParameterResolver } from './router.js';
|
|
10
|
+
/*@ts-ignore*/
|
|
11
|
+
import { __ΩReceiveType } from '@deepkit/type';
|
|
12
|
+
/*@ts-ignore*/
|
|
13
|
+
import { __ΩHttpMiddleware } from './middleware.js';
|
|
14
|
+
/*@ts-ignore*/
|
|
15
|
+
import { __ΩHttpMiddlewareFn } from './middleware.js';
|
|
16
|
+
/*@ts-ignore*/
|
|
17
|
+
import { __ΩExtractApiDataType } from '@deepkit/type';
|
|
18
|
+
/*@ts-ignore*/
|
|
19
|
+
import { __ΩExtractClass } from '@deepkit/type';
|
|
20
|
+
/*@ts-ignore*/
|
|
21
|
+
import { __ΩPropertyDecoratorFn } from '@deepkit/type';
|
|
22
|
+
/*@ts-ignore*/
|
|
23
|
+
import { __ΩDecoratorAndFetchSignature } from '@deepkit/type';
|
|
24
|
+
/*@ts-ignore*/
|
|
25
|
+
import { __ΩDualDecorator } from '@deepkit/type';
|
|
26
|
+
/*@ts-ignore*/
|
|
27
|
+
import { __ΩUnionToIntersection } from '@deepkit/type';
|
|
28
|
+
function __assignType(fn, args) {
|
|
29
|
+
fn.__type = args;
|
|
30
|
+
return fn;
|
|
31
|
+
}
|
|
1
32
|
/*
|
|
2
33
|
* Deepkit Framework
|
|
3
34
|
* Copyright (C) 2021 Deepkit UG, Marc J. Schmidt
|
|
@@ -7,29 +38,47 @@
|
|
|
7
38
|
*
|
|
8
39
|
* You should have received a copy of the MIT License along with this program.
|
|
9
40
|
*/
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
41
|
+
import { isClass, urlJoin } from '@deepkit/core';
|
|
42
|
+
import { createClassDecoratorContext, createPropertyDecoratorContext, isDecoratorContext, mergeDecorator, resolveReceiveType, Serializer } from '@deepkit/type';
|
|
43
|
+
import { httpMiddleware, HttpMiddlewareConfig } from './middleware.js';
|
|
44
|
+
const __ΩHttpActionMiddleware = [() => HttpMiddlewareConfig, '', () => __ΩClassType, () => __ΩHttpMiddleware, () => __ΩHttpMiddlewareFn, 'HttpActionMiddleware', 'PPP7!/"n$o#"n%Jw&y'];
|
|
45
|
+
function isMiddlewareClassTypeOrFn(v) {
|
|
46
|
+
return isClass(v) || !isDecoratorContext(httpMiddleware, v);
|
|
47
|
+
}
|
|
48
|
+
isMiddlewareClassTypeOrFn.__type = [() => __ΩHttpActionMiddleware, 'v', 'isMiddlewareClassTypeOrFn', 'Pn!2"!/#'];
|
|
49
|
+
export class HttpController {
|
|
13
50
|
constructor() {
|
|
14
51
|
this.baseUrl = '';
|
|
15
|
-
this.actions = new Set();
|
|
52
|
+
this.actions = (Set.Ω = [[() => HttpAction, 'P7!']], new Set());
|
|
16
53
|
this.groups = [];
|
|
54
|
+
this.middlewares = [];
|
|
55
|
+
this.resolverForToken = new Map();
|
|
56
|
+
this.resolverForParameterName = new Map();
|
|
57
|
+
this.actionsProcessed = (Set.Ω = [[() => HttpAction, 'P7!']], new Set());
|
|
17
58
|
}
|
|
18
59
|
getUrl(action) {
|
|
19
|
-
return
|
|
60
|
+
return urlJoin('/', this.baseUrl, action.path);
|
|
20
61
|
}
|
|
21
62
|
addAction(action) {
|
|
22
63
|
this.actions.add(action);
|
|
23
64
|
}
|
|
24
65
|
getActions() {
|
|
25
|
-
for (const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
66
|
+
for (const action of this.actions) {
|
|
67
|
+
if (!this.actionsProcessed.has(action)) {
|
|
68
|
+
action.groups = [
|
|
69
|
+
...this.groups,
|
|
70
|
+
...action.groups.filter(__assignType((g) => !this.groups.includes(g), ['g', '', 'P"2!"/"'])),
|
|
71
|
+
];
|
|
72
|
+
this.actionsProcessed.add(action);
|
|
29
73
|
}
|
|
30
74
|
}
|
|
31
75
|
return this.actions;
|
|
32
76
|
}
|
|
77
|
+
removeAction(methodName) {
|
|
78
|
+
const action = this.getAction(methodName);
|
|
79
|
+
this.actions.delete(action);
|
|
80
|
+
this.actionsProcessed.delete(action);
|
|
81
|
+
}
|
|
33
82
|
getAction(methodName) {
|
|
34
83
|
for (const a of this.getActions()) {
|
|
35
84
|
if (a.methodName === methodName)
|
|
@@ -38,65 +87,145 @@ class HttpController {
|
|
|
38
87
|
throw new Error(`No action with methodName ${methodName} found`);
|
|
39
88
|
}
|
|
40
89
|
}
|
|
90
|
+
HttpController.__type = ['baseUrl', function () { return ''; }, 'actions', function () { return (Set.Ω = [[() => HttpAction, 'P7!']], new Set()); }, 'groups', function () { return []; }, () => HttpMiddlewareConfig, '', 'middlewares', function () { return []; }, () => __ΩClassType, 'resolverForToken', function () { return new Map(); }, () => __ΩClassType, 'resolverForParameterName', function () { return new Map(); }, 'actionsProcessed', function () { return (Set.Ω = [[() => HttpAction, 'P7!']], new Set()); }, () => HttpAction, 'action', 'getUrl', () => HttpAction, 'addAction', () => HttpAction, 'getActions', 'methodName', 'removeAction', () => HttpAction, 'getAction', 'HttpController', '&3!>"!3#>$&F3%>&PP7\'/(F3)>*"n+E3,>-&n.E3/>0!31;>2PP7324&05PP7624"07PP78D09P&2:$0;P&2:P7<0=5w>'];
|
|
41
91
|
export class HttpActionParameter {
|
|
42
92
|
constructor() {
|
|
43
93
|
this.name = '';
|
|
44
94
|
this.optional = false;
|
|
45
95
|
}
|
|
46
96
|
}
|
|
97
|
+
HttpActionParameter.__type = ['name', function () { return ''; }, "body", "query", "queries", 'type', 'typePath', 'optional', function () { return false; }, 'HttpActionParameter', '&3!>"P.#.$.%J3&8&3\'8)3(>)5w*'];
|
|
47
98
|
export class HttpAction {
|
|
48
99
|
constructor() {
|
|
49
100
|
this.name = '';
|
|
50
101
|
this.description = '';
|
|
51
102
|
this.category = '';
|
|
52
103
|
this.path = '';
|
|
53
|
-
this.
|
|
104
|
+
this.httpMethods = [];
|
|
54
105
|
this.methodName = '';
|
|
55
106
|
this.groups = [];
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
*/
|
|
60
|
-
this.parameters = {};
|
|
107
|
+
this.middlewares = [];
|
|
108
|
+
this.resolverForToken = new Map();
|
|
109
|
+
this.resolverForParameterName = new Map();
|
|
61
110
|
/**
|
|
62
111
|
* An arbitrary data container the user can use to store app specific settings/values.
|
|
63
112
|
*/
|
|
64
|
-
this.data = new Map();
|
|
65
|
-
this.
|
|
113
|
+
this.data = (Map.Ω = [['"'], ['"']], new Map());
|
|
114
|
+
this.responses = [];
|
|
66
115
|
}
|
|
67
116
|
}
|
|
68
|
-
|
|
117
|
+
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(); }, 'data', function () { return (Map.Ω = [['"'], ['"']], new Map()); }, 'statusCode', 'Type', 'type', 'responses', function () { return []; }, 'HttpAction', '&3!>"&3#>$&3%>&&3\'>(&F3)>*&3+>,&F3->.P7/308PP71/2F33>4n5368"n7E38>9&n:E3;><!3=>>P\'4?&4#"w@4A8MF3B>C5wD'];
|
|
118
|
+
export class HttpControllerDecorator {
|
|
69
119
|
constructor() {
|
|
70
120
|
this.t = new HttpController;
|
|
71
121
|
}
|
|
72
122
|
controller(baseUrl = '') {
|
|
73
123
|
this.t.baseUrl = baseUrl;
|
|
74
124
|
}
|
|
75
|
-
|
|
125
|
+
group(...group) {
|
|
76
126
|
this.t.groups.push(...group);
|
|
77
127
|
}
|
|
128
|
+
middleware(...middlewares) {
|
|
129
|
+
this.t.middlewares.push(...middlewares.map(__assignType(v => isMiddlewareClassTypeOrFn(v) ? httpMiddleware.for(v) : v, ['v', '', 'P"2!"/"'])));
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Adds a parameter resolver for parameters based on the class type. Use .resolveParameterByName() for name-based resolving.
|
|
133
|
+
*
|
|
134
|
+
* ```typescript
|
|
135
|
+
*
|
|
136
|
+
* class UserResolver {
|
|
137
|
+
* resolve(context: RouteParameterResolverContext): any | Promise<any> {
|
|
138
|
+
* return new User();
|
|
139
|
+
* }
|
|
140
|
+
* }
|
|
141
|
+
*
|
|
142
|
+
* @http.resolveParameter(User, UserResolver)
|
|
143
|
+
* class MyController {
|
|
144
|
+
*
|
|
145
|
+
* @http.GET()
|
|
146
|
+
* myAction(user: User) {
|
|
147
|
+
* }
|
|
148
|
+
* }
|
|
149
|
+
*
|
|
150
|
+
* new App({providers: [UserResolver]}).run();
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
resolveParameter(classType, resolver) {
|
|
154
|
+
this.t.resolverForToken.set(classType, resolver);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Adds a parameter resolver for parameters based on its name. Use .resolveParameter() for class-based resolving.
|
|
158
|
+
*
|
|
159
|
+
* ```typescript
|
|
160
|
+
*
|
|
161
|
+
* class UserResolver {
|
|
162
|
+
* resolve(context: RouteParameterResolverContext): any | Promise<any> {
|
|
163
|
+
* return new User();
|
|
164
|
+
* }
|
|
165
|
+
* }
|
|
166
|
+
*
|
|
167
|
+
* @http.resolveParameterByName('user', UserResolver)
|
|
168
|
+
* class MyController {
|
|
169
|
+
*
|
|
170
|
+
* @http.GET()
|
|
171
|
+
* myAction(user: User) {
|
|
172
|
+
* }
|
|
173
|
+
* }
|
|
174
|
+
*
|
|
175
|
+
* new App({providers: [UserResolver]}).run();
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
resolveParameterByName(name, resolver) {
|
|
179
|
+
this.t.resolverForParameterName.set(name, resolver);
|
|
180
|
+
}
|
|
78
181
|
setAction(action) {
|
|
79
182
|
this.t.addAction(action);
|
|
80
183
|
}
|
|
81
184
|
}
|
|
82
|
-
|
|
185
|
+
HttpControllerDecorator.__type = ['t', function () { return new HttpController; }, 'baseUrl', () => "", 'controller', 'group', () => __ΩHttpActionMiddleware, 'middlewares', 'middleware', () => __ΩClassType, 'classType', () => __ΩClassType, () => __ΩRouteParameterResolver, 'resolver', 'resolveParameter', 'name', () => __ΩClassType, () => __ΩRouteParameterResolver, 'resolveParameterByName', () => HttpAction, 'action', 'setAction', 'HttpControllerDecorator', '!3!>"P&2#>$"0%P&@2&"0&Pn\'@2("0)PPn*&"J2+n-o,"2."0/P&20n2o1"2."03PP7425"065w7'];
|
|
186
|
+
export const httpClass = createClassDecoratorContext(HttpControllerDecorator);
|
|
187
|
+
export function getActions(target) {
|
|
188
|
+
const parent = Object.getPrototypeOf(target);
|
|
189
|
+
const results = parent ? getActions(parent) : [];
|
|
190
|
+
const config = httpClass._fetch(target);
|
|
191
|
+
if (config) {
|
|
192
|
+
for (const action of config.getActions()) {
|
|
193
|
+
const existing = results.findIndex(__assignType(v => v.methodName === action.methodName, ['v', '', 'P"2!"/"']));
|
|
194
|
+
if (existing !== -1)
|
|
195
|
+
results.splice(existing, 1);
|
|
196
|
+
results.push(action);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return results;
|
|
200
|
+
}
|
|
201
|
+
getActions.__type = [() => __ΩClassType, 'target', () => HttpAction, 'getActions', 'Pn!2"P7#F/$'];
|
|
83
202
|
export class HttpActionDecorator {
|
|
84
203
|
constructor() {
|
|
85
204
|
this.t = new HttpAction;
|
|
86
205
|
}
|
|
87
|
-
onDecorator(target, property) {
|
|
206
|
+
onDecorator(target, property, parameterIndexOrDescriptor) {
|
|
207
|
+
if (!property)
|
|
208
|
+
return;
|
|
209
|
+
if (target === Object)
|
|
210
|
+
return;
|
|
88
211
|
this.t.methodName = property;
|
|
89
212
|
httpClass.setAction(this.t)(target);
|
|
90
213
|
}
|
|
91
214
|
name(name) {
|
|
92
215
|
this.t.name = name;
|
|
93
216
|
}
|
|
94
|
-
setParameter(name, parameter) {
|
|
95
|
-
this.t.parameters[name] = parameter;
|
|
96
|
-
}
|
|
97
217
|
description(description) {
|
|
98
218
|
this.t.description = description;
|
|
99
219
|
}
|
|
220
|
+
serialization(options) {
|
|
221
|
+
this.t.serializationOptions = options;
|
|
222
|
+
}
|
|
223
|
+
serializer(serializer) {
|
|
224
|
+
this.t.serializer = serializer;
|
|
225
|
+
}
|
|
226
|
+
middleware(...middlewares) {
|
|
227
|
+
this.t.middlewares.push(...middlewares.map(__assignType(v => isMiddlewareClassTypeOrFn(v) ? httpMiddleware.for(v) : v, ['v', '', 'P"2!"/"'])));
|
|
228
|
+
}
|
|
100
229
|
/**
|
|
101
230
|
* Allows to change the HttpAction object and composite multiple properties into one function.
|
|
102
231
|
*
|
|
@@ -130,7 +259,7 @@ export class HttpActionDecorator {
|
|
|
130
259
|
* assets() {}
|
|
131
260
|
* }
|
|
132
261
|
* ```
|
|
133
|
-
|
|
262
|
+
*/
|
|
134
263
|
data(name, value) {
|
|
135
264
|
this.t.data.set(name, value);
|
|
136
265
|
}
|
|
@@ -141,113 +270,157 @@ export class HttpActionDecorator {
|
|
|
141
270
|
this.t.groups.push(...group);
|
|
142
271
|
}
|
|
143
272
|
GET(path = '') {
|
|
144
|
-
this.t.
|
|
145
|
-
|
|
273
|
+
this.t.httpMethods.push('GET');
|
|
274
|
+
if (path)
|
|
275
|
+
this.t.path = path;
|
|
276
|
+
}
|
|
277
|
+
HEAD(path = '') {
|
|
278
|
+
this.t.httpMethods.push('HEAD');
|
|
279
|
+
if (path)
|
|
280
|
+
this.t.path = path;
|
|
146
281
|
}
|
|
147
282
|
POST(path = '') {
|
|
148
|
-
this.t.
|
|
149
|
-
|
|
283
|
+
this.t.httpMethods.push('POST');
|
|
284
|
+
if (path)
|
|
285
|
+
this.t.path = path;
|
|
150
286
|
}
|
|
151
287
|
PUT(path = '') {
|
|
152
|
-
this.t.
|
|
153
|
-
|
|
288
|
+
this.t.httpMethods.push('PUT');
|
|
289
|
+
if (path)
|
|
290
|
+
this.t.path = path;
|
|
154
291
|
}
|
|
155
292
|
DELETE(path = '') {
|
|
156
|
-
this.t.
|
|
157
|
-
|
|
293
|
+
this.t.httpMethods.push('DELETE');
|
|
294
|
+
if (path)
|
|
295
|
+
this.t.path = path;
|
|
158
296
|
}
|
|
159
|
-
|
|
160
|
-
this.t.
|
|
161
|
-
|
|
297
|
+
OPTIONS(path = '') {
|
|
298
|
+
this.t.httpMethods.push('OPTIONS');
|
|
299
|
+
if (path)
|
|
300
|
+
this.t.path = path;
|
|
162
301
|
}
|
|
163
|
-
|
|
164
|
-
this.t.
|
|
302
|
+
TRACE(path = '') {
|
|
303
|
+
this.t.httpMethods.push('TRACE');
|
|
304
|
+
if (path)
|
|
305
|
+
this.t.path = path;
|
|
165
306
|
}
|
|
166
|
-
|
|
167
|
-
this.t.
|
|
307
|
+
PATCH(path = '') {
|
|
308
|
+
this.t.httpMethods.push('PATCH');
|
|
309
|
+
if (path)
|
|
310
|
+
this.t.path = path;
|
|
168
311
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
onDecorator(target, propertyName, parameterIndex) {
|
|
175
|
-
if (!propertyName)
|
|
176
|
-
throw new Error('@http action parameter decorator can only be used on method arguments.');
|
|
177
|
-
if (parameterIndex === undefined)
|
|
178
|
-
throw new Error('@http action parameter decorator can only be used on method arguments.');
|
|
179
|
-
const schema = getClassSchema(target);
|
|
180
|
-
const property = schema.getMethodProperties(propertyName)[parameterIndex];
|
|
181
|
-
this.t.name = property.name;
|
|
182
|
-
if (this.t.typePath === undefined) {
|
|
183
|
-
this.t.typePath = property.name;
|
|
184
|
-
}
|
|
185
|
-
httpAction.setParameter(property.name, this.t)(target.prototype, propertyName);
|
|
312
|
+
ANY(path = '') {
|
|
313
|
+
this.t.httpMethods = [];
|
|
314
|
+
if (path)
|
|
315
|
+
this.t.path = path;
|
|
186
316
|
}
|
|
187
317
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
318
|
+
* Adds additional information about what HTTP status codes are available in this route.
|
|
319
|
+
* You can add additionally a description and a response body type.
|
|
320
|
+
*
|
|
321
|
+
* The type is used for serialization for responses with the given statusCode.
|
|
322
|
+
*
|
|
323
|
+
* This information is available in Deepkit API console.
|
|
324
|
+
*
|
|
325
|
+
* ```typescript
|
|
326
|
+
*
|
|
327
|
+
* http.GET().response<boolean>(200, 'All ok')
|
|
328
|
+
*
|
|
329
|
+
* interface User {
|
|
330
|
+
* username: string;
|
|
331
|
+
* }
|
|
332
|
+
* http.GET().response<User>(200, 'User object')
|
|
333
|
+
*
|
|
334
|
+
* interface HttpErrorMessage {
|
|
335
|
+
* error: string;
|
|
336
|
+
* }
|
|
337
|
+
* http.GET().response<HttpErrorMessage>(500, 'Error')
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
response(statusCode, description = '', type = this.
|
|
341
|
+
/**
|
|
342
|
+
* Adds additional information about what HTTP status codes are available in this route.
|
|
343
|
+
* You can add additionally a description and a response body type.
|
|
344
|
+
*
|
|
345
|
+
* The type is used for serialization for responses with the given statusCode.
|
|
346
|
+
*
|
|
347
|
+
* This information is available in Deepkit API console.
|
|
191
348
|
*
|
|
192
|
-
* @example
|
|
193
349
|
* ```typescript
|
|
194
|
-
*
|
|
195
|
-
*
|
|
350
|
+
*
|
|
351
|
+
* http.GET().response<boolean>(200, 'All ok')
|
|
352
|
+
*
|
|
353
|
+
* interface User {
|
|
354
|
+
* username: string;
|
|
355
|
+
* }
|
|
356
|
+
* http.GET().response<User>(200, 'User object')
|
|
357
|
+
*
|
|
358
|
+
* interface HttpErrorMessage {
|
|
359
|
+
* error: string;
|
|
360
|
+
* }
|
|
361
|
+
* http.GET().response<HttpErrorMessage>(500, 'Error')
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
364
|
+
response.Ω?.[0]) {
|
|
365
|
+
this.response.Ω = undefined;
|
|
366
|
+
this.t.responses.push({ statusCode, description, type: type ? resolveReceiveType(type) : undefined });
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Adds a parameter resolver for parameters based on the class type. Use .resolveParameterByName() for name-based resolving.
|
|
370
|
+
*
|
|
371
|
+
* ```typescript
|
|
372
|
+
*
|
|
373
|
+
* class UserResolver {
|
|
374
|
+
* resolve(context: RouteParameterResolverContext): any | Promise<any> {
|
|
375
|
+
* return new User();
|
|
376
|
+
* }
|
|
196
377
|
* }
|
|
197
378
|
*
|
|
198
|
-
* class
|
|
379
|
+
* class MyController {
|
|
199
380
|
* @http.GET()
|
|
200
|
-
*
|
|
201
|
-
*
|
|
381
|
+
* @http.resolveParameter(User, UserResolver)
|
|
382
|
+
* myAction(user: User) {
|
|
202
383
|
* }
|
|
203
384
|
* }
|
|
385
|
+
*
|
|
386
|
+
* new App({providers: [UserResolver]}).run();
|
|
204
387
|
* ```
|
|
205
388
|
*/
|
|
206
|
-
|
|
207
|
-
this.t.
|
|
208
|
-
this.t.typePath = ''; //root
|
|
209
|
-
}
|
|
210
|
-
query(path) {
|
|
211
|
-
this.t.typePath = path; //undefined === propertyName
|
|
212
|
-
this.t.type = 'query';
|
|
213
|
-
}
|
|
214
|
-
get optional() {
|
|
215
|
-
this.t.optional = true;
|
|
216
|
-
return;
|
|
389
|
+
resolveParameter(classType, resolver) {
|
|
390
|
+
this.t.resolverForToken.set(classType, resolver);
|
|
217
391
|
}
|
|
218
392
|
/**
|
|
219
|
-
*
|
|
220
|
-
* and deserialized to the defined type.
|
|
221
|
-
* Define a `path` if you want to parse a subset of the query string only.
|
|
222
|
-
*
|
|
223
|
-
* Note: Make sure the defined parameter type has optional properties,
|
|
224
|
-
* otherwise it's always required to pass a query string.
|
|
393
|
+
* Adds a parameter resolver for parameters based on its name. Use .resolveParameter() for class-based resolving.
|
|
225
394
|
*
|
|
226
|
-
* @example
|
|
227
395
|
* ```typescript
|
|
228
|
-
*
|
|
229
|
-
*
|
|
396
|
+
*
|
|
397
|
+
* class UserResolver {
|
|
398
|
+
* resolve(context: RouteParameterResolverContext): any | Promise<any> {
|
|
399
|
+
* return new User();
|
|
400
|
+
* }
|
|
230
401
|
* }
|
|
231
402
|
*
|
|
232
|
-
* class
|
|
233
|
-
* @http.GET(
|
|
234
|
-
*
|
|
235
|
-
*
|
|
403
|
+
* class MyController {
|
|
404
|
+
* @http.GET()
|
|
405
|
+
* @http.resolveParameterByName('user', UserResolver)
|
|
406
|
+
* myAction(user: User) {
|
|
236
407
|
* }
|
|
237
408
|
* }
|
|
238
409
|
*
|
|
239
|
-
*
|
|
240
|
-
* // -> /my-action?name=Peter
|
|
410
|
+
* new App({providers: [UserResolver]}).run();
|
|
241
411
|
* ```
|
|
242
|
-
*
|
|
243
412
|
*/
|
|
244
|
-
|
|
245
|
-
this.t.
|
|
246
|
-
this.t.type = 'query';
|
|
413
|
+
resolveParameterByName(name, resolver) {
|
|
414
|
+
this.t.resolverForParameterName.set(name, resolver);
|
|
247
415
|
}
|
|
248
416
|
}
|
|
249
|
-
|
|
417
|
+
HttpActionDecorator.__type = ['t', function () { return new HttpAction; }, () => __Ω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', 'HttpActionDecorator', '!3!>"Pn#2$P&-J2%"2&8"0\'P&2("0(P&2)"0)Pn*2+"0,PP7-2."0.Pn/@20"01PPP7223$/425"05P&2("26"07P&28"08P&@29"09P&2:>;"0<P&2:>="0>P&2:>?"0@P&2:>A"0BP&2:>C"0DP&2:>E"0FP&2:>G"0HP&2:>I"0JP&2:>K"0LP\'2M&2)>N"oO"2P8"0QPPnR&"J2SnUoT"2V"0WP&2(nYoX"2V"0Z5w['];
|
|
418
|
+
const __ΩHttpActionFluidDecorator = ['T', 'D', "response", 'statusCode', 'description', () => __ΩReceiveType, 'type', () => __ΩHttpActionFluidDecorator, '', 'args', () => __ΩHttpActionFluidDecorator, () => __ΩHttpActionFluidDecorator, () => __ΩExtractApiDataType, '_data', 'HttpActionFluidDecorator', '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!w/y'];
|
|
419
|
+
const __ΩHttpActionPropertyDecoratorResult = [() => __ΩHttpActionFluidDecorator, () => __ΩExtractClass, () => HttpActionDecorator, () => __ΩPropertyDecoratorFn, () => __ΩDecoratorAndFetchSignature, () => HttpActionDecorator, () => __ΩPropertyDecoratorFn, 'HttpActionPropertyDecoratorResult', 'Pi#o""n$o!#i&n\'o%#Kw(y'];
|
|
250
420
|
export const httpAction = createPropertyDecoratorContext(HttpActionDecorator);
|
|
251
|
-
|
|
252
|
-
|
|
421
|
+
const __ΩHttpMerge = ['U', "response", 'statusCode', 'description', () => __ΩReceiveType, 'type', () => __ΩPropertyDecoratorFn, '', 'a', () => __ΩDualDecorator, () => __ΩPropertyDecoratorFn, 'HttpMerge', '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!w,y'];
|
|
422
|
+
const __ΩMergedHttp = ['T', () => __ΩHttpMerge, () => __ΩOmit, () => __ΩUnionToIntersection, "_fetch", "t", 'MergedHttp', 'b!e!!\'fo$"P.%.&Jo##o""w\'y'];
|
|
423
|
+
const __ΩHttpDecorator = [() => __ΩPropertyDecoratorFn, () => __ΩHttpActionFluidDecorator, () => HttpActionDecorator, () => __ΩPropertyDecoratorFn, 'HttpDecorator', 'Pn!P7#n$o"#Kw%y'];
|
|
424
|
+
export { __ΩHttpDecorator as __ΩHttpDecorator };
|
|
425
|
+
export const http = mergeDecorator(httpClass, httpAction);
|
|
253
426
|
//# sourceMappingURL=decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../src/decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../src/decorator.ts"],"names":[],"mappings":";;;;6BAU4C,eAAe;;wCAkBpD,eAAe;;0CACiB,aAAa;;+BAD7C,eAAe;;kCAEiE,iBAAiB;;oCAAjB,iBAAiB;;sCAFjG,eAAe;;gCAAf,eAAe;;uCAAf,eAAe;;8CAAf,eAAe;;iCAAf,eAAe;;uCAAf,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,iBAAiB,CAAC;;AAIzG,SAAS,yBAAyB,CAAC,CAAuB;IACtD,OAAO,OAAO,CAAC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AC;IACjC,CAAC;IAED,GAAG,CAAC,OAAe,EAAE;QACjB,IAAI,CAAC,CAAC,CAAC,WAAW,GAAG,EAAE,CAAC;QACxB,IAAI,IAAI;YAAE,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAI,UAAkB,EAAE,cAAsB,EAAE,EAAE;IAvB1D;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,OAAuE;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;;wDApMG,IAAI,UAAU;;;AAiNtB,MAAM,CAAC,MAAM,UAAU,GAAsC,8BAA8B,CAAC,mBAAmB,CAAC,CAAC;;;;;AAQjH,MAAM,CAAC,MAAM,IAAI,GAAsD,cAAc,CAAC,SAAS,EAAE,UAAU,CAA6D,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ClassType } from '@deepkit/core';
|
|
2
|
+
import { AppModule } from '@deepkit/app';
|
|
3
|
+
import { RouteConfig, HttpRouter } from './router.js';
|
|
4
|
+
export interface HttpRouteFilterRoute {
|
|
5
|
+
path?: string;
|
|
6
|
+
pathRegExp?: RegExp;
|
|
7
|
+
httpMethod?: 'GET' | 'HEAD' | 'POST' | 'PATCH' | 'PUT' | 'DELETE' | 'OPTIONS' | 'TRACE';
|
|
8
|
+
category?: string;
|
|
9
|
+
group?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class HttpRouteFilterModel {
|
|
12
|
+
controllers: ClassType[];
|
|
13
|
+
excludeControllers: ClassType[];
|
|
14
|
+
routes: HttpRouteFilterRoute[];
|
|
15
|
+
excludeRoutes: HttpRouteFilterRoute[];
|
|
16
|
+
routeNames: string[];
|
|
17
|
+
excludeRouteNames: string[];
|
|
18
|
+
modules: AppModule<any>[];
|
|
19
|
+
excludeModules: AppModule<any>[];
|
|
20
|
+
moduleClasses: ClassType<AppModule<any>>[];
|
|
21
|
+
excludeModuleClasses: ClassType<AppModule<any>>[];
|
|
22
|
+
reset(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare class HttpRouterFilterResolver {
|
|
25
|
+
protected router: HttpRouter;
|
|
26
|
+
constructor(router: HttpRouter);
|
|
27
|
+
/**
|
|
28
|
+
* Resolves
|
|
29
|
+
*/
|
|
30
|
+
resolve(filter: HttpRouteFilterModel): RouteConfig[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A class to describe a filter for routes.
|
|
34
|
+
*/
|
|
35
|
+
export declare class HttpRouteFilter {
|
|
36
|
+
model: HttpRouteFilterModel;
|
|
37
|
+
reset(): this;
|
|
38
|
+
forControllers(...controllers: ClassType[]): this;
|
|
39
|
+
excludeControllers(...controllers: ClassType[]): this;
|
|
40
|
+
forRoutes(...routes: HttpRouteFilterRoute[]): this;
|
|
41
|
+
excludeRoutes(...routes: HttpRouteFilterRoute[]): this;
|
|
42
|
+
forRouteNames(...names: string[]): this;
|
|
43
|
+
excludeRouteNames(...names: string[]): this;
|
|
44
|
+
forModules(...modules: AppModule<any>[]): this;
|
|
45
|
+
excludeModules(...modules: AppModule<any>[]): this;
|
|
46
|
+
forModuleClasses(...moduleClasses: ClassType<AppModule<any>>[]): this;
|
|
47
|
+
excludeModuleClasses(...moduleClasses: ClassType<AppModule<any>>[]): this;
|
|
48
|
+
}
|
|
49
|
+
export declare type __ΩHttpRouteFilterRoute = any[];
|