@deepkit/http 1.0.1-alpha.59 → 1.0.1-alpha.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/coverage/clover.xml +1086 -0
  2. package/coverage/coverage-final.json +12 -0
  3. package/coverage/lcov-report/base.css +224 -0
  4. package/coverage/lcov-report/block-navigation.js +79 -0
  5. package/coverage/lcov-report/favicon.png +0 -0
  6. package/coverage/lcov-report/index.html +126 -0
  7. package/coverage/lcov-report/prettify.css +1 -0
  8. package/coverage/lcov-report/prettify.js +2 -0
  9. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  10. package/coverage/lcov-report/sorter.js +170 -0
  11. package/coverage/lcov-report/src/controllers.ts.html +113 -0
  12. package/coverage/lcov-report/src/decorator.ts.html +1280 -0
  13. package/coverage/lcov-report/src/filter.ts.html +734 -0
  14. package/coverage/lcov-report/src/http.ts.html +2192 -0
  15. package/coverage/lcov-report/src/index.html +246 -0
  16. package/coverage/lcov-report/src/kernel.ts.html +260 -0
  17. package/coverage/lcov-report/src/middleware.ts.html +428 -0
  18. package/coverage/lcov-report/src/model.ts.html +937 -0
  19. package/coverage/lcov-report/src/module.config.ts.html +89 -0
  20. package/coverage/lcov-report/src/module.ts.html +245 -0
  21. package/coverage/lcov-report/src/router.ts.html +2318 -0
  22. package/coverage/lcov-report/tests/index.html +111 -0
  23. package/coverage/lcov-report/tests/utils.ts.html +176 -0
  24. package/coverage/lcov.info +2225 -0
  25. package/dist/cjs/index.js +5 -1
  26. package/dist/cjs/index.js.map +1 -1
  27. package/dist/cjs/src/controllers.d.ts +4 -4
  28. package/dist/cjs/src/controllers.js +3 -0
  29. package/dist/cjs/src/controllers.js.map +1 -1
  30. package/dist/cjs/src/decorator.d.ts +29 -94
  31. package/dist/cjs/src/decorator.js +53 -118
  32. package/dist/cjs/src/decorator.js.map +1 -1
  33. package/dist/cjs/src/filter.d.ts +1 -0
  34. package/dist/cjs/src/filter.js +11 -17
  35. package/dist/cjs/src/filter.js.map +1 -1
  36. package/dist/cjs/src/http.d.ts +5 -3
  37. package/dist/cjs/src/http.js +91 -55
  38. package/dist/cjs/src/http.js.map +1 -1
  39. package/dist/cjs/src/kernel.d.ts +3 -3
  40. package/dist/cjs/src/kernel.js +5 -25
  41. package/dist/cjs/src/kernel.js.map +1 -1
  42. package/dist/cjs/src/logger.d.ts +2 -2
  43. package/dist/cjs/src/logger.js +4 -8
  44. package/dist/cjs/src/logger.js.map +1 -1
  45. package/dist/cjs/src/middleware.d.ts +5 -1
  46. package/dist/cjs/src/middleware.js +15 -3
  47. package/dist/cjs/src/middleware.js.map +1 -1
  48. package/dist/cjs/src/model.d.ts +62 -2
  49. package/dist/cjs/src/model.js +101 -26
  50. package/dist/cjs/src/model.js.map +1 -1
  51. package/dist/cjs/src/module.config.d.ts +3 -4
  52. package/dist/cjs/src/module.config.js +8 -6
  53. package/dist/cjs/src/module.config.js.map +1 -1
  54. package/dist/cjs/src/module.d.ts +2 -3
  55. package/dist/cjs/src/module.js +4 -2
  56. package/dist/cjs/src/module.js.map +1 -1
  57. package/dist/cjs/src/router.d.ts +24 -53
  58. package/dist/cjs/src/router.js +140 -159
  59. package/dist/cjs/src/router.js.map +1 -1
  60. package/dist/cjs/src/static-serving.d.ts +1 -0
  61. package/dist/cjs/src/static-serving.js +46 -39
  62. package/dist/cjs/src/static-serving.js.map +1 -1
  63. package/dist/cjs/src/utils.js +1 -0
  64. package/dist/cjs/tests/filter.spec.js +61 -47
  65. package/dist/cjs/tests/filter.spec.js.map +1 -1
  66. package/dist/cjs/tests/middleware.spec.d.ts +1 -1
  67. package/dist/cjs/tests/middleware.spec.js +157 -145
  68. package/dist/cjs/tests/middleware.spec.js.map +1 -1
  69. package/dist/cjs/tests/model.spec.js +4 -4
  70. package/dist/cjs/tests/model.spec.js.map +1 -1
  71. package/dist/cjs/tests/module.spec.js +4 -3
  72. package/dist/cjs/tests/module.spec.js.map +1 -1
  73. package/dist/cjs/tests/router.spec.d.ts +1 -1
  74. package/dist/cjs/tests/router.spec.js +298 -333
  75. package/dist/cjs/tests/router.spec.js.map +1 -1
  76. package/dist/cjs/tests/utils.js +5 -2
  77. package/dist/cjs/tests/utils.js.map +1 -1
  78. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  79. package/dist/esm/src/controllers.d.ts +4 -4
  80. package/dist/esm/src/controllers.js +3 -0
  81. package/dist/esm/src/controllers.js.map +1 -1
  82. package/dist/esm/src/decorator.d.ts +29 -94
  83. package/dist/esm/src/decorator.js +49 -114
  84. package/dist/esm/src/decorator.js.map +1 -1
  85. package/dist/esm/src/filter.d.ts +1 -0
  86. package/dist/esm/src/filter.js +11 -18
  87. package/dist/esm/src/filter.js.map +1 -1
  88. package/dist/esm/src/http.d.ts +5 -3
  89. package/dist/esm/src/http.js +89 -55
  90. package/dist/esm/src/http.js.map +1 -1
  91. package/dist/esm/src/kernel.d.ts +3 -3
  92. package/dist/esm/src/kernel.js +6 -27
  93. package/dist/esm/src/kernel.js.map +1 -1
  94. package/dist/esm/src/logger.d.ts +2 -2
  95. package/dist/esm/src/logger.js +4 -9
  96. package/dist/esm/src/logger.js.map +1 -1
  97. package/dist/esm/src/middleware.d.ts +5 -1
  98. package/dist/esm/src/middleware.js +12 -0
  99. package/dist/esm/src/middleware.js.map +1 -1
  100. package/dist/esm/src/model.d.ts +62 -2
  101. package/dist/esm/src/model.js +92 -24
  102. package/dist/esm/src/model.js.map +1 -1
  103. package/dist/esm/src/module.config.d.ts +3 -4
  104. package/dist/esm/src/module.config.js +6 -5
  105. package/dist/esm/src/module.config.js.map +1 -1
  106. package/dist/esm/src/module.d.ts +2 -3
  107. package/dist/esm/src/module.js +5 -3
  108. package/dist/esm/src/module.js.map +1 -1
  109. package/dist/esm/src/router.d.ts +24 -53
  110. package/dist/esm/src/router.js +136 -155
  111. package/dist/esm/src/router.js.map +1 -1
  112. package/dist/esm/src/static-serving.d.ts +1 -0
  113. package/dist/esm/src/static-serving.js +39 -32
  114. package/dist/esm/src/static-serving.js.map +1 -1
  115. package/dist/esm/src/utils.js +1 -0
  116. package/dist/esm/tests/filter.spec.js +14 -0
  117. package/dist/esm/tests/filter.spec.js.map +1 -1
  118. package/dist/esm/tests/middleware.spec.d.ts +1 -1
  119. package/dist/esm/tests/middleware.spec.js +60 -48
  120. package/dist/esm/tests/middleware.spec.js.map +1 -1
  121. package/dist/esm/tests/module.spec.js +1 -0
  122. package/dist/esm/tests/module.spec.js.map +1 -1
  123. package/dist/esm/tests/router.spec.d.ts +1 -1
  124. package/dist/esm/tests/router.spec.js +167 -202
  125. package/dist/esm/tests/router.spec.js.map +1 -1
  126. package/dist/esm/tests/utils.js +4 -1
  127. package/dist/esm/tests/utils.js.map +1 -1
  128. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  129. package/package.json +14 -15
  130. package/src/controllers.ts +3 -3
  131. package/src/decorator.ts +42 -131
  132. package/src/filter.ts +0 -2
  133. package/src/http.ts +35 -36
  134. package/src/kernel.ts +4 -5
  135. package/src/logger.ts +2 -4
  136. package/src/middleware.ts +2 -1
  137. package/src/model.ts +80 -8
  138. package/src/module.config.ts +3 -6
  139. package/src/module.ts +2 -2
  140. package/src/router.ts +121 -161
  141. package/src/static-serving.ts +14 -12
  142. package/tests/middleware.spec.ts +0 -1
  143. package/tests/router.spec.ts +131 -133
  144. package/tsconfig.json +2 -1
