@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.
Files changed (124) hide show
  1. package/CHANGELOG.md +236 -0
  2. package/dist/cjs/index.d.ts +14 -10
  3. package/dist/cjs/index.js +19 -11
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/src/controllers.d.ts +10 -3
  6. package/dist/cjs/src/controllers.js +7 -3
  7. package/dist/cjs/src/controllers.js.map +1 -1
  8. package/dist/cjs/src/decorator.d.ts +144 -70
  9. package/dist/cjs/src/decorator.js +277 -102
  10. package/dist/cjs/src/decorator.js.map +1 -1
  11. package/dist/cjs/src/filter.d.ts +49 -0
  12. package/dist/cjs/src/filter.js +215 -0
  13. package/dist/cjs/src/filter.js.map +1 -0
  14. package/dist/cjs/src/http-app.d.ts +8 -0
  15. package/dist/cjs/src/http-app.js +16 -0
  16. package/dist/cjs/src/http-app.js.map +1 -0
  17. package/dist/cjs/src/http.d.ts +131 -32
  18. package/dist/cjs/src/http.js +523 -122
  19. package/dist/cjs/src/http.js.map +1 -1
  20. package/dist/cjs/src/kernel.d.ts +50 -9
  21. package/dist/cjs/src/kernel.js +109 -98
  22. package/dist/cjs/src/kernel.js.map +1 -1
  23. package/dist/cjs/src/logger.d.ts +3 -3
  24. package/dist/cjs/src/logger.js +9 -12
  25. package/dist/cjs/src/logger.js.map +1 -1
  26. package/dist/cjs/src/middleware.d.ts +61 -0
  27. package/dist/cjs/src/middleware.js +95 -0
  28. package/dist/cjs/src/middleware.js.map +1 -0
  29. package/dist/cjs/src/model.d.ts +270 -4
  30. package/dist/cjs/src/model.js +401 -3
  31. package/dist/cjs/src/model.js.map +1 -1
  32. package/dist/cjs/src/module.config.d.ts +149 -4
  33. package/dist/cjs/src/module.config.js +11 -6
  34. package/dist/cjs/src/module.config.js.map +1 -1
  35. package/dist/cjs/src/module.d.ts +14 -32
  36. package/dist/cjs/src/module.js +122 -7
  37. package/dist/cjs/src/module.js.map +1 -1
  38. package/dist/cjs/src/request-parser.d.ts +37 -0
  39. package/dist/cjs/src/request-parser.js +382 -0
  40. package/dist/cjs/src/request-parser.js.map +1 -0
  41. package/dist/cjs/src/router.d.ts +174 -75
  42. package/dist/cjs/src/router.js +469 -288
  43. package/dist/cjs/src/router.js.map +1 -1
  44. package/dist/cjs/src/static-serving.d.ts +32 -4
  45. package/dist/cjs/src/static-serving.js +115 -71
  46. package/dist/cjs/src/static-serving.js.map +1 -1
  47. package/dist/cjs/src/utils.js +2 -2
  48. package/dist/cjs/src/utils.js.map +1 -1
  49. package/dist/cjs/tsconfig.tsbuildinfo +1 -2916
  50. package/dist/esm/index.d.ts +14 -10
  51. package/dist/esm/index.js +14 -10
  52. package/dist/esm/index.js.map +1 -1
  53. package/dist/esm/src/controllers.d.ts +10 -3
  54. package/dist/esm/src/controllers.js +7 -3
  55. package/dist/esm/src/controllers.js.map +1 -1
  56. package/dist/esm/src/decorator.d.ts +144 -70
  57. package/dist/esm/src/decorator.js +272 -99
  58. package/dist/esm/src/decorator.js.map +1 -1
  59. package/dist/esm/src/filter.d.ts +49 -0
  60. package/dist/esm/src/filter.js +209 -0
  61. package/dist/esm/src/filter.js.map +1 -0
  62. package/dist/esm/src/http-app.d.ts +8 -0
  63. package/dist/esm/src/http-app.js +12 -0
  64. package/dist/esm/src/http-app.js.map +1 -0
  65. package/dist/esm/src/http.d.ts +131 -32
  66. package/dist/esm/src/http.js +504 -121
  67. package/dist/esm/src/http.js.map +1 -1
  68. package/dist/esm/src/kernel.d.ts +50 -9
  69. package/dist/esm/src/kernel.js +110 -100
  70. package/dist/esm/src/kernel.js.map +1 -1
  71. package/dist/esm/src/logger.d.ts +3 -3
  72. package/dist/esm/src/logger.js +7 -11
  73. package/dist/esm/src/logger.js.map +1 -1
  74. package/dist/esm/src/middleware.d.ts +61 -0
  75. package/dist/esm/src/middleware.js +90 -0
  76. package/dist/esm/src/middleware.js.map +1 -0
  77. package/dist/esm/src/model.d.ts +270 -4
  78. package/dist/esm/src/model.js +357 -1
  79. package/dist/esm/src/model.js.map +1 -1
  80. package/dist/esm/src/module.config.d.ts +149 -4
  81. package/dist/esm/src/module.config.js +9 -5
  82. package/dist/esm/src/module.config.js.map +1 -1
  83. package/dist/esm/src/module.d.ts +14 -32
  84. package/dist/esm/src/module.js +121 -7
  85. package/dist/esm/src/module.js.map +1 -1
  86. package/dist/esm/src/request-parser.d.ts +37 -0
  87. package/dist/esm/src/request-parser.js +372 -0
  88. package/dist/esm/src/request-parser.js.map +1 -0
  89. package/dist/esm/src/router.d.ts +174 -75
  90. package/dist/esm/src/router.js +463 -285
  91. package/dist/esm/src/router.js.map +1 -1
  92. package/dist/esm/src/static-serving.d.ts +32 -4
  93. package/dist/esm/src/static-serving.js +107 -65
  94. package/dist/esm/src/static-serving.js.map +1 -1
  95. package/dist/esm/src/utils.js +1 -0
  96. package/dist/esm/src/utils.js.map +1 -1
  97. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -2916
  98. package/index.ts +14 -10
  99. package/package.json +30 -19
  100. package/src/controllers.ts +4 -3
  101. package/src/decorator.ts +242 -104
  102. package/src/filter.ts +224 -0
  103. package/src/http-app.ts +11 -0
  104. package/src/http.ts +501 -100
  105. package/src/kernel.ts +128 -80
  106. package/src/logger.ts +4 -6
  107. package/src/middleware.ts +116 -0
  108. package/src/model.ts +516 -5
  109. package/src/module.config.ts +168 -5
  110. package/src/module.ts +120 -7
  111. package/src/request-parser.ts +430 -0
  112. package/src/router.ts +546 -317
  113. package/src/static-serving.ts +120 -50
  114. package/src/utils.ts +0 -2
  115. package/tsconfig.esm.json +7 -7
  116. package/tsconfig.json +18 -11
  117. package/tsconfig.spec.json +8 -0
  118. package/dist/cjs/tests/router.spec.d.ts +0 -1
  119. package/dist/cjs/tests/router.spec.js +0 -481
  120. package/dist/cjs/tests/router.spec.js.map +0 -1
  121. package/dist/esm/tests/router.spec.d.ts +0 -1
  122. package/dist/esm/tests/router.spec.js +0 -479
  123. package/dist/esm/tests/router.spec.js.map +0 -1
  124. package/tests/router.spec.ts +0 -347
