@deepkit/http 1.0.1-alpha.58 → 1.0.1-alpha.62

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 (142) 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/src/controllers.d.ts +4 -4
  26. package/dist/cjs/src/controllers.js +3 -0
  27. package/dist/cjs/src/controllers.js.map +1 -1
  28. package/dist/cjs/src/decorator.d.ts +29 -94
  29. package/dist/cjs/src/decorator.js +53 -118
  30. package/dist/cjs/src/decorator.js.map +1 -1
  31. package/dist/cjs/src/filter.d.ts +1 -0
  32. package/dist/cjs/src/filter.js +11 -17
  33. package/dist/cjs/src/filter.js.map +1 -1
  34. package/dist/cjs/src/http.d.ts +5 -3
  35. package/dist/cjs/src/http.js +91 -55
  36. package/dist/cjs/src/http.js.map +1 -1
  37. package/dist/cjs/src/kernel.d.ts +3 -3
  38. package/dist/cjs/src/kernel.js +5 -25
  39. package/dist/cjs/src/kernel.js.map +1 -1
  40. package/dist/cjs/src/logger.d.ts +2 -2
  41. package/dist/cjs/src/logger.js +4 -8
  42. package/dist/cjs/src/logger.js.map +1 -1
  43. package/dist/cjs/src/middleware.d.ts +5 -1
  44. package/dist/cjs/src/middleware.js +15 -3
  45. package/dist/cjs/src/middleware.js.map +1 -1
  46. package/dist/cjs/src/model.d.ts +69 -2
  47. package/dist/cjs/src/model.js +96 -25
  48. package/dist/cjs/src/model.js.map +1 -1
  49. package/dist/cjs/src/module.config.d.ts +3 -4
  50. package/dist/cjs/src/module.config.js +8 -6
  51. package/dist/cjs/src/module.config.js.map +1 -1
  52. package/dist/cjs/src/module.d.ts +2 -3
  53. package/dist/cjs/src/module.js +4 -2
  54. package/dist/cjs/src/module.js.map +1 -1
  55. package/dist/cjs/src/router.d.ts +25 -54
  56. package/dist/cjs/src/router.js +157 -175
  57. package/dist/cjs/src/router.js.map +1 -1
  58. package/dist/cjs/src/static-serving.d.ts +1 -0
  59. package/dist/cjs/src/static-serving.js +38 -34
  60. package/dist/cjs/src/static-serving.js.map +1 -1
  61. package/dist/cjs/src/utils.js +1 -0
  62. package/dist/cjs/tests/filter.spec.js +61 -47
  63. package/dist/cjs/tests/filter.spec.js.map +1 -1
  64. package/dist/cjs/tests/middleware.spec.d.ts +1 -1
  65. package/dist/cjs/tests/middleware.spec.js +157 -145
  66. package/dist/cjs/tests/middleware.spec.js.map +1 -1
  67. package/dist/cjs/tests/model.spec.js +4 -4
  68. package/dist/cjs/tests/model.spec.js.map +1 -1
  69. package/dist/cjs/tests/module.spec.js +4 -3
  70. package/dist/cjs/tests/module.spec.js.map +1 -1
  71. package/dist/cjs/tests/router.spec.d.ts +1 -1
  72. package/dist/cjs/tests/router.spec.js +311 -322
  73. package/dist/cjs/tests/router.spec.js.map +1 -1
  74. package/dist/cjs/tests/utils.js +5 -2
  75. package/dist/cjs/tests/utils.js.map +1 -1
  76. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  77. package/dist/esm/src/controllers.d.ts +4 -4
  78. package/dist/esm/src/controllers.js +3 -0
  79. package/dist/esm/src/controllers.js.map +1 -1
  80. package/dist/esm/src/decorator.d.ts +29 -94
  81. package/dist/esm/src/decorator.js +49 -114
  82. package/dist/esm/src/decorator.js.map +1 -1
  83. package/dist/esm/src/filter.d.ts +1 -0
  84. package/dist/esm/src/filter.js +11 -18
  85. package/dist/esm/src/filter.js.map +1 -1
  86. package/dist/esm/src/http.d.ts +5 -3
  87. package/dist/esm/src/http.js +89 -55
  88. package/dist/esm/src/http.js.map +1 -1
  89. package/dist/esm/src/kernel.d.ts +3 -3
  90. package/dist/esm/src/kernel.js +6 -27
  91. package/dist/esm/src/kernel.js.map +1 -1
  92. package/dist/esm/src/logger.d.ts +2 -2
  93. package/dist/esm/src/logger.js +4 -9
  94. package/dist/esm/src/logger.js.map +1 -1
  95. package/dist/esm/src/middleware.d.ts +5 -1
  96. package/dist/esm/src/middleware.js +12 -0
  97. package/dist/esm/src/middleware.js.map +1 -1
  98. package/dist/esm/src/model.d.ts +69 -2
  99. package/dist/esm/src/model.js +92 -24
  100. package/dist/esm/src/model.js.map +1 -1
  101. package/dist/esm/src/module.config.d.ts +3 -4
  102. package/dist/esm/src/module.config.js +6 -5
  103. package/dist/esm/src/module.config.js.map +1 -1
  104. package/dist/esm/src/module.d.ts +2 -3
  105. package/dist/esm/src/module.js +5 -3
  106. package/dist/esm/src/module.js.map +1 -1
  107. package/dist/esm/src/router.d.ts +25 -54
  108. package/dist/esm/src/router.js +154 -172
  109. package/dist/esm/src/router.js.map +1 -1
  110. package/dist/esm/src/static-serving.d.ts +1 -0
  111. package/dist/esm/src/static-serving.js +29 -25
  112. package/dist/esm/src/static-serving.js.map +1 -1
  113. package/dist/esm/src/utils.js +1 -0
  114. package/dist/esm/tests/filter.spec.js +14 -0
  115. package/dist/esm/tests/filter.spec.js.map +1 -1
  116. package/dist/esm/tests/middleware.spec.d.ts +1 -1
  117. package/dist/esm/tests/middleware.spec.js +60 -48
  118. package/dist/esm/tests/middleware.spec.js.map +1 -1
  119. package/dist/esm/tests/module.spec.js +1 -0
  120. package/dist/esm/tests/module.spec.js.map +1 -1
  121. package/dist/esm/tests/router.spec.d.ts +1 -1
  122. package/dist/esm/tests/router.spec.js +184 -195
  123. package/dist/esm/tests/router.spec.js.map +1 -1
  124. package/dist/esm/tests/utils.js +4 -1
  125. package/dist/esm/tests/utils.js.map +1 -1
  126. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  127. package/package.json +14 -15
  128. package/src/controllers.ts +3 -3
  129. package/src/decorator.ts +42 -131
  130. package/src/filter.ts +0 -2
  131. package/src/http.ts +35 -36
  132. package/src/kernel.ts +4 -5
  133. package/src/logger.ts +2 -4
  134. package/src/middleware.ts +2 -1
  135. package/src/model.ts +86 -8
  136. package/src/module.config.ts +3 -6
  137. package/src/module.ts +2 -2
  138. package/src/router.ts +143 -183
  139. package/src/static-serving.ts +2 -4
  140. package/tests/middleware.spec.ts +0 -1
  141. package/tests/router.spec.ts +152 -131
  142. 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,46 +332,77 @@ 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]);