@@ -7,17 +7,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- var __param = (this && this.__param) || function (paramIndex, decorator) {
11
- return function (target, key) { decorator(target, key, paramIndex); }
12
- };
10
+ import { __ΩHttpRegExp as __ΩHttpRegExp } from '../src/model';
11
+ import { __ΩRouteParameterResolverContext as __ΩRouteParameterResolverContext } from '../src/router';
12
+ import { __ΩHttpBody as __ΩHttpBody } from '../src/model';
13
+ import { __ΩHttpQuery as __ΩHttpQuery } from '../src/model';
14
+ import { __ΩHttpQueries as __ΩHttpQueries } from '../src/model';
15
+ import { __ΩGroup as __ΩGroup } from '@deepkit/type';
16
+ import { __ΩMinLength as __ΩMinLength } from '@deepkit/type';
17
+ import { __ΩHttpBodyValidation as __ΩHttpBodyValidation } from '../src/model';
13
18
  import { expect, test } from '@jest/globals';
14
- import 'reflect-metadata';
15
- import { dotToUrlPath, Router } from '../src/router';
19
+ import { dotToUrlPath, Router, UploadedFile } from '../src/router';
16
20
  import { http, httpClass } from '../src/decorator';
17
- import { getClassSchema, t } from '@deepkit/type';
18
- import { httpWorkflow, JSONResponse } from '../src/http';
21
+ import { HttpBadRequestError, httpWorkflow, JSONResponse } from '../src/http';
19
22
  import { eventDispatcher } from '@deepkit/event';
20
- import { inject } from '@deepkit/injector';
21
23
  import { HttpRequest } from '../src/model';
22
24
  import { getClassName, sleep } from '@deepkit/core';
23
25
  import { createHttpKernel } from './utils';