@@ -1,4 +1,38 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.http = exports.__ΩHttpDecorator = exports.httpAction = exports.HttpActionDecorator = exports.httpClass = exports.HttpControllerDecorator = exports.HttpAction = exports.HttpActionParameter = exports.HttpController = void 0;
4
+ exports.getActions = getActions;
5
+ const __ΩOmit = ['T', 'K', () => __ΩPick, () => __ΩExclude, 'Omit', 'b!b"e!!e!!ge!"o$#o##w%y'];
6
+ const __ΩPick = ['T', 'K', 'Pick', 'l+e#!e"!fRb!b"Pde""N#!w#y'];
7
+ const __ΩExclude = ['T', 'U', 'Exclude', 'l6!Re$!RPe#!e$"qk#%QRb!b"Pde"!p)w#y'];
8
+ /*@ts-ignore*/
9
+ const { __ΩClassType } = require('@deepkit/core');
10
+ /*@ts-ignore*/
11
+ const { __ΩSerializationOptions } = require('@deepkit/type');
12
+ /*@ts-ignore*/
13
+ const { __ΩRouteParameterResolver } = require('./router.js');
14
+ /*@ts-ignore*/
15
+ const { __ΩReceiveType } = require('@deepkit/type');
16
+ /*@ts-ignore*/
17
+ const { __ΩHttpMiddleware } = require('./middleware.js');
18
+ /*@ts-ignore*/
19
+ const { __ΩHttpMiddlewareFn } = require('./middleware.js');
20
+ /*@ts-ignore*/
21
+ const { __ΩExtractApiDataType } = require('@deepkit/type');
22
+ /*@ts-ignore*/
23
+ const { __ΩExtractClass } = require('@deepkit/type');
24
+ /*@ts-ignore*/
25
+ const { __ΩPropertyDecoratorFn } = require('@deepkit/type');
26
+ /*@ts-ignore*/
27
+ const { __ΩDecoratorAndFetchSignature } = require('@deepkit/type');
28
+ /*@ts-ignore*/
29
+ const { __ΩDualDecorator } = require('@deepkit/type');
30
+ /*@ts-ignore*/
31
+ const { __ΩUnionToIntersection } = require('@deepkit/type');
32
+ function __assignType(fn, args) {
33
+ fn.__type = args;
34
+ return fn;
35
+ }
2
36
  /*
3
37
  * Deepkit Framework
4
38
  * Copyright (C) 2021 Deepkit UG, Marc J. Schmidt
@@ -8,31 +42,47 @@
8
42
  *
9
43
  * You should have received a copy of the MIT License along with this program.
10
44
  */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.http = exports.httpActionParameter = exports.httpAction = exports.HttpActionDecorator = exports.httpClass = exports.HttpDecorator = exports.HttpAction = exports.HttpActionParameter = void 0;