337
352
  expect((await httpKernel.request(HttpRequest.POST('/').json({ username: 'Peter' }))).json).toEqual(['Peter', true, '/']);
338
353
  });
339
- test('router body double', async () => {
354
+ test('router body is safe for simultaneous requests', async () => {
340
355
  class Body {
341
356
  }
357
+ Body.__type = ['username', '&3!5'];
358
+ class Controller {
359
+ anyReq(body, req) {
360
+ return [body.username, body instanceof Body, req.url];
361
+ }
362
+ }
363
+ Controller.__type = [() => __ΩHttpBody, () => Body, 'body', () => HttpRequest, 'req', 'anyReq', 'PP7"o!"2#P7$2%"0&5'];
342
364
  __decorate([
343
- t,
344
- __metadata("design:type", String)
345
- ], Body.prototype, "username", void 0);
365
+ http.POST(),
366
+ __metadata("design:type", Function),
367
+ __metadata("design:paramtypes", [Object, HttpRequest]),
368
+ __metadata("design:returntype", void 0)
369
+ ], Controller.prototype, "anyReq", null);
370
+ const httpKernel = createHttpKernel([Controller]);
371
+ const makeReq = () => httpKernel.request(HttpRequest.POST('/').json({ username: 'Peter' }));
372
+ const results = await Promise.all([...new Array(100)].map(() => makeReq().then(Object.assign(res => res.json, { __type: ['res', '', 'P"2!"/"'] }))));
373
+ expect(results).toEqual(results.map(() => ['Peter', true, '/']));
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
+ });
392
+ test('router body double', async () => {
393
+ class Body {
394
+ }
395
+ Body.__type = ['username', '&3!5'];
346
396
  class Controller {
347
397
  anyReq(body, body2, req) {
348
398
  return [body2.username, body2 instanceof Body && body instanceof Body, req.url];
349
399
  }
350
400
  }
401
+ Controller.__type = [() => __ΩHttpBody, () => Body, 'body', () => __ΩHttpBody, () => Body, 'body2', () => HttpRequest, 'req', 'anyReq', 'PP7"o!"2#P7%o$"2&P7\'2("0)5'];
351
402
  __decorate([
352
403
  http.POST(),
353
- __param(0, http.body()),
354
- __param(1, http.body()),
355
404
  __metadata("design:type", Function),
356
- __metadata("design:paramtypes", [Body, Body, HttpRequest]),
405
+ __metadata("design:paramtypes", [Object, Object, HttpRequest]),
357
406
  __metadata("design:returntype", void 0)
358
407
  ], Controller.prototype, "anyReq", null);
359
408
  const httpData = httpClass._fetch(Controller);
@@ -362,10 +411,6 @@ test('router body double', async () => {
362
411
  const action = [...httpData.getActions()][0];
363
412
  expect(action.methodName).toBe('anyReq');
364
413
  expect(action.httpMethods).toEqual(['POST']);
365
- expect(action.parameters['body']).not.toBeUndefined();
366
- expect(action.parameters['body'].name).toBe('body');
367
- expect(action.parameters['body2']).not.toBeUndefined();
368
- expect(action.parameters['body2'].name).toBe('body2');
369
414
  const httpKernel = createHttpKernel([Controller]);
370
415
  expect((await httpKernel.request(HttpRequest.POST('/').json({ username: 'Peter' }))).json).toEqual(['Peter', true, '/']);
371
416
  });
@@ -379,6 +424,7 @@ test('router groups', async () => {
379
424
  c() {
380
425
  }
381
426
  }
427
+ Controller.__type = ['a', 'b', 'c', 'P"0!P"0"P"0#5'];
382
428
  __decorate([
383
429
  http.GET('a').group('a'),
384
430
  __metadata("design:type", Function),
@@ -413,6 +459,7 @@ test('router groups', async () => {
413
459
  c() {
414
460
  }
415
461
  };
462
+ Controller.__type = ['a', 'b', 'c', 'P"0!P"0"P"0#5'];
416
463
  __decorate([
417
464
  http.GET('a').group('a'),
418
465
  __metadata("design:type", Function),
@@ -448,11 +495,11 @@ test('router query', async () => {
448
495
  return test;
449
496
  }
450
497
  }
498
+ Controller.__type = [() => __ΩHttpQuery, 'test', 'anyReq', 'P\'o!"2"8"0#5'];
451
499
  __decorate([
452
500
  http.GET('my-action'),
453
- __param(0, http.query().optional),
454
501
  __metadata("design:type", Function),
455
- __metadata("design:paramtypes", [Number]),
502
+ __metadata("design:paramtypes", [Object]),
456
503
  __metadata("design:returntype", void 0)
457
504
  ], Controller.prototype, "anyReq", null);
458
505
  const httpData = httpClass._fetch(Controller);
@@ -461,9 +508,6 @@ test('router query', async () => {
461
508
  const action = [...httpData.getActions()][0];
462
509
  expect(action.methodName).toBe('anyReq');
463
510
  expect(action.httpMethods).toEqual(['GET']);
464
- expect(action.parameters['test']).not.toBeUndefined();
465
- expect(action.parameters['test'].name).toBe('test');
466
- expect(action.parameters['test'].type).toBe('query');
467
511
  const httpKernel = createHttpKernel([Controller]);
468
512
  expect((await httpKernel.request(HttpRequest.GET('/my-action?test=123'))).json).toEqual(123);
469
513
  expect((await httpKernel.request(HttpRequest.GET('/my-action'))).bodyString).toEqual('');
@@ -471,28 +515,17 @@ test('router query', async () => {
471
515
  test('router query all', async () => {
472
516
  class AnyReqQuery {
473
517
  }
474
- __decorate([
475
- t.optional,
476
- __metadata("design:type", String)
477
- ], AnyReqQuery.prototype, "test", void 0);
478
- __decorate([
479
- t.optional,
480
- __metadata("design:type", String)
481
- ], AnyReqQuery.prototype, "filter", void 0);
482
- __decorate([
483
- t.optional,
484
- __metadata("design:type", Number)
485
- ], AnyReqQuery.prototype, "page", void 0);
518
+ AnyReqQuery.__type = ['test', 'filter', 'page', '&3!8&3"8\'3#85'];
486
519
  class Controller {
487
520
  anyReq(anyReqQuery) {
488
521
  return anyReqQuery;
489
522
  }
490
523
  }
524
+ Controller.__type = [() => __ΩHttpQueries, () => AnyReqQuery, 'anyReqQuery', 'anyReq', 'PP7"o!"2#"0$5'];
491
525
  __decorate([
492
526
  http.GET('my-action'),
493
- __param(0, http.queries()),
494
527
  __metadata("design:type", Function),
495
- __metadata("design:paramtypes", [AnyReqQuery]),
528
+ __metadata("design:paramtypes", [Object]),
496
529
  __metadata("design:returntype", void 0)
497
530
  ], Controller.prototype, "anyReq", null);
498
531
  const httpKernel = createHttpKernel([Controller]);
@@ -503,25 +536,18 @@ test('router query all', async () => {
503
536
  test('serializer options', async () => {
504
537
  class User {
505
538
  }
506
- __decorate([
507
- t,
508
- __metadata("design:type", String)
509
- ], User.prototype, "username", void 0);
510
- __decorate([
511
- t.group('sensitive'),
512
- __metadata("design:type", String)
513
- ], User.prototype, "password", void 0);
539
+ User.__type = ['username', () => __ΩGroup, "sensitive", 'password', '&3!P&.#o""K3$5'];
514
540
  class Controller {
515
541
  anyReq() {
516
542
  return { username: 'Peter', password: 'secret' };
517
543
  }
518
544
  }
545
+ Controller.__type = [() => User, 'anyReq', 'PP7!0"5'];
519
546
  __decorate([
520
547
  http.GET().serialization({ groupsExclude: ['sensitive'] }),
521
- t.type(User),
522
548
  __metadata("design:type", Function),
523
549
  __metadata("design:paramtypes", []),
524
- __metadata("design:returntype", void 0)
550
+ __metadata("design:returntype", User)
525
551
  ], Controller.prototype, "anyReq", null);
526
552
  const httpKernel = createHttpKernel([Controller]);
527
553
  expect((await httpKernel.request(HttpRequest.GET('/'))).json).toEqual({ username: 'Peter' });
@@ -529,23 +555,16 @@ test('serializer options', async () => {
529
555
  test('hook after serializer', async () => {
530
556
  class User {
531
557
  }
532
- __decorate([
533
- t,
534
- __metadata("design:type", String)
535
- ], User.prototype, "username", void 0);
536
- __decorate([
537
- t.group('sensitive'),
538
- __metadata("design:type", String)
539
- ], User.prototype, "password", void 0);
558
+ User.__type = ['username', () => __ΩGroup, "sensitive", 'password', '&3!P&.#o""K3$5'];
540
559
  class Controller {
541
560
  async anyReq() {
542
561
  await sleep(0.1);
543
562
  return { username: 'Peter', password: 'secret' };
544
563
  }
545
564
  }
565
+ Controller.__type = [() => User, 'anyReq', 'PP7!`0"5'];
546
566
  __decorate([
547
567
  http.GET().serialization({ groupsExclude: ['sensitive'] }),
548
- t.type(User),
549
568
  __metadata("design:type", Function),
550
569
  __metadata("design:paramtypes", []),
551
570
  __metadata("design:returntype", Promise)
@@ -555,6 +574,7 @@ test('hook after serializer', async () => {
555
574
  event.result = { processingTime: event.controllerActionTime, data: event.result };
556
575
  }
557
576
  }
577
+ Listener.__type = [() => httpWorkflow.onResponse.event, 'event', 'onResponse', 'Pi!2""0#5'];
558
578
  __decorate([
559
579
  eventDispatcher.listen(httpWorkflow.onResponse),
560
580
  __metadata("design:type", Function),
@@ -571,6 +591,7 @@ test('invalid route definition', async () => {
571
591
  doIt(user) {
572
592
  }
573
593
  }
594
+ Controller.__type = ['user', 'doIt', 'P"2!"0"5'];
574
595
  __decorate([
575
596
  http.GET(),
576
597
  __metadata("design:type", Function),
@@ -578,7 +599,7 @@ test('invalid route definition', async () => {
578
599
  __metadata("design:returntype", void 0)
579
600
  ], Controller.prototype, "doIt", null);
580
601
  const httpKernel = createHttpKernel([Controller]);
581
- expect((await httpKernel.request(HttpRequest.GET('/'))).bodyString).toEqual('Not found');
602
+ expect((await httpKernel.request(HttpRequest.GET('/'))).bodyString).toEqual('Internal error');
582
603
  });
583
604
  test('inject request storage ClassType', async () => {
584
605
  class User {
@@ -586,6 +607,7 @@ test('inject request storage ClassType', async () => {
586
607
  this.username = username;
587
608
  }
588
609
  }
610
+ User.__type = ['username', 'constructor', 'P&2!:"0"5'];
589
611
  class Controller {
590
612
  doIt(user) {
591
613
  return { isUser: user instanceof User, username: user.username };
@@ -594,6 +616,7 @@ test('inject request storage ClassType', async () => {
594
616
  return { isUser: user instanceof User };
595
617
  }
596
618
  }
619
+ Controller.__type = [() => User, 'user', 'doIt', () => User, 'doItOptional', 'PP7!2""0#PP7$2"8"0%5'];
597
620
  __decorate([
598
621
  http.GET(),
599
622
  __metadata("design:type", Function),
@@ -602,7 +625,6 @@ test('inject request storage ClassType', async () => {
602
625
  ], Controller.prototype, "doIt", null);
603
626
  __decorate([
604
627
  http.GET('optional'),
605
- __param(0, inject().optional),
606
628
  __metadata("design:type", Function),
607
629
  __metadata("design:paramtypes", [User]),
608
630
  __metadata("design:returntype", void 0)
@@ -614,6 +636,7 @@ test('inject request storage ClassType', async () => {
614
636
  }
615
637
  }
616
638
  }
639
+ Listener.__type = [() => httpWorkflow.onAuth.event, 'event', 'onAuth', 'Pi!2""0#5'];
617
640
  __decorate([
618
641
  eventDispatcher.listen(httpWorkflow.onAuth),
619
642
  __metadata("design:type", Function),
@@ -622,55 +645,16 @@ test('inject request storage ClassType', async () => {
622
645
  ], Listener.prototype, "onAuth", null);
623
646
  const httpKernel = createHttpKernel([Controller], [
624
647
  {
625
- provide: User, scope: 'http', deps: [HttpRequest], useFactory(request) {
648
+ provide: User, scope: 'http',
649
+ useFactory: Object.assign(function useFactory(request) {
626
650
  return request.store.user;
627
- }
651
+ }, { __type: [() => HttpRequest, 'request', 'useFactory', 'PP7!2""/#'] })
628
652
  }
629
653
  ], [Listener]);
630
654
  expect((await httpKernel.request(HttpRequest.GET('/').headers({ authorization: 'yes' }))).json).toEqual({ isUser: true, username: 'bar' });
631
655
  expect((await httpKernel.request(HttpRequest.GET('/').headers({ authorization: 'no' }))).bodyString).toEqual('Internal error');
632
656
  expect((await httpKernel.request(HttpRequest.GET('/optional').headers({ authorization: 'no' }))).json).toEqual({ isUser: false });
633
657
  });
634
- test('inject request storage @inject', async () => {
635
- class User {
636
- constructor(username) {
637
- this.username = username;
638
- }
639
- }
640
- class Controller {
641
- doIt(user) {
642
- return { isUser: user instanceof User, username: user.username };
643
- }
644
- }
645
- __decorate([
646
- http.GET(),
647
- __param(0, inject('user')),
648
- __metadata("design:type", Function),
649
- __metadata("design:paramtypes", [Object]),
650
- __metadata("design:returntype", void 0)
651
- ], Controller.prototype, "doIt", null);
652
- class Listener {
653
- onAuth(event) {
654
- event.request.store.user = new User('bar');
655
- }
656
- }
657
- __decorate([
658
- eventDispatcher.listen(httpWorkflow.onAuth),
659
- __metadata("design:type", Function),
660
- __metadata("design:paramtypes", [Object]),
661
- __metadata("design:returntype", void 0)
662
- ], Listener.prototype, "onAuth", null);
663
- const httpKernel = createHttpKernel([Controller], [
664
- {
665
- provide: 'user', scope: 'http', deps: [HttpRequest], useFactory(request) {
666
- return request.store.user;
667
- }
668
- }
669
- ], [Listener]);
670
- const result = (await httpKernel.request(HttpRequest.GET('/'))).json;
671
- expect(result.isUser).toBe(true);
672
- expect(result.username).toBe('bar');
673
- });
674
658
  test('custom request handling', async () => {
675
659
  class Listener {
676
660
  onRouteNotFound(event) {
@@ -679,6 +663,7 @@ test('custom request handling', async () => {
679
663
  event.send(new JSONResponse(true, 200));
680
664
  }
681
665
  }
666
+ Listener.__type = [() => httpWorkflow.onRouteNotFound.event, 'event', 'onRouteNotFound', 'Pi!2""0#5'];
682
667
  __decorate([
683
668
  eventDispatcher.listen(httpWorkflow.onRouteNotFound),
684
669
  __metadata("design:type", Function),
@@ -698,6 +683,7 @@ test('race condition', async () => {
698
683
  call++;
699
684
  }
700
685
  }
686
+ Listener.__type = [() => httpWorkflow.onRouteNotFound.event, 'event', 'onRouteNotFound', 'Pi!2""0#5'];
701
687
  __decorate([
702
688
  eventDispatcher.listen(httpWorkflow.onAuth),
703
689
  __metadata("design:type", Function),
@@ -712,6 +698,7 @@ test('race condition', async () => {
712
698
  return param2;
713
699
  }
714
700
  }
701
+ Controller.__type = ['param1', 'one', 'param2', 'second', 'P&2!"0"P&2#"0$5'];
715
702
  __decorate([
716
703
  http.GET('/one/:param1'),
717
704
  __metadata("design:type", Function),
@@ -738,6 +725,7 @@ test('multiple methods', async () => {
738
725
  return true;
739
726
  }
740
727
  }
728
+ Controller.__type = ['one', 'P"0!5'];
741
729
  __decorate([
742
730
  http.GET('/one').POST(),
743
731
  __metadata("design:type", Function),
@@ -759,6 +747,7 @@ test('promise serializer', async () => {
759
747
  return 1;
760
748
  }
761
749
  }
750
+ Controller.__type = ['anyReq1', 'anyReq2', 'P"0!P&`0"5'];
762
751
  __decorate([
763
752
  http.GET('1'),
764
753
  __metadata("design:type", Function),
@@ -767,7 +756,6 @@ test('promise serializer', async () => {
767
756
  ], Controller.prototype, "anyReq1", null);
768
757
  __decorate([
769
758
  http.GET('2'),
770
- t.string,
771
759
  __metadata("design:type", Function),
772
760
  __metadata("design:paramtypes", []),
773
761
  __metadata("design:returntype", Promise)
@@ -782,18 +770,28 @@ test('unions', async () => {
782
770
  return page;
783
771
  }
784
772
  }
773
+ Controller.__type = [() => __ΩHttpQuery, 'page', 'list', 'PP\')Jo!"2""0#5'];
785
774
  __decorate([
786
775
  http.GET('/list'),
787
- __param(0, http.query()),
788
- __param(0, t.union(t.number, t.boolean)),
789
776
  __metadata("design:type", Function),
790
777
  __metadata("design:paramtypes", [Object]),
791
778
  __metadata("design:returntype", void 0)
792
779
  ], Controller.prototype, "list", null);
793
780
  const httpKernel = createHttpKernel([Controller]);
781
+ expect((await httpKernel.request(HttpRequest.GET('/list?page=0'))).json).toEqual(0);
794
782
  expect((await httpKernel.request(HttpRequest.GET('/list?page=1'))).json).toEqual(1);
795
783
  expect((await httpKernel.request(HttpRequest.GET('/list?page=2222'))).json).toEqual(2222);
796
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
+ });
797
795
  });
798
796
  test('router dotToUrlPath', () => {
799
797
  expect(dotToUrlPath('peter')).toBe('peter');
@@ -804,18 +802,7 @@ test('router dotToUrlPath', () => {
804
802
  test('router url resolve', async () => {
805
803
  class AnyReqQuery {
806
804
  }
807
- __decorate([
808
- t.optional,
809
- __metadata("design:type", String)
810
- ], AnyReqQuery.prototype, "test", void 0);
811
- __decorate([
812
- t.optional,
813
- __metadata("design:type", String)
814
- ], AnyReqQuery.prototype, "filter", void 0);
815
- __decorate([
816
- t.optional,
817
- __metadata("design:type", Number)
818
- ], AnyReqQuery.prototype, "page", void 0);
805
+ AnyReqQuery.__type = ['test', 'filter', 'page', '&3!8&3"8\'3#85'];
819
806
  class Controller {
820
807
  first() {
821
808
  return '';
@@ -836,6 +823,7 @@ test('router url resolve', async () => {
836
823
  return params;
837
824
  }
838
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'];
839
827
  __decorate([
840
828
  http.GET('').name('first'),
841
829
  __metadata("design:type", Function),
@@ -850,30 +838,26 @@ test('router url resolve', async () => {
850
838
  ], Controller.prototype, "second", null);
851
839
  __decorate([
852
840
  http.GET('').name('secondQuery'),
853
- __param(0, http.query()),
854
841
  __metadata("design:type", Function),
855
- __metadata("design:paramtypes", [String]),
842
+ __metadata("design:paramtypes", [Object]),
856
843
  __metadata("design:returntype", void 0)
857
844
  ], Controller.prototype, "secondQuery", null);
858
845
  __decorate([
859
846
  http.GET('').name('secondQuery2'),
860
- __param(0, http.query('changed')),
861
847
  __metadata("design:type", Function),
862
- __metadata("design:paramtypes", [String]),
848
+ __metadata("design:paramtypes", [Object]),
863
849
  __metadata("design:returntype", void 0)
864
850
  ], Controller.prototype, "secondQuery2", null);
865
851
  __decorate([
866
852
  http.GET('third').name('third'),
867
- __param(0, http.queries()),
868
853
  __metadata("design:type", Function),
869
- __metadata("design:paramtypes", [AnyReqQuery]),
854
+ __metadata("design:paramtypes", [Object]),
870
855
  __metadata("design:returntype", void 0)
871
856
  ], Controller.prototype, "third", null);
872
857
  __decorate([
873
858
  http.GET('third2').name('third2'),
874
- __param(0, http.queries('deep')),
875
859
  __metadata("design:type", Function),
876
- __metadata("design:paramtypes", [AnyReqQuery]),
860
+ __metadata("design:paramtypes", [Object]),
877
861
  __metadata("design:returntype", void 0)
878
862
  ], Controller.prototype, "third2", null);
879
863
  const router = Router.forControllers([Controller]);
@@ -889,76 +873,28 @@ test('router url resolve', async () => {
889
873
  expect(router.resolveUrl('third2', { params: { test: 123, filter: 'peter' } })).toBe('/third2?deep[test]=123&deep[filter]=peter');
890
874
  });
891
875
  test('destructing params', async () => {
892
- class DTO {
893
- }
894
- __decorate([
895
- t.required,
896
- __metadata("design:type", String)
897
- ], DTO.prototype, "name", void 0);
898
- __decorate([
899
- t.required,
900
- __metadata("design:type", String)
901
- ], DTO.prototype, "title", void 0);
876
+ var __ΩDTO = ['name', 'title', 'P&4!&4"M'];
902
877
  class Controller {
903
878
  first({ name, title }) {
904
879
  return [name, title];
905
880
  }
906
881
  }
882
+ Controller.__type = [() => __ΩHttpBody, () => __ΩDTO, 'param0', 'first', 'Pn"o!"2#"0$5'];
907
883
  __decorate([
908
884
  http.GET(''),
909
- __param(0, http.body()),
910
885
  __metadata("design:type", Function),
911
- __metadata("design:paramtypes", [DTO]),
886
+ __metadata("design:paramtypes", [Object]),
912
887
  __metadata("design:returntype", void 0)
913
888
  ], Controller.prototype, "first", null);
914
889
  const httpKernel = createHttpKernel([Controller]);
915
890
  expect((await httpKernel.request(HttpRequest.GET('/').json({ name: 'Peter', title: 'CTO' }))).json).toEqual(['Peter', 'CTO']);
916
891
  });
917
- test('dynamic parameter name', async () => {
918
- let Controller = class Controller {
919
- first(id) {
920
- return [id];
921
- }
922
- second(id, second) {
923
- return [id, second];
924
- }
925
- };
926
- __decorate([
927
- http.GET('first/:another'),
928
- __param(0, t.description('The identifier').name('another')),
929
- __metadata("design:type", Function),
930
- __metadata("design:paramtypes", [String]),
931
- __metadata("design:returntype", void 0)
932
- ], Controller.prototype, "first", null);
933
- __decorate([
934
- http.GET('second/:another2'),
935
- __param(0, t.description('The identifier').name('another2')),
936
- __param(1, http.query()),
937
- __metadata("design:type", Function),
938
- __metadata("design:paramtypes", [String, String]),
939
- __metadata("design:returntype", void 0)
940
- ], Controller.prototype, "second", null);
941
- Controller = __decorate([
942
- http.controller()
943
- ], Controller);
944
- const schema = getClassSchema(Controller);
945
- expect(schema.getMethodProperties('first')[0].name).toBe('another');
946
- expect(schema.getMethodProperties('second')[0].name).toBe('another2');
947
- expect(schema.getMethodProperties('second')[1].name).toBe('second');
948
- const httpKernel = createHttpKernel([Controller]);
949
- expect((await httpKernel.request(HttpRequest.GET('/first/peter'))).json).toEqual(['peter']);
950
- expect((await httpKernel.request(HttpRequest.GET('/second/peter?second=true'))).json).toEqual(['peter', 'true']);
951
- });
952
892
  test('use http.response for serialization', async () => {
953
- const schemaString = t.schema({
954
- title: t.string
955
- });
956
- const errorSchema = t.schema({
957
- message: t.string
958
- });
893
+ var __ΩDefaultResponse = ['title', 'P&4!M'];
894
+ var __ΩErrorResponse = ['message', 'P&4!M'];
959
895
  class Controller {
960
896
  action1() {
961
- return [{ title: 'a' }, { title: 1 }];
897
+ return [{ title: 'a' }, { title: '1' }];
962
898
  }
963
899
  action2() {
964
900
  return [{ title: 'a' }, { title: 1 }];
@@ -967,23 +903,23 @@ test('use http.response for serialization', async () => {
967
903
  return new JSONResponse([{ message: 'error' }, { message: 1 }]).status(400);
968
904
  }
969
905
  }
906
+ Controller.__type = [() => __ΩDefaultResponse, 'action1', 'action2', 'action3', 'Pn!F0"P"0#P"0$5'];
970
907
  __decorate([
971
908
  http.GET('/action1'),
972
- t.array(schemaString),
973
909
  __metadata("design:type", Function),
974
910
  __metadata("design:paramtypes", []),
975
- __metadata("design:returntype", void 0)
911
+ __metadata("design:returntype", Array)
976
912
  ], Controller.prototype, "action1", null);
977
913
  __decorate([
978
- http.GET('/action2').response(200, `List`, t.array(schemaString)),
914
+ http.GET('/action2').response(200, `List`, [() => __ΩDefaultResponse, 'n!F']),
979
915
  __metadata("design:type", Function),
980
916
  __metadata("design:paramtypes", []),
981
917
  __metadata("design:returntype", void 0)
982
918
  ], Controller.prototype, "action2", null);
983
919
  __decorate([
984
920
  http.GET('/action3')
985
- .response(200, `List`, t.array(schemaString))
986
- .response(400, `Error`, t.array(errorSchema)),
921
+ .response(200, `List`, [() => __ΩDefaultResponse, 'n!F'])
922
+ .response(400, `Error`, [() => __ΩErrorResponse, 'n!F']),
987
923
  __metadata("design:type", Function),
988
924
  __metadata("design:paramtypes", []),
989
925
  __metadata("design:returntype", void 0)
@@ -993,4 +929,57 @@ test('use http.response for serialization', async () => {
993
929
  expect((await httpKernel.request(HttpRequest.GET('/action2'))).json).toEqual([{ title: 'a' }, { title: '1' }]);
994
930
  expect((await httpKernel.request(HttpRequest.GET('/action3'))).json).toEqual([{ message: 'error' }, { message: '1' }]);
995
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
+ });
996
985
  //# sourceMappingURL=router.spec.js.map