@@ -35,6 +37,7 @@ test('router', async () => {
35
37
  any() {
36
38
  }
37
39
  }
40
+ Controller.__type = ['helloWorld', 'name', 'hello', 'id', 'userStatic', 'id2', 'userStatic2', 'any', 'P"0!P&2""0#P&2$"0%P&2$&2&"0\'P"0(5'];
38
41
  __decorate([
39
42
  http.GET(),
40
43
  __metadata("design:type", Function),
@@ -81,6 +84,7 @@ test('any', async () => {
81
84
  any() {
82
85
  }
83
86
  }
87
+ Controller.__type = ['any', 'P"0!5'];
84
88
  __decorate([
85
89
  http.ANY('/any'),
86
90
  __metadata("design:type", Function),
@@ -108,6 +112,7 @@ test('router parameters', async () => {
108
112
  return new JSONResponse(path);
109
113
  }
110
114
  }
115
+ Controller.__type = ['name', 'string', 'id', 'number', 'yes', 'boolean', () => __ΩHttpRegExp, ".*", 'path', 'any', 'P&2!"0"P\'2#"0$P)2%"0&P&.(o\'#2)"0*5'];
111
116
  __decorate([
112
117
  http.GET('/user/:name'),
113
118
  __metadata("design:type", Function),
@@ -127,9 +132,9 @@ test('router parameters', async () => {
127
132
  __metadata("design:returntype", void 0)
128
133
  ], Controller.prototype, "boolean", null);
129
134
  __decorate([
130
- http.GET(':path').regexp('path', '.*'),
135
+ http.GET(':path'),
131
136
  __metadata("design:type", Function),
132
- __metadata("design:paramtypes", [String]),
137
+ __metadata("design:paramtypes", [Object]),
133
138
  __metadata("design:returntype", void 0)
134
139
  ], Controller.prototype, "any", null);
135
140
  const router = Router.forControllers([Controller]);
@@ -137,7 +142,7 @@ test('router parameters', async () => {
137
142
  const httpKernel = createHttpKernel([Controller]);
138
143
  expect((await httpKernel.request(HttpRequest.GET('/user/peter'))).json).toBe('peter');
139
144
  expect((await httpKernel.request(HttpRequest.GET('/user-id/123'))).json).toBe(123);
140
- expect((await httpKernel.request(HttpRequest.GET('/user-id/asd'))).json).toMatchObject({ message: 'Validation failed: id(invalid_number): No valid number given, got NaN' });
145
+ expect((await httpKernel.request(HttpRequest.GET('/user-id/asd'))).json).toMatchObject({ message: 'Validation error:\nid(type): Cannot convert asd to number' });
141
146
  expect((await httpKernel.request(HttpRequest.GET('/boolean/1'))).json).toBe(true);
142
147
  expect((await httpKernel.request(HttpRequest.GET('/boolean/false'))).json).toBe(false);
143
148
  expect((await httpKernel.request(HttpRequest.GET('/any'))).json).toBe('any');
@@ -149,10 +154,11 @@ test('router HttpRequest', async () => {
149
154
  return [req.url, path];
150
155
  }
151
156
  }
157
+ Controller.__type = [() => HttpRequest, 'req', () => __ΩHttpRegExp, ".*", 'path', 'anyReq', 'PP7!2"&.$o##2%"0&5'];
152
158
  __decorate([
153
- http.GET(':path').regexp('path', '.*'),
159
+ http.GET(':path'),
154
160
  __metadata("design:type", Function),
155
- __metadata("design:paramtypes", [HttpRequest, String]),
161
+ __metadata("design:paramtypes", [HttpRequest, Object]),
156
162
  __metadata("design:returntype", void 0)
157
163
  ], Controller.prototype, "anyReq", null);
158
164
  const httpKernel = createHttpKernel([Controller]);
@@ -164,11 +170,13 @@ test('router parameter resolver by class', async () => {
164
170
  this.username = username;
165
171
  }
166
172
  }
173
+ User.__type = ['username', 'constructor', 'P&2!:"0"5'];
167
174
  class Group {
168
175
  constructor(name) {
169
176
  this.name = name;
170
177
  }
171
178
  }
179
+ Group.__type = ['name', 'constructor', 'P&2!:"0"5'];
172
180
  class UserResolver {
173
181
  resolve(context) {
174
182
  const value = context.value || context.parameters.username;
@@ -177,6 +185,7 @@ test('router parameter resolver by class', async () => {
177
185
  return new User(value);
178
186
  }
179
187
  }
188
+ UserResolver.__type = [() => __ΩRouteParameterResolverContext, 'context', 'resolve', 'Pn!2"P""`J0#5'];
180
189
  class GroupResolver {
181
190
  resolve(context) {
182
191
  if (!context.value)
@@ -184,6 +193,7 @@ test('router parameter resolver by class', async () => {
184
193
  return new Group(context.value);
185
194
  }
186
195
  }
196
+ GroupResolver.__type = [() => __ΩRouteParameterResolverContext, 'context', 'resolve', 'Pn!2"P""`J0#5'];
187
197
  let Controller = class Controller {
188
198
  route1(user) {
189
199
  return [user.username];
@@ -195,6 +205,7 @@ test('router parameter resolver by class', async () => {
195
205
  return [user.username, group.name];
196
206
  }
197
207
  };
208
+ Controller.__type = [() => User, 'user', 'route1', () => User, 'route2', () => User, () => Group, 'group', 'route3', 'PP7!2""0#PP7$2""0%PP7&2"P7\'2("0)5'];
198
209
  __decorate([
199
210
  http.GET('user/:username'),
200
211
  __metadata("design:type", Function),
@@ -232,11 +243,13 @@ test('router parameter resolver by name', async () => {
232
243
  this.username = username;
233
244
  }
234
245
  }
246
+ User.__type = ['username', 'constructor', 'P&2!:"0"5'];
235
247
  class Group {
236
248
  constructor(name) {
237
249
  this.name = name;
238
250
  }
239
251
  }
252
+ Group.__type = ['name', 'constructor', 'P&2!:"0"5'];
240
253
  class UserResolver {
241
254
  resolve(context) {
242
255
  const value = context.value || context.parameters.username;
@@ -246,6 +259,7 @@ test('router parameter resolver by name', async () => {
246
259
  return new User(value);
247
260
  }
248
261
  }
262
+ UserResolver.__type = [() => __ΩRouteParameterResolverContext, 'context', 'resolve', 'Pn!2"P""`J0#5'];
249
263
  class GroupResolver {
250
264
  resolve(context) {
251
265
  if (!context.value)
@@ -253,16 +267,19 @@ test('router parameter resolver by name', async () => {
253
267
  return new Group(context.value);
254
268
  }
255
269
  }
270
+ GroupResolver.__type = [() => __ΩRouteParameterResolverContext, 'context', 'resolve', 'Pn!2"P""`J0#5'];
256
271
  class MyAuth {
257
272
  constructor(name) {
258
273
  this.name = name;
259
274
  }
260
275
  }
276
+ MyAuth.__type = ['name', 'constructor', 'P&2!:"0"5'];
261
277
  class AuthResolver {
262
278
  resolve(context) {
263
279
  return new MyAuth('auth');
264
280
  }
265
281
  }
282
+ AuthResolver.__type = [() => __ΩRouteParameterResolverContext, 'context', 'resolve', 'Pn!2"P""`J0#5'];
266
283
  let Controller = class Controller {
267
284
  route1(user) {
268
285
  return [user.username];
@@ -277,6 +294,7 @@ test('router parameter resolver by name', async () => {
277
294
  return [auth.name, getClassName(auth)];
278
295
  }
279
296
  };
297
+ Controller.__type = [() => User, 'user', 'route1', () => User, 'route2', () => User, () => Group, 'group', 'route3', 'auth', 'nonClass', 'PP7!2""0#PP7$2""0%PP7&2"P7\'2("0)P"2*"0+5'];
280
298
  __decorate([
281
299
  http.GET('user/:username'),
282
300
  __metadata("design:type", Function),
@@ -314,23 +332,20 @@ test('router parameter resolver by name', async () => {
314
332
  expect((await httpKernel.request(HttpRequest.GET('/invalid'))).bodyString).toEqual('Internal error');
315
333
  expect((await httpKernel.request(HttpRequest.GET('/nonClass'))).json).toEqual(['auth', 'MyAuth']);
316
334
  });
317
- test('router body', async () => {
335
+ test('router body class', async () => {
318
336
  class Body {
319
337
  }
320
- __decorate([
321
- t,
322
- __metadata("design:type", String)
323
- ], Body.prototype, "username", void 0);
338
+ Body.__type = ['username', '&3!5'];
324
339
  class Controller {
325
340
  anyReq(body, req) {
326
341
  return [body.username, body instanceof Body, req.url];
327
342
  }
328
343
  }
344
+ Controller.__type = [() => __ΩHttpBody, () => Body, 'body', () => HttpRequest, 'req', 'anyReq', 'PP7"o!"2#P7$2%"0&5'];
329
345
  __decorate([
330
346
  http.POST(),
331
- __param(0, http.body()),
332
347
  __metadata("design:type", Function),
333
- __metadata("design:paramtypes", [Body, HttpRequest]),
348
+ __metadata("design:paramtypes", [Object, HttpRequest]),
334
349
  __metadata("design:returntype", void 0)
335
350
  ], Controller.prototype, "anyReq", null);
336
351
  const httpKernel = createHttpKernel([Controller]);
@@ -339,45 +354,55 @@ test('router body', async () => {
339
354
  test('router body is safe for simultaneous requests', async () => {
340
355
  class Body {
341
356
  }
342
- __decorate([
343
- t,
344
- __metadata("design:type", String)
345
- ], Body.prototype, "username", void 0);
357
+ Body.__type = ['username', '&3!5'];
346
358
  class Controller {
347
359
  anyReq(body, req) {
348
360
  return [body.username, body instanceof Body, req.url];
349
361
  }
350
362
  }
363
+ Controller.__type = [() => __ΩHttpBody, () => Body, 'body', () => HttpRequest, 'req', 'anyReq', 'PP7"o!"2#P7$2%"0&5'];
351
364
  __decorate([
352
365
  http.POST(),
353
- __param(0, http.body()),
354
366
  __metadata("design:type", Function),
355
- __metadata("design:paramtypes", [Body, HttpRequest]),
367
+ __metadata("design:paramtypes", [Object, HttpRequest]),
356
368
  __metadata("design:returntype", void 0)
357
369
  ], Controller.prototype, "anyReq", null);
358
370
  const httpKernel = createHttpKernel([Controller]);
359
371
  const makeReq = () => httpKernel.request(HttpRequest.POST('/').json({ username: 'Peter' }));
360
- const results = await Promise.all([...new Array(100)].map(() => makeReq().then(res => res.json)));
372
+ const results = await Promise.all([...new Array(100)].map(() => makeReq().then(Object.assign(res => res.json, { __type: ['res', '', 'P"2!"/"'] }))));
361
373
  expect(results).toEqual(results.map(() => ['Peter', true, '/']));
362
374
  });
375
+ test('router body interface', async () => {
376
+ var __ΩBody = ['username', 'P&4!M'];
377
+ class Controller {
378
+ anyReq(body, req) {
379
+ return [body.username, typeof body.username, req.url];
380
+ }
381
+ }
382
+ Controller.__type = [() => __ΩHttpBody, () => __ΩBody, 'body', () => HttpRequest, 'req', 'anyReq', 'Pn"o!"2#P7$2%"0&5'];
383
+ __decorate([
384
+ http.POST(),
385
+ __metadata("design:type", Function),
386
+ __metadata("design:paramtypes", [Object, HttpRequest]),
387
+ __metadata("design:returntype", void 0)
388
+ ], Controller.prototype, "anyReq", null);
389
+ const httpKernel = createHttpKernel([Controller]);
390
+ expect((await httpKernel.request(HttpRequest.POST('/').json({ username: 'Peter' }))).json).toEqual(['Peter', 'string', '/']);
391
+ });
363
392
  test('router body double', async () => {
364
393
  class Body {
365
394
  }
366
- __decorate([
367
- t,
368
- __metadata("design:type", String)
369
- ], Body.prototype, "username", void 0);
395
+ Body.__type = ['username', '&3!5'];
370
396
  class Controller {
371
397
  anyReq(body, body2, req) {
372
398
  return [body2.username, body2 instanceof Body && body instanceof Body, req.url];
373
399
  }
374
400
  }
401
+ Controller.__type = [() => __ΩHttpBody, () => Body, 'body', () => __ΩHttpBody, () => Body, 'body2', () => HttpRequest, 'req', 'anyReq', 'PP7"o!"2#P7%o$"2&P7\'2("0)5'];
375
402
  __decorate([
376
403
  http.POST(),
377
- __param(0, http.body()),
378
- __param(1, http.body()),
379
404
  __metadata("design:type", Function),
380
- __metadata("design:paramtypes", [Body, Body, HttpRequest]),
405
+ __metadata("design:paramtypes", [Object, Object, HttpRequest]),
381
406
  __metadata("design:returntype", void 0)
382
407
  ], Controller.prototype, "anyReq", null);
383
408
  const httpData = httpClass._fetch(Controller);
@@ -386,10 +411,6 @@ test('router body double', async () => {
386
411
  const action = [...httpData.getActions()][0];
387
412
  expect(action.methodName).toBe('anyReq');
388
413
  expect(action.httpMethods).toEqual(['POST']);
389
- expect(action.parameters['body']).not.toBeUndefined();
390
- expect(action.parameters['body'].name).toBe('body');
391
- expect(action.parameters['body2']).not.toBeUndefined();
392
- expect(action.parameters['body2'].name).toBe('body2');
393
414
  const httpKernel = createHttpKernel([Controller]);
394
415
  expect((await httpKernel.request(HttpRequest.POST('/').json({ username: 'Peter' }))).json).toEqual(['Peter', true, '/']);
395
416
  });
@@ -403,6 +424,7 @@ test('router groups', async () => {
403
424
  c() {
404
425
  }
405
426
  }
427
+ Controller.__type = ['a', 'b', 'c', 'P"0!P"0"P"0#5'];
406
428
  __decorate([
407
429
  http.GET('a').group('a'),
408
430
  __metadata("design:type", Function),
@@ -437,6 +459,7 @@ test('router groups', async () => {
437
459
  c() {
438
460
  }
439
461
  };
462
+ Controller.__type = ['a', 'b', 'c', 'P"0!P"0"P"0#5'];
440
463
  __decorate([
441
464
  http.GET('a').group('a'),
442
465
  __metadata("design:type", Function),
@@ -472,11 +495,11 @@ test('router query', async () => {
472
495
  return test;
473
496
  }
474
497
  }
498
+ Controller.__type = [() => __ΩHttpQuery, 'test', 'anyReq', 'P\'o!"2"8"0#5'];
475
499
  __decorate([
476
500
  http.GET('my-action'),
477
- __param(0, http.query().optional),
478
501
  __metadata("design:type", Function),
479
- __metadata("design:paramtypes", [Number]),
502
+ __metadata("design:paramtypes", [Object]),
480
503
  __metadata("design:returntype", void 0)
481
504
  ], Controller.prototype, "anyReq", null);
482
505
  const httpData = httpClass._fetch(Controller);
@@ -485,9 +508,6 @@ test('router query', async () => {
485
508
  const action = [...httpData.getActions()][0];
486
509
  expect(action.methodName).toBe('anyReq');
487
510
  expect(action.httpMethods).toEqual(['GET']);
488
- expect(action.parameters['test']).not.toBeUndefined();
489
- expect(action.parameters['test'].name).toBe('test');
490
- expect(action.parameters['test'].type).toBe('query');
491
511
  const httpKernel = createHttpKernel([Controller]);
492
512
  expect((await httpKernel.request(HttpRequest.GET('/my-action?test=123'))).json).toEqual(123);
493
513
  expect((await httpKernel.request(HttpRequest.GET('/my-action'))).bodyString).toEqual('');
@@ -495,28 +515,17 @@ test('router query', async () => {
495
515
  test('router query all', async () => {
496
516
  class AnyReqQuery {
497
517
  }
498
- __decorate([
499
- t.optional,
500
- __metadata("design:type", String)
501
- ], AnyReqQuery.prototype, "test", void 0);
502
- __decorate([
503
- t.optional,
504
- __metadata("design:type", String)
505
- ], AnyReqQuery.prototype, "filter", void 0);
506
- __decorate([
507
- t.optional,
508
- __metadata("design:type", Number)
509
- ], AnyReqQuery.prototype, "page", void 0);
518
+ AnyReqQuery.__type = ['test', 'filter', 'page', '&3!8&3"8\'3#85'];
510
519
  class Controller {
511
520
  anyReq(anyReqQuery) {
512
521
  return anyReqQuery;
513
522
  }
514
523
  }
524
+ Controller.__type = [() => __ΩHttpQueries, () => AnyReqQuery, 'anyReqQuery', 'anyReq', 'PP7"o!"2#"0$5'];
515
525
  __decorate([
516
526
  http.GET('my-action'),
517
- __param(0, http.queries()),
518
527
  __metadata("design:type", Function),
519
- __metadata("design:paramtypes", [AnyReqQuery]),
528
+ __metadata("design:paramtypes", [Object]),
520
529
  __metadata("design:returntype", void 0)
521
530
  ], Controller.prototype, "anyReq", null);
522
531
  const httpKernel = createHttpKernel([Controller]);
@@ -527,25 +536,18 @@ test('router query all', async () => {
527
536
  test('serializer options', async () => {
528
537
  class User {
529
538
  }
530
- __decorate([
531
- t,
532
- __metadata("design:type", String)
533
- ], User.prototype, "username", void 0);
534
- __decorate([
535
- t.group('sensitive'),
536
- __metadata("design:type", String)
537
- ], User.prototype, "password", void 0);
539
+ User.__type = ['username', () => __ΩGroup, "sensitive", 'password', '&3!P&.#o""K3$5'];
538
540
  class Controller {
539
541
  anyReq() {
540
542
  return { username: 'Peter', password: 'secret' };
541
543
  }
542
544
  }
545
+ Controller.__type = [() => User, 'anyReq', 'PP7!0"5'];
543
546
  __decorate([
544
547
  http.GET().serialization({ groupsExclude: ['sensitive'] }),
545
- t.type(User),
546
548
  __metadata("design:type", Function),
547
549
  __metadata("design:paramtypes", []),
548
- __metadata("design:returntype", void 0)
550
+ __metadata("design:returntype", User)
549
551
  ], Controller.prototype, "anyReq", null);
550
552
  const httpKernel = createHttpKernel([Controller]);
551
553
  expect((await httpKernel.request(HttpRequest.GET('/'))).json).toEqual({ username: 'Peter' });
@@ -553,23 +555,16 @@ test('serializer options', async () => {
553
555
  test('hook after serializer', async () => {
554
556
  class User {
555
557
  }
556
- __decorate([
557
- t,
558
- __metadata("design:type", String)
559
- ], User.prototype, "username", void 0);
560
- __decorate([
561
- t.group('sensitive'),
562
- __metadata("design:type", String)
563
- ], User.prototype, "password", void 0);
558
+ User.__type = ['username', () => __ΩGroup, "sensitive", 'password', '&3!P&.#o""K3$5'];
564
559
  class Controller {
565
560
  async anyReq() {
566
561
  await sleep(0.1);
567
562
  return { username: 'Peter', password: 'secret' };
568
563
  }
569
564
  }
565
+ Controller.__type = [() => User, 'anyReq', 'PP7!`0"5'];
570
566
  __decorate([
571
567
  http.GET().serialization({ groupsExclude: ['sensitive'] }),
572
- t.type(User),
573
568
  __metadata("design:type", Function),
574
569
  __metadata("design:paramtypes", []),
575
570
  __metadata("design:returntype", Promise)
@@ -579,6 +574,7 @@ test('hook after serializer', async () => {
579
574
  event.result = { processingTime: event.controllerActionTime, data: event.result };
580
575
  }
581
576
  }
577
+ Listener.__type = [() => httpWorkflow.onResponse.event, 'event', 'onResponse', 'Pi!2""0#5'];
582
578
  __decorate([
583
579
  eventDispatcher.listen(httpWorkflow.onResponse),
584
580
  __metadata("design:type", Function),
@@ -595,6 +591,7 @@ test('invalid route definition', async () => {
595
591
  doIt(user) {
596
592
  }
597
593
  }
594
+ Controller.__type = ['user', 'doIt', 'P"2!"0"5'];
598
595
  __decorate([
599
596
  http.GET(),
600
597
  __metadata("design:type", Function),
@@ -602,7 +599,7 @@ test('invalid route definition', async () => {
602
599
  __metadata("design:returntype", void 0)
603
600
  ], Controller.prototype, "doIt", null);
604
601
  const httpKernel = createHttpKernel([Controller]);
605
- expect((await httpKernel.request(HttpRequest.GET('/'))).bodyString).toEqual('Not found');
602
+ expect((await httpKernel.request(HttpRequest.GET('/'))).bodyString).toEqual('Internal error');
606
603
  });
607
604
  test('inject request storage ClassType', async () => {
608
605
  class User {
@@ -610,6 +607,7 @@ test('inject request storage ClassType', async () => {
610
607
  this.username = username;
611
608
  }
612
609
  }
610
+ User.__type = ['username', 'constructor', 'P&2!:"0"5'];
613
611
  class Controller {
614
612
  doIt(user) {
615
613
  return { isUser: user instanceof User, username: user.username };
@@ -618,6 +616,7 @@ test('inject request storage ClassType', async () => {
618
616
  return { isUser: user instanceof User };
619
617
  }
620
618
  }
619
+ Controller.__type = [() => User, 'user', 'doIt', () => User, 'doItOptional', 'PP7!2""0#PP7$2"8"0%5'];
621
620
  __decorate([
622
621
  http.GET(),
623
622
  __metadata("design:type", Function),
@@ -626,7 +625,6 @@ test('inject request storage ClassType', async () => {
626
625
  ], Controller.prototype, "doIt", null);
627
626
  __decorate([
628
627
  http.GET('optional'),
629
- __param(0, inject().optional),
630
628
  __metadata("design:type", Function),
631
629
  __metadata("design:paramtypes", [User]),
632
630
  __metadata("design:returntype", void 0)
@@ -638,6 +636,7 @@ test('inject request storage ClassType', async () => {
638
636
  }
639
637
  }
640
638
  }
639
+ Listener.__type = [() => httpWorkflow.onAuth.event, 'event', 'onAuth', 'Pi!2""0#5'];
641
640
  __decorate([
642
641
  eventDispatcher.listen(httpWorkflow.onAuth),
643
642
  __metadata("design:type", Function),
@@ -646,55 +645,16 @@ test('inject request storage ClassType', async () => {
646
645
  ], Listener.prototype, "onAuth", null);
647
646
  const httpKernel = createHttpKernel([Controller], [
648
647
  {
649
- provide: User, scope: 'http', deps: [HttpRequest], useFactory(request) {
648
+ provide: User, scope: 'http',
649
+ useFactory: Object.assign(function useFactory(request) {
650
650
  return request.store.user;
651
- }
651
+ }, { __type: [() => HttpRequest, 'request', 'useFactory', 'PP7!2""/#'] })
652
652
  }
653
653
  ], [Listener]);
654
654
  expect((await httpKernel.request(HttpRequest.GET('/').headers({ authorization: 'yes' }))).json).toEqual({ isUser: true, username: 'bar' });
655
655
  expect((await httpKernel.request(HttpRequest.GET('/').headers({ authorization: 'no' }))).bodyString).toEqual('Internal error');
656
656
  expect((await httpKernel.request(HttpRequest.GET('/optional').headers({ authorization: 'no' }))).json).toEqual({ isUser: false });
657
657
  });
658
- test('inject request storage @inject', async () => {
659
- class User {
660
- constructor(username) {
661
- this.username = username;
662
- }
663
- }
664
- class Controller {
665
- doIt(user) {
666
- return { isUser: user instanceof User, username: user.username };
667
- }
668
- }
669
- __decorate([
670
- http.GET(),
671
- __param(0, inject('user')),
672
- __metadata("design:type", Function),
673
- __metadata("design:paramtypes", [Object]),
674
- __metadata("design:returntype", void 0)
675
- ], Controller.prototype, "doIt", null);
676
- class Listener {
677
- onAuth(event) {
678
- event.request.store.user = new User('bar');
679
- }
680
- }
681
- __decorate([
682
- eventDispatcher.listen(httpWorkflow.onAuth),
683
- __metadata("design:type", Function),
684
- __metadata("design:paramtypes", [Object]),
685
- __metadata("design:returntype", void 0)
686
- ], Listener.prototype, "onAuth", null);
687
- const httpKernel = createHttpKernel([Controller], [
688
- {
689
- provide: 'user', scope: 'http', deps: [HttpRequest], useFactory(request) {
690
- return request.store.user;
691
- }
692
- }
693
- ], [Listener]);
694
- const result = (await httpKernel.request(HttpRequest.GET('/'))).json;
695
- expect(result.isUser).toBe(true);
696
- expect(result.username).toBe('bar');
697
- });
698
658
  test('custom request handling', async () => {
699
659
  class Listener {
700
660
  onRouteNotFound(event) {
@@ -703,6 +663,7 @@ test('custom request handling', async () => {
703
663
  event.send(new JSONResponse(true, 200));
704
664
  }
705
665
  }
666
+ Listener.__type = [() => httpWorkflow.onRouteNotFound.event, 'event', 'onRouteNotFound', 'Pi!2""0#5'];
706
667
  __decorate([
707
668
  eventDispatcher.listen(httpWorkflow.onRouteNotFound),
708
669
  __metadata("design:type", Function),
@@ -722,6 +683,7 @@ test('race condition', async () => {
722
683
  call++;
723
684
  }
724
685
  }
686
+ Listener.__type = [() => httpWorkflow.onRouteNotFound.event, 'event', 'onRouteNotFound', 'Pi!2""0#5'];
725
687
  __decorate([
726
688
  eventDispatcher.listen(httpWorkflow.onAuth),
727
689
  __metadata("design:type", Function),
@@ -736,6 +698,7 @@ test('race condition', async () => {
736
698
  return param2;
737
699
  }
738
700
  }
701
+ Controller.__type = ['param1', 'one', 'param2', 'second', 'P&2!"0"P&2#"0$5'];
739
702
  __decorate([
740
703
  http.GET('/one/:param1'),
741
704
  __metadata("design:type", Function),
@@ -762,6 +725,7 @@ test('multiple methods', async () => {
762
725
  return true;
763
726
  }
764
727
  }
728
+ Controller.__type = ['one', 'P"0!5'];
765
729
  __decorate([
766
730
  http.GET('/one').POST(),
767
731
  __metadata("design:type", Function),
@@ -783,6 +747,7 @@ test('promise serializer', async () => {
783
747
  return 1;
784
748
  }
785
749
  }
750
+ Controller.__type = ['anyReq1', 'anyReq2', 'P"0!P&`0"5'];
786
751
  __decorate([
787
752
  http.GET('1'),
788
753
  __metadata("design:type", Function),
@@ -791,7 +756,6 @@ test('promise serializer', async () => {
791
756
  ], Controller.prototype, "anyReq1", null);
792
757
  __decorate([
793
758
  http.GET('2'),
794
- t.string,
795
759
  __metadata("design:type", Function),
796
760
  __metadata("design:paramtypes", []),
797
761
  __metadata("design:returntype", Promise)
@@ -806,18 +770,28 @@ test('unions', async () => {
806
770
  return page;
807
771
  }
808
772
  }
773
+ Controller.__type = [() => __ΩHttpQuery, 'page', 'list', 'PP\')Jo!"2""0#5'];
809
774
  __decorate([
810
775
  http.GET('/list'),
811
- __param(0, http.query()),
812
- __param(0, t.union(t.number, t.boolean)),
813
776
  __metadata("design:type", Function),
814
777
  __metadata("design:paramtypes", [Object]),
815
778
  __metadata("design:returntype", void 0)
816
779
  ], Controller.prototype, "list", null);
817
780
  const httpKernel = createHttpKernel([Controller]);
781
+ expect((await httpKernel.request(HttpRequest.GET('/list?page=0'))).json).toEqual(0);
818
782
  expect((await httpKernel.request(HttpRequest.GET('/list?page=1'))).json).toEqual(1);
819
783
  expect((await httpKernel.request(HttpRequest.GET('/list?page=2222'))).json).toEqual(2222);
820
784
  expect((await httpKernel.request(HttpRequest.GET('/list?page=false'))).json).toEqual(false);
785
+ expect((await httpKernel.request(HttpRequest.GET('/list?page=true'))).json).toEqual(true);
786
+ expect((await httpKernel.request(HttpRequest.GET('/list?page=asdasdc'))).json).toMatchObject({
787
+ 'errors': [
788
+ {
789
+ 'code': 'type',
790
+ 'message': 'No value given',
791
+ 'path': 'page'
792
+ }
793
+ ],
794
+ });
821
795
  });
822
796
  test('router dotToUrlPath', () => {
823
797
  expect(dotToUrlPath('peter')).toBe('peter');
@@ -828,18 +802,7 @@ test('router dotToUrlPath', () => {
828
802
  test('router url resolve', async () => {
829
803
  class AnyReqQuery {
830
804
  }
831
- __decorate([
832
- t.optional,
833
- __metadata("design:type", String)
834
- ], AnyReqQuery.prototype, "test", void 0);
835
- __decorate([
836
- t.optional,
837
- __metadata("design:type", String)
838
- ], AnyReqQuery.prototype, "filter", void 0);
839
- __decorate([
840
- t.optional,
841
- __metadata("design:type", Number)
842
- ], AnyReqQuery.prototype, "page", void 0);
805
+ AnyReqQuery.__type = ['test', 'filter', 'page', '&3!8&3"8\'3#85'];
843
806
  class Controller {
844
807
  first() {
845
808
  return '';
@@ -860,6 +823,7 @@ test('router url resolve', async () => {
860
823
  return params;
861
824
  }
862
825
  }
826
+ Controller.__type = ['first', 'peter', 'second', () => __ΩHttpQuery, 'secondQuery', () => __ΩHttpQuery, "changed", 'name', 'secondQuery2', () => __ΩHttpQueries, () => AnyReqQuery, 'params', 'third', () => __ΩHttpQueries, () => AnyReqQuery, "deep", 'third2', 'P"0!P&2""0#P&o$"2""0%P&P.\'4(Mo&#2""0)PP7+o*"2,"0-PP7/P.04(Mo.#2,"015'];
863
827
  __decorate([
864
828
  http.GET('').name('first'),
865
829
  __metadata("design:type", Function),
@@ -874,30 +838,26 @@ test('router url resolve', async () => {
874
838
  ], Controller.prototype, "second", null);
875
839
  __decorate([
876
840
  http.GET('').name('secondQuery'),
877
- __param(0, http.query()),
878
841
  __metadata("design:type", Function),
879
- __metadata("design:paramtypes", [String]),
842
+ __metadata("design:paramtypes", [Object]),
880
843
  __metadata("design:returntype", void 0)
881
844
  ], Controller.prototype, "secondQuery", null);
882
845
  __decorate([
883
846
  http.GET('').name('secondQuery2'),
884
- __param(0, http.query('changed')),
885
847
  __metadata("design:type", Function),
886
- __metadata("design:paramtypes", [String]),
848
+ __metadata("design:paramtypes", [Object]),
887
849
  __metadata("design:returntype", void 0)
888
850
  ], Controller.prototype, "secondQuery2", null);
889
851
  __decorate([
890
852
  http.GET('third').name('third'),
891
- __param(0, http.queries()),
892
853
  __metadata("design:type", Function),
893
- __metadata("design:paramtypes", [AnyReqQuery]),
854
+ __metadata("design:paramtypes", [Object]),
894
855
  __metadata("design:returntype", void 0)
895
856
  ], Controller.prototype, "third", null);
896
857
  __decorate([
897
858
  http.GET('third2').name('third2'),
898
- __param(0, http.queries('deep')),
899
859
  __metadata("design:type", Function),
900
- __metadata("design:paramtypes", [AnyReqQuery]),
860
+ __metadata("design:paramtypes", [Object]),
901
861
  __metadata("design:returntype", void 0)
902
862
  ], Controller.prototype, "third2", null);
903
863
  const router = Router.forControllers([Controller]);
@@ -913,76 +873,28 @@ test('router url resolve', async () => {
913
873
  expect(router.resolveUrl('third2', { params: { test: 123, filter: 'peter' } })).toBe('/third2?deep[test]=123&deep[filter]=peter');
914
874
  });
915
875
  test('destructing params', async () => {
916
- class DTO {
917
- }
918
- __decorate([
919
- t.required,
920
- __metadata("design:type", String)
921
- ], DTO.prototype, "name", void 0);
922
- __decorate([
923
- t.required,
924
- __metadata("design:type", String)
925
- ], DTO.prototype, "title", void 0);
876
+ var __ΩDTO = ['name', 'title', 'P&4!&4"M'];
926
877
  class Controller {
927
878
  first({ name, title }) {
928
879
  return [name, title];
929
880
  }
930
881
  }
882
+ Controller.__type = [() => __ΩHttpBody, () => __ΩDTO, 'param0', 'first', 'Pn"o!"2#"0$5'];
931
883
  __decorate([
932
884
  http.GET(''),
933
- __param(0, http.body()),
934
885
  __metadata("design:type", Function),
935
- __metadata("design:paramtypes", [DTO]),
886
+ __metadata("design:paramtypes", [Object]),
936
887
  __metadata("design:returntype", void 0)
937
888
  ], Controller.prototype, "first", null);
938
889
  const httpKernel = createHttpKernel([Controller]);
939
890
  expect((await httpKernel.request(HttpRequest.GET('/').json({ name: 'Peter', title: 'CTO' }))).json).toEqual(['Peter', 'CTO']);
940
891
  });
941
- test('dynamic parameter name', async () => {
942
- let Controller = class Controller {
943
- first(id) {
944
- return [id];
945
- }
946
- second(id, second) {
947
- return [id, second];
948
- }
949
- };
950
- __decorate([
951
- http.GET('first/:another'),
952
- __param(0, t.description('The identifier').name('another')),
953
- __metadata("design:type", Function),
954
- __metadata("design:paramtypes", [String]),
955
- __metadata("design:returntype", void 0)
956
- ], Controller.prototype, "first", null);
957
- __decorate([
958
- http.GET('second/:another2'),
959
- __param(0, t.description('The identifier').name('another2')),
960
- __param(1, http.query()),
961
- __metadata("design:type", Function),
962
- __metadata("design:paramtypes", [String, String]),
963
- __metadata("design:returntype", void 0)
964
- ], Controller.prototype, "second", null);
965
- Controller = __decorate([
966
- http.controller()
967
- ], Controller);
968
- const schema = getClassSchema(Controller);
969
- expect(schema.getMethodProperties('first')[0].name).toBe('another');
970
- expect(schema.getMethodProperties('second')[0].name).toBe('another2');
971
- expect(schema.getMethodProperties('second')[1].name).toBe('second');
972
- const httpKernel = createHttpKernel([Controller]);
973
- expect((await httpKernel.request(HttpRequest.GET('/first/peter'))).json).toEqual(['peter']);
974
- expect((await httpKernel.request(HttpRequest.GET('/second/peter?second=true'))).json).toEqual(['peter', 'true']);
975
- });
976
892
  test('use http.response for serialization', async () => {
977
- const schemaString = t.schema({
978
- title: t.string
979
- });
980
- const errorSchema = t.schema({
981
- message: t.string
982
- });
893
+ var __ΩDefaultResponse = ['title', 'P&4!M'];
894
+ var __ΩErrorResponse = ['message', 'P&4!M'];
983
895
  class Controller {
984
896
  action1() {
985
- return [{ title: 'a' }, { title: 1 }];
897
+ return [{ title: 'a' }, { title: '1' }];
986
898
  }
987
899
  action2() {
988
900
  return [{ title: 'a' }, { title: 1 }];
@@ -991,23 +903,23 @@ test('use http.response for serialization', async () => {
991
903
  return new JSONResponse([{ message: 'error' }, { message: 1 }]).status(400);
992
904
  }
993
905
  }
906
+ Controller.__type = [() => __ΩDefaultResponse, 'action1', 'action2', 'action3', 'Pn!F0"P"0#P"0$5'];
994
907
  __decorate([
995
908
  http.GET('/action1'),
996
- t.array(schemaString),
997
909
  __metadata("design:type", Function),
998
910
  __metadata("design:paramtypes", []),
999
- __metadata("design:returntype", void 0)
911
+ __metadata("design:returntype", Array)
1000
912
  ], Controller.prototype, "action1", null);
1001
913
  __decorate([
1002
- http.GET('/action2').response(200, `List`, t.array(schemaString)),
914
+ http.GET('/action2').response(200, `List`, [() => __ΩDefaultResponse, 'n!F']),
1003
915
  __metadata("design:type", Function),
1004
916
  __metadata("design:paramtypes", []),
1005
917
  __metadata("design:returntype", void 0)
1006
918
  ], Controller.prototype, "action2", null);
1007
919
  __decorate([
1008
920
  http.GET('/action3')
1009
- .response(200, `List`, t.array(schemaString))
1010
- .response(400, `Error`, t.array(errorSchema)),
921
+ .response(200, `List`, [() => __ΩDefaultResponse, 'n!F'])
922
+ .response(400, `Error`, [() => __ΩErrorResponse, 'n!F']),
1011
923
  __metadata("design:type", Function),
1012
924
  __metadata("design:paramtypes", []),
1013
925
  __metadata("design:returntype", void 0)
@@ -1017,4 +929,57 @@ test('use http.response for serialization', async () => {
1017
929
  expect((await httpKernel.request(HttpRequest.GET('/action2'))).json).toEqual([{ title: 'a' }, { title: '1' }]);
1018
930
  expect((await httpKernel.request(HttpRequest.GET('/action3'))).json).toEqual([{ message: 'error' }, { message: '1' }]);
1019
931
  });
932
+ test('BodyValidation', async () => {
933
+ class User {
934
+ }
935
+ User.__type = [() => __ΩMinLength, 3, 'username', 'P&."o!"K3#5'];
936
+ class AddUserDto extends User {
937
+ }
938
+ AddUserDto.__type = [() => UploadedFile, 'imageUpload', 'P7!3"85'];
939
+ class Controller {
940
+ action1(user) {
941
+ return user;
942
+ }
943
+ action2(user) {
944
+ if (user.valid()) {
945
+ return user.value;
946
+ }
947
+ throw new HttpBadRequestError('Invalid: ' + user.error.getErrorMessageForPath('username'));
948
+ }
949
+ action3(user) {
950
+ if (user.valid()) {
951
+ return user.value;
952
+ }
953
+ throw new HttpBadRequestError('Invalid: ' + user.error.getErrorMessageForPath('username'));
954
+ }
955
+ }
956
+ Controller.__type = [() => __ΩHttpBody, () => User, 'user', 'action1', () => __ΩHttpBodyValidation, () => User, () => User, 'action2', () => __ΩHttpBodyValidation, () => AddUserDto, () => User, 'action3', 'PP7"o!"2#"0$PP7&o%"2#P7\'0(PP7*o)"2#P7+0,5'];
957
+ __decorate([
958
+ http.POST('/action1'),
959
+ __metadata("design:type", Function),
960
+ __metadata("design:paramtypes", [Object]),
961
+ __metadata("design:returntype", Object)
962
+ ], Controller.prototype, "action1", null);
963
+ __decorate([
964
+ http.POST('/action2'),
965
+ __metadata("design:type", Function),
966
+ __metadata("design:paramtypes", [Object]),
967
+ __metadata("design:returntype", User)
968
+ ], Controller.prototype, "action2", null);
969
+ __decorate([
970
+ http.POST('/action3'),
971
+ __metadata("design:type", Function),
972
+ __metadata("design:paramtypes", [Object]),
973
+ __metadata("design:returntype", User)
974
+ ], Controller.prototype, "action3", null);
975
+ const httpKernel = createHttpKernel([Controller]);
976
+ expect((await httpKernel.request(HttpRequest.POST('/action1').json({ username: 'Peter' }))).json).toEqual({ username: 'Peter' });
977
+ expect((await httpKernel.request(HttpRequest.POST('/action1').json({ username: 'Pe' }))).json).toEqual({
978
+ errors: [{ code: 'minLength', message: 'Min length is 3', path: 'username' }], message: 'Validation error:\nusername(minLength): Min length is 3'
979
+ });
980
+ expect((await httpKernel.request(HttpRequest.POST('/action2').json({ username: 'Peter' }))).json).toEqual({ username: 'Peter' });
981
+ expect((await httpKernel.request(HttpRequest.POST('/action2').json({ username: 'Pe' }))).bodyString).toEqual(`{"message":"Invalid: Min length is 3"}`);
982
+ expect((await httpKernel.request(HttpRequest.POST('/action3').json({ username: 'Peter' }))).json).toEqual({ username: 'Peter' });
983
+ expect((await httpKernel.request(HttpRequest.POST('/action3').json({ username: 'Pe' }))).bodyString).toEqual(`{"message":"Invalid: Min length is 3"}`);
984
+ });
1020
985
  //# sourceMappingURL=router.spec.js.map