45
+ const core_1 = require("@deepkit/core");
13
46
  const type_1 = require("@deepkit/type");
14
- const path_1 = require("path");
47
+ const middleware_js_1 = require("./middleware.js");
48
+ const __ΩHttpActionMiddleware = [() => middleware_js_1.HttpMiddlewareConfig, '', () => __ΩClassType, () => __ΩHttpMiddleware, () => __ΩHttpMiddlewareFn, 'HttpActionMiddleware', 'PPP7!/"n$o#"n%Jw&y'];
49
+ function isMiddlewareClassTypeOrFn(v) {
50
+ return (0, core_1.isClass)(v) || !(0, type_1.isDecoratorContext)(middleware_js_1.httpMiddleware, v);
51
+ }
52
+ isMiddlewareClassTypeOrFn.__type = [() => __ΩHttpActionMiddleware, 'v', 'isMiddlewareClassTypeOrFn', 'Pn!2"!/#'];
15
53
  class HttpController {
16
54
  constructor() {
17
55
  this.baseUrl = '';
18
- this.actions = new Set();
56
+ this.actions = (Set.Ω = [[() => HttpAction, 'P7!']], new Set());
19
57
  this.groups = [];
58
+ this.middlewares = [];
59
+ this.resolverForToken = new Map();
60
+ this.resolverForParameterName = new Map();
61
+ this.actionsProcessed = (Set.Ω = [[() => HttpAction, 'P7!']], new Set());
20
62
  }
21
63
  getUrl(action) {
22
- return path_1.join('/', this.baseUrl, action.path);
64
+ return (0, core_1.urlJoin)('/', this.baseUrl, action.path);
23
65
  }
24
66
  addAction(action) {
25
67
  this.actions.add(action);
26
68
  }
27
69
  getActions() {
28
- for (const a of this.actions) {
29
- for (const g of this.groups) {
30
- if (!a.groups.includes(g))
31
- a.groups.push(g);
70
+ for (const action of this.actions) {
71
+ if (!this.actionsProcessed.has(action)) {
72
+ action.groups = [
73
+ ...this.groups,
74
+ ...action.groups.filter(__assignType((g) => !this.groups.includes(g), ['g', '', 'P"2!"/"'])),
75
+ ];
76
+ this.actionsProcessed.add(action);
32
77
  }
33
78
  }
34
79
  return this.actions;
35
80
  }
81
+ removeAction(methodName) {
82
+ const action = this.getAction(methodName);
83
+ this.actions.delete(action);
84
+ this.actionsProcessed.delete(action);
85
+ }
36
86
  getAction(methodName) {
37
87
  for (const a of this.getActions()) {
38
88
  if (a.methodName === methodName)
@@ -41,6 +91,8 @@ class HttpController {
41
91
  throw new Error(`No action with methodName ${methodName} found`);
42
92
  }
43
93
  }
94
+ exports.HttpController = HttpController;
95
+ HttpController.__type = ['baseUrl', function () { return ''; }, 'actions', function () { return (Set.Ω = [[() => HttpAction, 'P7!']], new Set()); }, 'groups', function () { return []; }, () => middleware_js_1.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>'];
44
96
  class HttpActionParameter {
45
97
  constructor() {
46
98
  this.name = '';
@@ -48,61 +100,140 @@ class HttpActionParameter {
48
100
  }
49
101
  }
50
102
  exports.HttpActionParameter = HttpActionParameter;
103
+ HttpActionParameter.__type = ['name', function () { return ''; }, "body", "query", "queries", 'type', 'typePath', 'optional', function () { return false; }, 'HttpActionParameter', '&3!>"P.#.$.%J3&8&3\'8)3(>)5w*'];
51
104
  class HttpAction {
52
105
  constructor() {
53
106
  this.name = '';
54
107
  this.description = '';
55
108
  this.category = '';
56
109
  this.path = '';
57
- this.httpMethod = 'GET';
110
+ this.httpMethods = [];
58
111
  this.methodName = '';
59
112
  this.groups = [];
60
- this.parameterRegularExpressions = {};
61
- /**
62
- * This is only filled when the user used @http.body() for example on an method argument.
63
- */
64
- this.parameters = {};
113
+ this.middlewares = [];
114
+ this.resolverForToken = new Map();
115
+ this.resolverForParameterName = new Map();
65
116
  /**
66
117
  * An arbitrary data container the user can use to store app specific settings/values.
67
118
  */
68
- this.data = new Map();
69
- this.throws = [];
119
+ this.data = (Map.Ω = [['"'], ['"']], new Map());
120
+ this.responses = [];
70
121
  }
71
122
  }
72
123
  exports.HttpAction = HttpAction;
73
- class HttpDecorator {
124
+ 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_js_1.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'];
125
+ class HttpControllerDecorator {
74
126
  constructor() {
75
127
  this.t = new HttpController;
76
128
  }
77
129
  controller(baseUrl = '') {
78
130
  this.t.baseUrl = baseUrl;
79
131
  }
80
- groupAll(...group) {
132
+ group(...group) {
81
133
  this.t.groups.push(...group);
82
134
  }
135
+ middleware(...middlewares) {
136
+ this.t.middlewares.push(...middlewares.map(__assignType(v => isMiddlewareClassTypeOrFn(v) ? middleware_js_1.httpMiddleware.for(v) : v, ['v', '', 'P"2!"/"'])));
137
+ }
138
+ /**
139
+ * Adds a parameter resolver for parameters based on the class type. Use .resolveParameterByName() for name-based resolving.
140
+ *
141
+ * ```typescript
142
+ *
143
+ * class UserResolver {
144
+ * resolve(context: RouteParameterResolverContext): any | Promise<any> {
145
+ * return new User();
146
+ * }
147
+ * }
148
+ *
149
+ * @http.resolveParameter(User, UserResolver)
150
+ * class MyController {
151
+ *
152
+ * @http.GET()
153
+ * myAction(user: User) {
154
+ * }
155
+ * }
156
+ *
157
+ * new App({providers: [UserResolver]}).run();
158
+ * ```
159
+ */
160
+ resolveParameter(classType, resolver) {
161
+ this.t.resolverForToken.set(classType, resolver);
162
+ }
163
+ /**
164
+ * Adds a parameter resolver for parameters based on its name. Use .resolveParameter() for class-based resolving.
165
+ *
166
+ * ```typescript
167
+ *
168
+ * class UserResolver {
169
+ * resolve(context: RouteParameterResolverContext): any | Promise<any> {
170
+ * return new User();
171
+ * }
172
+ * }
173
+ *
174
+ * @http.resolveParameterByName('user', UserResolver)
175
+ * class MyController {
176
+ *
177
+ * @http.GET()
178
+ * myAction(user: User) {
179
+ * }
180
+ * }
181
+ *
182
+ * new App({providers: [UserResolver]}).run();
183
+ * ```
184
+ */
185
+ resolveParameterByName(name, resolver) {
186
+ this.t.resolverForParameterName.set(name, resolver);
187
+ }
83
188
  setAction(action) {
84
189
  this.t.addAction(action);
85
190
  }
86
191
  }
87
- exports.HttpDecorator = HttpDecorator;
88
- exports.httpClass = type_1.createClassDecoratorContext(HttpDecorator);
192
+ exports.HttpControllerDecorator = HttpControllerDecorator;
193
+ 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'];
194
+ exports.httpClass = (0, type_1.createClassDecoratorContext)(HttpControllerDecorator);
195
+ function getActions(target) {
196
+ const parent = Object.getPrototypeOf(target);
197
+ const results = parent ? getActions(parent) : [];
198
+ const config = exports.httpClass._fetch(target);
199
+ if (config) {
200
+ for (const action of config.getActions()) {
201
+ const existing = results.findIndex(__assignType(v => v.methodName === action.methodName, ['v', '', 'P"2!"/"']));
202
+ if (existing !== -1)
203
+ results.splice(existing, 1);
204
+ results.push(action);
205
+ }
206
+ }
207
+ return results;
208
+ }
209
+ getActions.__type = [() => __ΩClassType, 'target', () => HttpAction, 'getActions', 'Pn!2"P7#F/$'];
89
210
  class HttpActionDecorator {
90
211
  constructor() {
91
212
  this.t = new HttpAction;
92
213
  }
93
- onDecorator(target, property) {
214
+ onDecorator(target, property, parameterIndexOrDescriptor) {
215
+ if (!property)
216
+ return;
217
+ if (target === Object)
218
+ return;
94
219
  this.t.methodName = property;
95
220
  exports.httpClass.setAction(this.t)(target);
96
221
  }
97
222
  name(name) {
98
223
  this.t.name = name;
99
224
  }
100
- setParameter(name, parameter) {
101
- this.t.parameters[name] = parameter;
102
- }
103
225
  description(description) {
104
226
  this.t.description = description;
105
227
  }
228
+ serialization(options) {
229
+ this.t.serializationOptions = options;
230
+ }
231
+ serializer(serializer) {
232
+ this.t.serializer = serializer;
233
+ }
234
+ middleware(...middlewares) {
235
+ this.t.middlewares.push(...middlewares.map(__assignType(v => isMiddlewareClassTypeOrFn(v) ? middleware_js_1.httpMiddleware.for(v) : v, ['v', '', 'P"2!"/"'])));
236
+ }
106
237
  /**
107
238
  * Allows to change the HttpAction object and composite multiple properties into one function.
108
239
  *
@@ -136,7 +267,7 @@ class HttpActionDecorator {
136
267
  * assets() {}
137
268
  * }
138
269
  * ```
139
- */
270
+ */
140
271
  data(name, value) {
141
272
  this.t.data.set(name, value);
142
273
  }
@@ -147,114 +278,158 @@ class HttpActionDecorator {
147
278
  this.t.groups.push(...group);
148
279
  }
149
280
  GET(path = '') {
150
- this.t.httpMethod = 'GET';
151
- this.t.path = path;
281
+ this.t.httpMethods.push('GET');
282
+ if (path)
283
+ this.t.path = path;
284
+ }
285
+ HEAD(path = '') {
286
+ this.t.httpMethods.push('HEAD');
287
+ if (path)
288
+ this.t.path = path;
152
289
  }
153
290
  POST(path = '') {
154
- this.t.httpMethod = 'POST';
155
- this.t.path = path;
291
+ this.t.httpMethods.push('POST');
292
+ if (path)
293
+ this.t.path = path;
156
294
  }
157
295
  PUT(path = '') {
158
- this.t.httpMethod = 'PUT';
159
- this.t.path = path;
296
+ this.t.httpMethods.push('PUT');
297
+ if (path)
298
+ this.t.path = path;
160
299
  }
161
300
  DELETE(path = '') {
162
- this.t.httpMethod = 'DELETE';
163
- this.t.path = path;
301
+ this.t.httpMethods.push('DELETE');
302
+ if (path)
303
+ this.t.path = path;
164
304
  }
165
- ANY(path = '') {
166
- this.t.httpMethod = 'ANY';
167
- this.t.path = path;
305
+ OPTIONS(path = '') {
306
+ this.t.httpMethods.push('OPTIONS');
307
+ if (path)
308
+ this.t.path = path;
168
309
  }
169
- throws(errorType, message) {
170
- this.t.throws.push({ errorType, message });
310
+ TRACE(path = '') {
311
+ this.t.httpMethods.push('TRACE');
312
+ if (path)
313
+ this.t.path = path;
171
314
  }
172
- regexp(parameterName, regex) {
173
- this.t.parameterRegularExpressions[parameterName] = regex;
315
+ PATCH(path = '') {
316
+ this.t.httpMethods.push('PATCH');
317
+ if (path)
318
+ this.t.path = path;
174
319
  }
175
- }
176
- exports.HttpActionDecorator = HttpActionDecorator;
177
- class HttpActionParameterDecorator {
178
- constructor() {
179
- this.t = new HttpActionParameter();
180
- }
181
- onDecorator(target, propertyName, parameterIndex) {
182
- if (!propertyName)
183
- throw new Error('@http action parameter decorator can only be used on method arguments.');
184
- if (parameterIndex === undefined)
185
- throw new Error('@http action parameter decorator can only be used on method arguments.');
186
- const schema = type_1.getClassSchema(target);
187
- const property = schema.getMethodProperties(propertyName)[parameterIndex];
188
- this.t.name = property.name;
189
- if (this.t.typePath === undefined) {
190
- this.t.typePath = property.name;
191
- }
192
- exports.httpAction.setParameter(property.name, this.t)(target.prototype, propertyName);
320
+ ANY(path = '') {
321
+ this.t.httpMethods = [];
322
+ if (path)
323
+ this.t.path = path;
193
324
  }
194
325
  /**
195
- * Marks the argument as body parameter. Data from the client sent in the body
196
- * will be tried to parsed (JSON/form data) and deserialized to the defined type.
197
- * Make sure the class type as a schema assigned.
326
+ * Adds additional information about what HTTP status codes are available in this route.
327
+ * You can add additionally a description and a response body type.
328
+ *
329
+ * The type is used for serialization for responses with the given statusCode.
330
+ *
331
+ * This information is available in Deepkit API console.
332
+ *
333
+ * ```typescript
334
+ *
335
+ * http.GET().response<boolean>(200, 'All ok')
336
+ *
337
+ * interface User {
338
+ * username: string;
339
+ * }
340
+ * http.GET().response<User>(200, 'User object')
341
+ *
342
+ * interface HttpErrorMessage {
343
+ * error: string;
344
+ * }
345
+ * http.GET().response<HttpErrorMessage>(500, 'Error')
346
+ * ```
347
+ */
348
+ response(statusCode, description = '', type = this.
349
+ /**
350
+ * Adds additional information about what HTTP status codes are available in this route.
351
+ * You can add additionally a description and a response body type.
352
+ *
353
+ * The type is used for serialization for responses with the given statusCode.
354
+ *
355
+ * This information is available in Deepkit API console.
198
356
  *
199
- * @example
200
357
  * ```typescript
201
- * class MyActionBody {
202
- * @t name!: string;
358
+ *
359
+ * http.GET().response<boolean>(200, 'All ok')
360
+ *
361
+ * interface User {
362
+ * username: string;
363
+ * }
364
+ * http.GET().response<User>(200, 'User object')
365
+ *
366
+ * interface HttpErrorMessage {
367
+ * error: string;
203
368
  * }
369
+ * http.GET().response<HttpErrorMessage>(500, 'Error')
370
+ * ```
371
+ */
372
+ response.Ω?.[0]) {
373
+ this.response.Ω = undefined;
374
+ this.t.responses.push({ statusCode, description, type: type ? (0, type_1.resolveReceiveType)(type) : undefined });
375
+ }
376
+ /**
377
+ * Adds a parameter resolver for parameters based on the class type. Use .resolveParameterByName() for name-based resolving.
378
+ *
379
+ * ```typescript
204
380
  *
205
- * class Controller {
381
+ * class UserResolver {
382
+ * resolve(context: RouteParameterResolverContext): any | Promise<any> {
383
+ * return new User();
384
+ * }
385
+ * }
386
+ *
387
+ * class MyController {
206
388
  * @http.GET()
207
- * myAction(@http.body() body: MyActionBody) {
208
- * console.log('body', body.name);
389
+ * @http.resolveParameter(User, UserResolver)
390
+ * myAction(user: User) {
209
391
  * }
210
392
  * }
393
+ *
394
+ * new App({providers: [UserResolver]}).run();
211
395
  * ```
212
396
  */
213
- body() {
214
- this.t.type = 'body';
215
- this.t.typePath = ''; //root
216
- }
217
- query(path) {
218
- this.t.typePath = path; //undefined === propertyName
219
- this.t.type = 'query';
220
- }
221
- get optional() {
222
- this.t.optional = true;
223
- return;
397
+ resolveParameter(classType, resolver) {
398
+ this.t.resolverForToken.set(classType, resolver);
224
399
  }
225
400
  /**
226
- * Marks the argument as query parameter. Data from the query string is parsed
227
- * and deserialized to the defined type.
228
- * Define a `path` if you want to parse a subset of the query string only.
229
- *
230
- * Note: Make sure the defined parameter type has optional properties,
231
- * otherwise it's always required to pass a query string.
401
+ * Adds a parameter resolver for parameters based on its name. Use .resolveParameter() for class-based resolving.
232
402
  *
233
- * @example
234
403
  * ```typescript
235
- * class MyActionQueries {
236
- * @t.optional name?: string;
404
+ *
405
+ * class UserResolver {
406
+ * resolve(context: RouteParameterResolverContext): any | Promise<any> {
407
+ * return new User();
408
+ * }
237
409
  * }
238
410
  *
239
- * class Controller {
240
- * @http.GET('my-action')
241
- * myAction(@http.queries() query: MyActionQueries) {
242
- * console.log('query', query.name);
411
+ * class MyController {
412
+ * @http.GET()
413
+ * @http.resolveParameterByName('user', UserResolver)
414
+ * myAction(user: User) {
243
415
  * }
244
416
  * }
245
417
  *
246
- * // Open via, e.g.
247
- * // -> /my-action?name=Peter
418
+ * new App({providers: [UserResolver]}).run();
248
419
  * ```
249
- *
250
420
  */
251
- queries(path = '') {
252
- this.t.typePath = path; //'' === root
253
- this.t.type = 'query';
421
+ resolveParameterByName(name, resolver) {
422
+ this.t.resolverForParameterName.set(name, resolver);
254
423
  }
255
424
  }
256
- type_1.createPropertyDecoratorContext(HttpActionDecorator);
257
- exports.httpAction = type_1.createPropertyDecoratorContext(HttpActionDecorator);
258
- exports.httpActionParameter = type_1.createPropertyDecoratorContext(HttpActionParameterDecorator);
259
- exports.http = type_1.mergeDecorator(exports.httpClass, exports.httpAction, exports.httpActionParameter);
425
+ exports.HttpActionDecorator = HttpActionDecorator;
426
+ HttpActionDecorator.__type = ['t', function () { return new HttpAction; }, () => __Ω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', '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['];
427
+ 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'];
428
+ const __ΩHttpActionPropertyDecoratorResult = [() => __ΩHttpActionFluidDecorator, () => __ΩExtractClass, () => HttpActionDecorator, () => __ΩPropertyDecoratorFn, () => __ΩDecoratorAndFetchSignature, () => HttpActionDecorator, () => __ΩPropertyDecoratorFn, 'HttpActionPropertyDecoratorResult', 'Pi#o""n$o!#i&n\'o%#Kw(y'];
429
+ exports.httpAction = (0, type_1.createPropertyDecoratorContext)(HttpActionDecorator);
430
+ 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'];
431
+ const __ΩMergedHttp = ['T', () => __ΩHttpMerge, () => __ΩOmit, () => __ΩUnionToIntersection, "_fetch", "t", 'MergedHttp', 'b!e!!\'fo$"P.%.&Jo##o""w\'y'];
432
+ const __ΩHttpDecorator = [() => __ΩPropertyDecoratorFn, () => __ΩHttpActionFluidDecorator, () => HttpActionDecorator, () => __ΩPropertyDecoratorFn, 'HttpDecorator', 'Pn!P7#n$o"#Kw%y'];
433
+ exports.__ΩHttpDecorator = __ΩHttpDecorator;
434
+ exports.http = (0, type_1.mergeDecorator)(exports.httpClass, exports.httpAction);
260
435
  //# sourceMappingURL=decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../src/decorator.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAGH,wCAA2K;AAC3K,+BAA4B;AAM5B,MAAM,cAAc;IAApB;QACI,YAAO,GAAW,EAAE,CAAC;QACX,YAAO,GAAG,IAAI,GAAG,EAAc,CAAC;QAC1C,WAAM,GAAa,EAAE,CAAC;IA0B1B,CAAC;IAxBG,MAAM,CAAC,MAAkB;QACrB,OAAO,WAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,SAAS,CAAC,MAAkB;QACxB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED,UAAU;QACN,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE;YAC1B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE;gBACzB,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAC/C;SACJ;QAED,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,SAAS,CAAC,UAAkB;QACxB,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE;YAC/B,IAAI,CAAC,CAAC,UAAU,KAAK,UAAU;gBAAE,OAAO,CAAC,CAAC;SAC7C;QACD,MAAM,IAAI,KAAK,CAAC,6BAA6B,UAAU,QAAQ,CAAC,CAAC;IACrE,CAAC;CACJ;AAED,MAAa,mBAAmB;IAAhC;QACI,SAAI,GAAW,EAAE,CAAC;QAOlB,aAAQ,GAAY,KAAK,CAAC;IAC9B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QpG,QAAA,IAAI,GAAsD,IAAA,qBAAc,EAAC,iBAAS,EAAE,kBAAU,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[];