@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
@@ -8,22 +8,24 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ var { __ΩHttpRegExp } = require('../src/model');
13
+ var { __ΩRouteParameterResolverContext } = require('../src/router');
14
+ var { __ΩHttpBody } = require('../src/model');
15
+ var { __ΩHttpQuery } = require('../src/model');
16
+ var { __ΩHttpQueries } = require('../src/model');
17
+ var { __ΩGroup } = require('@deepkit/type');
18
+ var { __ΩMinLength } = require('@deepkit/type');
19
+ var { __ΩHttpBodyValidation } = require('../src/model');
15
20
  const globals_1 = require("@jest/globals");
16
- require("reflect-metadata");
17
21
  const router_1 = require("../src/router");
18
22
  const decorator_1 = require("../src/decorator");
19
- const type_1 = require("@deepkit/type");
20
23
  const http_1 = require("../src/http");
21
24
  const event_1 = require("@deepkit/event");
22
- const injector_1 = require("@deepkit/injector");
23
25
  const model_1 = require("../src/model");
24
26
  const core_1 = require("@deepkit/core");
25
27
  const utils_1 = require("./utils");
26
- globals_1.test('router', async () => {
28
+ (0, globals_1.test)('router', async () => {
27
29
  var _a, _b, _c;
28
30
  class Controller {
29
31
  helloWorld() {
@@ -37,6 +39,7 @@ globals_1.test('router', async () => {
37
39
  any() {
38
40
  }
39
41
  }
42
+ 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'];
40
43
  __decorate([
41
44
  decorator_1.http.GET(),
42
45
  __metadata("design:type", Function),
@@ -68,21 +71,22 @@ globals_1.test('router', async () => {
68
71
  __metadata("design:returntype", void 0)
69
72
  ], Controller.prototype, "any", null);
70
73
  const router = router_1.Router.forControllers([Controller]);
71
- globals_1.expect((_a = (await router.resolve('GET', '/'))) === null || _a === void 0 ? void 0 : _a.routeConfig.action).toMatchObject({ controller: Controller, methodName: 'helloWorld' });
72
- globals_1.expect((_b = (await router.resolve('GET', '/peter'))) === null || _b === void 0 ? void 0 : _b.routeConfig.action).toMatchObject({ controller: Controller, methodName: 'hello' });
73
- globals_1.expect((_c = (await router.resolve('GET', '/peter'))) === null || _c === void 0 ? void 0 : _c.parameters(undefined)).toEqual(['peter']);
74
+ (0, globals_1.expect)((_a = (await router.resolve('GET', '/'))) === null || _a === void 0 ? void 0 : _a.routeConfig.action).toMatchObject({ controller: Controller, methodName: 'helloWorld' });
75
+ (0, globals_1.expect)((_b = (await router.resolve('GET', '/peter'))) === null || _b === void 0 ? void 0 : _b.routeConfig.action).toMatchObject({ controller: Controller, methodName: 'hello' });
76
+ (0, globals_1.expect)((_c = (await router.resolve('GET', '/peter'))) === null || _c === void 0 ? void 0 : _c.parameters(undefined)).toEqual(['peter']);
74
77
  const userStatic = await router.resolve('GET', '/user/1233/static');
75
- globals_1.expect(userStatic === null || userStatic === void 0 ? void 0 : userStatic.routeConfig.action).toMatchObject({ controller: Controller, methodName: 'userStatic' });
76
- globals_1.expect(userStatic === null || userStatic === void 0 ? void 0 : userStatic.parameters(undefined)).toEqual(['1233']);
78
+ (0, globals_1.expect)(userStatic === null || userStatic === void 0 ? void 0 : userStatic.routeConfig.action).toMatchObject({ controller: Controller, methodName: 'userStatic' });
79
+ (0, globals_1.expect)(userStatic === null || userStatic === void 0 ? void 0 : userStatic.parameters(undefined)).toEqual(['1233']);
77
80
  const userStatic2 = await router.resolve('GET', '/user2/1233/static/123');
78
- globals_1.expect(userStatic2 === null || userStatic2 === void 0 ? void 0 : userStatic2.routeConfig.action).toMatchObject({ controller: Controller, methodName: 'userStatic2' });
79
- globals_1.expect(userStatic2 === null || userStatic2 === void 0 ? void 0 : userStatic2.parameters(undefined)).toEqual(['1233', '123']);
81
+ (0, globals_1.expect)(userStatic2 === null || userStatic2 === void 0 ? void 0 : userStatic2.routeConfig.action).toMatchObject({ controller: Controller, methodName: 'userStatic2' });
82
+ (0, globals_1.expect)(userStatic2 === null || userStatic2 === void 0 ? void 0 : userStatic2.parameters(undefined)).toEqual(['1233', '123']);
80
83
  });
81
- globals_1.test('any', async () => {
84
+ (0, globals_1.test)('any', async () => {
82
85
  class Controller {
83
86
  any() {
84
87
  }
85
88
  }
89
+ Controller.__type = ['any', 'P"0!5'];
86
90
  __decorate([
87
91
  decorator_1.http.ANY('/any'),
88
92
  __metadata("design:type", Function),
@@ -90,11 +94,11 @@ globals_1.test('any', async () => {
90
94
  __metadata("design:returntype", void 0)
91
95
  ], Controller.prototype, "any", null);
92
96
  const router = router_1.Router.forControllers([Controller]);
93
- globals_1.expect((await router.resolve('GET', '/any')).routeConfig.action.methodName).toEqual('any');
94
- globals_1.expect((await router.resolve('POST', '/any')).routeConfig.action.methodName).toEqual('any');
95
- globals_1.expect((await router.resolve('OPTIONS', '/any')).routeConfig.action.methodName).toEqual('any');
97
+ (0, globals_1.expect)((await router.resolve('GET', '/any')).routeConfig.action.methodName).toEqual('any');
98
+ (0, globals_1.expect)((await router.resolve('POST', '/any')).routeConfig.action.methodName).toEqual('any');
99
+ (0, globals_1.expect)((await router.resolve('OPTIONS', '/any')).routeConfig.action.methodName).toEqual('any');
96
100
  });
97
- globals_1.test('router parameters', async () => {
101
+ (0, globals_1.test)('router parameters', async () => {
98
102
  var _a;
99
103
  class Controller {
100
104
  string(name) {
@@ -110,6 +114,7 @@ globals_1.test('router parameters', async () => {
110
114
  return new http_1.JSONResponse(path);
111
115
  }
112
116
  }
117
+ 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'];
113
118
  __decorate([
114
119
  decorator_1.http.GET('/user/:name'),
115
120
  __metadata("design:type", Function),
@@ -129,48 +134,51 @@ globals_1.test('router parameters', async () => {
129
134
  __metadata("design:returntype", void 0)
130
135
  ], Controller.prototype, "boolean", null);
131
136
  __decorate([
132
- decorator_1.http.GET(':path').regexp('path', '.*'),
137
+ decorator_1.http.GET(':path'),
133
138
  __metadata("design:type", Function),
134
- __metadata("design:paramtypes", [String]),
139
+ __metadata("design:paramtypes", [Object]),
135
140
  __metadata("design:returntype", void 0)
136
141
  ], Controller.prototype, "any", null);
137
142
  const router = router_1.Router.forControllers([Controller]);
138
- globals_1.expect((_a = (await router.resolve('GET', '/user/peter'))) === null || _a === void 0 ? void 0 : _a.routeConfig.action).toMatchObject({ controller: Controller, methodName: 'string' });
139
- const httpKernel = utils_1.createHttpKernel([Controller]);
140
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/user/peter'))).json).toBe('peter');
141
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/user-id/123'))).json).toBe(123);
142
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/user-id/asd'))).json).toMatchObject({ message: 'Validation failed: id(invalid_number): No valid number given, got NaN' });
143
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/boolean/1'))).json).toBe(true);
144
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/boolean/false'))).json).toBe(false);
145
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/any'))).json).toBe('any');
146
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/any/path'))).json).toBe('any/path');
143
+ (0, globals_1.expect)((_a = (await router.resolve('GET', '/user/peter'))) === null || _a === void 0 ? void 0 : _a.routeConfig.action).toMatchObject({ controller: Controller, methodName: 'string' });
144
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
145
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/user/peter'))).json).toBe('peter');
146
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/user-id/123'))).json).toBe(123);
147
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/user-id/asd'))).json).toMatchObject({ message: 'Validation error:\nid(type): Cannot convert asd to number' });
148
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/boolean/1'))).json).toBe(true);
149
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/boolean/false'))).json).toBe(false);
150
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/any'))).json).toBe('any');
151
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/any/path'))).json).toBe('any/path');
147
152
  });
148
- globals_1.test('router HttpRequest', async () => {
153
+ (0, globals_1.test)('router HttpRequest', async () => {
149
154
  class Controller {
150
155
  anyReq(req, path) {
151
156
  return [req.url, path];
152
157
  }
153
158
  }
159
+ Controller.__type = [() => model_1.HttpRequest, 'req', () => __ΩHttpRegExp, ".*", 'path', 'anyReq', 'PP7!2"&.$o##2%"0&5'];
154
160
  __decorate([
155
- decorator_1.http.GET(':path').regexp('path', '.*'),
161
+ decorator_1.http.GET(':path'),
156
162
  __metadata("design:type", Function),
157
- __metadata("design:paramtypes", [model_1.HttpRequest, String]),
163
+ __metadata("design:paramtypes", [model_1.HttpRequest, Object]),
158
164
  __metadata("design:returntype", void 0)
159
165
  ], Controller.prototype, "anyReq", null);
160
- const httpKernel = utils_1.createHttpKernel([Controller]);
161
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/req/any/path'))).json).toEqual(['/req/any/path', 'req/any/path']);
166
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
167
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/req/any/path'))).json).toEqual(['/req/any/path', 'req/any/path']);
162
168
  });
163
- globals_1.test('router parameter resolver by class', async () => {
169
+ (0, globals_1.test)('router parameter resolver by class', async () => {
164
170
  class User {
165
171
  constructor(username) {
166
172
  this.username = username;
167
173
  }
168
174
  }
175
+ User.__type = ['username', 'constructor', 'P&2!:"0"5'];
169
176
  class Group {
170
177
  constructor(name) {
171
178
  this.name = name;
172
179
  }
173
180
  }
181
+ Group.__type = ['name', 'constructor', 'P&2!:"0"5'];
174
182
  class UserResolver {
175
183
  resolve(context) {
176
184
  const value = context.value || context.parameters.username;
@@ -179,6 +187,7 @@ globals_1.test('router parameter resolver by class', async () => {
179
187
  return new User(value);
180
188
  }
181
189
  }
190
+ UserResolver.__type = [() => __ΩRouteParameterResolverContext, 'context', 'resolve', 'Pn!2"P""`J0#5'];
182
191
  class GroupResolver {
183
192
  resolve(context) {
184
193
  if (!context.value)
@@ -186,6 +195,7 @@ globals_1.test('router parameter resolver by class', async () => {
186
195
  return new Group(context.value);
187
196
  }
188
197
  }
198
+ GroupResolver.__type = [() => __ΩRouteParameterResolverContext, 'context', 'resolve', 'Pn!2"P""`J0#5'];
189
199
  let Controller = class Controller {
190
200
  route1(user) {
191
201
  return [user.username];
@@ -197,6 +207,7 @@ globals_1.test('router parameter resolver by class', async () => {
197
207
  return [user.username, group.name];
198
208
  }
199
209
  };
210
+ Controller.__type = [() => User, 'user', 'route1', () => User, 'route2', () => User, () => Group, 'group', 'route3', 'PP7!2""0#PP7$2""0%PP7&2"P7\'2("0)5'];
200
211
  __decorate([
201
212
  decorator_1.http.GET('user/:username'),
202
213
  __metadata("design:type", Function),
@@ -219,26 +230,28 @@ globals_1.test('router parameter resolver by class', async () => {
219
230
  decorator_1.http.resolveParameter(User, UserResolver)
220
231
  ], Controller);
221
232
  const data = decorator_1.httpClass._fetch(Controller);
222
- globals_1.expect(data.getActions().size).toBe(3);
223
- globals_1.expect(data.resolverForToken.get(User)).toBe(UserResolver);
224
- globals_1.expect(data.resolverForToken.get(User)).toBe(UserResolver);
225
- globals_1.expect(data.getAction('route3').resolverForToken.get(Group)).toBe(GroupResolver);
226
- const httpKernel = utils_1.createHttpKernel([Controller], [UserResolver, GroupResolver]);
227
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/user/peter'))).json).toEqual(['peter']);
228
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/user/peter/group/a'))).json).toEqual(['peter', 'a']);
229
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/invalid'))).bodyString).toEqual('Internal error');
233
+ (0, globals_1.expect)(data.getActions().size).toBe(3);
234
+ (0, globals_1.expect)(data.resolverForToken.get(User)).toBe(UserResolver);
235
+ (0, globals_1.expect)(data.resolverForToken.get(User)).toBe(UserResolver);
236
+ (0, globals_1.expect)(data.getAction('route3').resolverForToken.get(Group)).toBe(GroupResolver);
237
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller], [UserResolver, GroupResolver]);
238
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/user/peter'))).json).toEqual(['peter']);
239
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/user/peter/group/a'))).json).toEqual(['peter', 'a']);
240
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/invalid'))).bodyString).toEqual('Internal error');
230
241
  });
231
- globals_1.test('router parameter resolver by name', async () => {
242
+ (0, globals_1.test)('router parameter resolver by name', async () => {
232
243
  class User {
233
244
  constructor(username) {
234
245
  this.username = username;
235
246
  }
236
247
  }
248
+ User.__type = ['username', 'constructor', 'P&2!:"0"5'];
237
249
  class Group {
238
250
  constructor(name) {
239
251
  this.name = name;
240
252
  }
241
253
  }
254
+ Group.__type = ['name', 'constructor', 'P&2!:"0"5'];
242
255
  class UserResolver {
243
256
  resolve(context) {
244
257
  const value = context.value || context.parameters.username;
@@ -248,6 +261,7 @@ globals_1.test('router parameter resolver by name', async () => {
248
261
  return new User(value);
249
262
  }
250
263
  }
264
+ UserResolver.__type = [() => __ΩRouteParameterResolverContext, 'context', 'resolve', 'Pn!2"P""`J0#5'];
251
265
  class GroupResolver {
252
266
  resolve(context) {
253
267
  if (!context.value)
@@ -255,16 +269,19 @@ globals_1.test('router parameter resolver by name', async () => {
255
269
  return new Group(context.value);
256
270
  }
257
271
  }
272
+ GroupResolver.__type = [() => __ΩRouteParameterResolverContext, 'context', 'resolve', 'Pn!2"P""`J0#5'];
258
273
  class MyAuth {
259
274
  constructor(name) {
260
275
  this.name = name;
261
276
  }
262
277
  }
278
+ MyAuth.__type = ['name', 'constructor', 'P&2!:"0"5'];
263
279
  class AuthResolver {
264
280
  resolve(context) {
265
281
  return new MyAuth('auth');
266
282
  }
267
283
  }
284
+ AuthResolver.__type = [() => __ΩRouteParameterResolverContext, 'context', 'resolve', 'Pn!2"P""`J0#5'];
268
285
  let Controller = class Controller {
269
286
  route1(user) {
270
287
  return [user.username];
@@ -276,9 +293,10 @@ globals_1.test('router parameter resolver by name', async () => {
276
293
  return [user.username, group.name];
277
294
  }
278
295
  nonClass(auth) {
279
- return [auth.name, core_1.getClassName(auth)];
296
+ return [auth.name, (0, core_1.getClassName)(auth)];
280
297
  }
281
298
  };
299
+ 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'];
282
300
  __decorate([
283
301
  decorator_1.http.GET('user/:username'),
284
302
  __metadata("design:type", Function),
@@ -307,71 +325,98 @@ globals_1.test('router parameter resolver by name', async () => {
307
325
  decorator_1.http.resolveParameterByName('user', UserResolver)
308
326
  ], Controller);
309
327
  const data = decorator_1.httpClass._fetch(Controller);
310
- globals_1.expect(data.getActions().size).toBe(4);
311
- globals_1.expect(data.resolverForParameterName.get('user')).toBe(UserResolver);
312
- globals_1.expect(data.getAction('route3').resolverForParameterName.get('group')).toBe(GroupResolver);
313
- const httpKernel = utils_1.createHttpKernel([Controller], [UserResolver, GroupResolver, AuthResolver]);
314
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/user/peter'))).json).toEqual(['peter']);
315
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/user/peter/group/a'))).json).toEqual(['peter', 'a']);
316
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/invalid'))).bodyString).toEqual('Internal error');
317
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/nonClass'))).json).toEqual(['auth', 'MyAuth']);
328
+ (0, globals_1.expect)(data.getActions().size).toBe(4);
329
+ (0, globals_1.expect)(data.resolverForParameterName.get('user')).toBe(UserResolver);
330
+ (0, globals_1.expect)(data.getAction('route3').resolverForParameterName.get('group')).toBe(GroupResolver);
331
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller], [UserResolver, GroupResolver, AuthResolver]);
332
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/user/peter'))).json).toEqual(['peter']);
333
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/user/peter/group/a'))).json).toEqual(['peter', 'a']);
334
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/invalid'))).bodyString).toEqual('Internal error');
335
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/nonClass'))).json).toEqual(['auth', 'MyAuth']);
318
336
  });
319
- globals_1.test('router body', async () => {
337
+ (0, globals_1.test)('router body class', async () => {
320
338
  class Body {
321
339
  }
322
- __decorate([
323
- type_1.t,
324
- __metadata("design:type", String)
325
- ], Body.prototype, "username", void 0);
340
+ Body.__type = ['username', '&3!5'];
326
341
  class Controller {
327
342
  anyReq(body, req) {
328
343
  return [body.username, body instanceof Body, req.url];
329
344
  }
330
345
  }
346
+ Controller.__type = [() => __ΩHttpBody, () => Body, 'body', () => model_1.HttpRequest, 'req', 'anyReq', 'PP7"o!"2#P7$2%"0&5'];
331
347
  __decorate([
332
348
  decorator_1.http.POST(),
333
- __param(0, decorator_1.http.body()),
334
349
  __metadata("design:type", Function),
335
- __metadata("design:paramtypes", [Body, model_1.HttpRequest]),
350
+ __metadata("design:paramtypes", [Object, model_1.HttpRequest]),
336
351
  __metadata("design:returntype", void 0)
337
352
  ], Controller.prototype, "anyReq", null);
338
- const httpKernel = utils_1.createHttpKernel([Controller]);
339
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.POST('/').json({ username: 'Peter' }))).json).toEqual(['Peter', true, '/']);
353
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
354
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.POST('/').json({ username: 'Peter' }))).json).toEqual(['Peter', true, '/']);
340
355
  });
341
- globals_1.test('router body double', async () => {
356
+ (0, globals_1.test)('router body is safe for simultaneous requests', async () => {
342
357
  class Body {
343
358
  }
359
+ Body.__type = ['username', '&3!5'];
360
+ class Controller {
361
+ anyReq(body, req) {
362
+ return [body.username, body instanceof Body, req.url];
363
+ }
364
+ }
365
+ Controller.__type = [() => __ΩHttpBody, () => Body, 'body', () => model_1.HttpRequest, 'req', 'anyReq', 'PP7"o!"2#P7$2%"0&5'];
344
366
  __decorate([
345
- type_1.t,
346
- __metadata("design:type", String)
347
- ], Body.prototype, "username", void 0);
367
+ decorator_1.http.POST(),
368
+ __metadata("design:type", Function),
369
+ __metadata("design:paramtypes", [Object, model_1.HttpRequest]),
370
+ __metadata("design:returntype", void 0)
371
+ ], Controller.prototype, "anyReq", null);
372
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
373
+ const makeReq = () => httpKernel.request(model_1.HttpRequest.POST('/').json({ username: 'Peter' }));
374
+ const results = await Promise.all([...new Array(100)].map(() => makeReq().then(Object.assign(res => res.json, { __type: ['res', '', 'P"2!"/"'] }))));
375
+ (0, globals_1.expect)(results).toEqual(results.map(() => ['Peter', true, '/']));
376
+ });
377
+ (0, globals_1.test)('router body interface', async () => {
378
+ var __ΩBody = ['username', 'P&4!M'];
379
+ class Controller {
380
+ anyReq(body, req) {
381
+ return [body.username, typeof body.username, req.url];
382
+ }
383
+ }
384
+ Controller.__type = [() => __ΩHttpBody, () => __ΩBody, 'body', () => model_1.HttpRequest, 'req', 'anyReq', 'Pn"o!"2#P7$2%"0&5'];
385
+ __decorate([
386
+ decorator_1.http.POST(),
387
+ __metadata("design:type", Function),
388
+ __metadata("design:paramtypes", [Object, model_1.HttpRequest]),
389
+ __metadata("design:returntype", void 0)
390
+ ], Controller.prototype, "anyReq", null);
391
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
392
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.POST('/').json({ username: 'Peter' }))).json).toEqual(['Peter', 'string', '/']);
393
+ });
394
+ (0, globals_1.test)('router body double', async () => {
395
+ class Body {
396
+ }
397
+ Body.__type = ['username', '&3!5'];
348
398
  class Controller {
349
399
  anyReq(body, body2, req) {
350
400
  return [body2.username, body2 instanceof Body && body instanceof Body, req.url];
351
401
  }
352
402
  }
403
+ Controller.__type = [() => __ΩHttpBody, () => Body, 'body', () => __ΩHttpBody, () => Body, 'body2', () => model_1.HttpRequest, 'req', 'anyReq', 'PP7"o!"2#P7%o$"2&P7\'2("0)5'];
353
404
  __decorate([
354
405
  decorator_1.http.POST(),
355
- __param(0, decorator_1.http.body()),
356
- __param(1, decorator_1.http.body()),
357
406
  __metadata("design:type", Function),
358
- __metadata("design:paramtypes", [Body, Body, model_1.HttpRequest]),
407
+ __metadata("design:paramtypes", [Object, Object, model_1.HttpRequest]),
359
408
  __metadata("design:returntype", void 0)
360
409
  ], Controller.prototype, "anyReq", null);
361
410
  const httpData = decorator_1.httpClass._fetch(Controller);
362
411
  if (!httpData)
363
412
  throw new Error('httpClass undefined');
364
413
  const action = [...httpData.getActions()][0];
365
- globals_1.expect(action.methodName).toBe('anyReq');
366
- globals_1.expect(action.httpMethods).toEqual(['POST']);
367
- globals_1.expect(action.parameters['body']).not.toBeUndefined();
368
- globals_1.expect(action.parameters['body'].name).toBe('body');
369
- globals_1.expect(action.parameters['body2']).not.toBeUndefined();
370
- globals_1.expect(action.parameters['body2'].name).toBe('body2');
371
- const httpKernel = utils_1.createHttpKernel([Controller]);
372
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.POST('/').json({ username: 'Peter' }))).json).toEqual(['Peter', true, '/']);
414
+ (0, globals_1.expect)(action.methodName).toBe('anyReq');
415
+ (0, globals_1.expect)(action.httpMethods).toEqual(['POST']);
416
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
417
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.POST('/').json({ username: 'Peter' }))).json).toEqual(['Peter', true, '/']);
373
418
  });
374
- globals_1.test('router groups', async () => {
419
+ (0, globals_1.test)('router groups', async () => {
375
420
  {
376
421
  class Controller {
377
422
  a() {
@@ -381,6 +426,7 @@ globals_1.test('router groups', async () => {
381
426
  c() {
382
427
  }
383
428
  }
429
+ Controller.__type = ['a', 'b', 'c', 'P"0!P"0"P"0#5'];
384
430
  __decorate([
385
431
  decorator_1.http.GET('a').group('a'),
386
432
  __metadata("design:type", Function),
@@ -402,9 +448,9 @@ globals_1.test('router groups', async () => {
402
448
  const httpData = decorator_1.httpClass._fetch(Controller);
403
449
  if (!httpData)
404
450
  throw new Error('httpClass undefined');
405
- globals_1.expect(httpData.getAction('a').groups).toEqual(['a']);
406
- globals_1.expect(httpData.getAction('b').groups).toEqual([]);
407
- globals_1.expect(httpData.getAction('c').groups).toEqual(['c']);
451
+ (0, globals_1.expect)(httpData.getAction('a').groups).toEqual(['a']);
452
+ (0, globals_1.expect)(httpData.getAction('b').groups).toEqual([]);
453
+ (0, globals_1.expect)(httpData.getAction('c').groups).toEqual(['c']);
408
454
  }
409
455
  {
410
456
  let Controller = class Controller {
@@ -415,6 +461,7 @@ globals_1.test('router groups', async () => {
415
461
  c() {
416
462
  }
417
463
  };
464
+ Controller.__type = ['a', 'b', 'c', 'P"0!P"0"P"0#5'];
418
465
  __decorate([
419
466
  decorator_1.http.GET('a').group('a'),
420
467
  __metadata("design:type", Function),
@@ -439,115 +486,87 @@ globals_1.test('router groups', async () => {
439
486
  const httpData = decorator_1.httpClass._fetch(Controller);
440
487
  if (!httpData)
441
488
  throw new Error('httpClass undefined');
442
- globals_1.expect(httpData.getAction('a').groups).toEqual(['a', 'all']);
443
- globals_1.expect(httpData.getAction('b').groups).toEqual(['all']);
444
- globals_1.expect(httpData.getAction('c').groups).toEqual(['c', 'all']);
489
+ (0, globals_1.expect)(httpData.getAction('a').groups).toEqual(['a', 'all']);
490
+ (0, globals_1.expect)(httpData.getAction('b').groups).toEqual(['all']);
491
+ (0, globals_1.expect)(httpData.getAction('c').groups).toEqual(['c', 'all']);
445
492
  }
446
493
  });
447
- globals_1.test('router query', async () => {
494
+ (0, globals_1.test)('router query', async () => {
448
495
  class Controller {
449
496
  anyReq(test) {
450
497
  return test;
451
498
  }
452
499
  }
500
+ Controller.__type = [() => __ΩHttpQuery, 'test', 'anyReq', 'P\'o!"2"8"0#5'];
453
501
  __decorate([
454
502
  decorator_1.http.GET('my-action'),
455
- __param(0, decorator_1.http.query().optional),
456
503
  __metadata("design:type", Function),
457
- __metadata("design:paramtypes", [Number]),
504
+ __metadata("design:paramtypes", [Object]),
458
505
  __metadata("design:returntype", void 0)
459
506
  ], Controller.prototype, "anyReq", null);
460
507
  const httpData = decorator_1.httpClass._fetch(Controller);
461
508
  if (!httpData)
462
509
  throw new Error('httpClass undefined');
463
510
  const action = [...httpData.getActions()][0];
464
- globals_1.expect(action.methodName).toBe('anyReq');
465
- globals_1.expect(action.httpMethods).toEqual(['GET']);
466
- globals_1.expect(action.parameters['test']).not.toBeUndefined();
467
- globals_1.expect(action.parameters['test'].name).toBe('test');
468
- globals_1.expect(action.parameters['test'].type).toBe('query');
469
- const httpKernel = utils_1.createHttpKernel([Controller]);
470
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/my-action?test=123'))).json).toEqual(123);
471
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/my-action'))).bodyString).toEqual('');
511
+ (0, globals_1.expect)(action.methodName).toBe('anyReq');
512
+ (0, globals_1.expect)(action.httpMethods).toEqual(['GET']);
513
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
514
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/my-action?test=123'))).json).toEqual(123);
515
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/my-action'))).bodyString).toEqual('');
472
516
  });
473
- globals_1.test('router query all', async () => {
517
+ (0, globals_1.test)('router query all', async () => {
474
518
  class AnyReqQuery {
475
519
  }
476
- __decorate([
477
- type_1.t.optional,
478
- __metadata("design:type", String)
479
- ], AnyReqQuery.prototype, "test", void 0);
480
- __decorate([
481
- type_1.t.optional,
482
- __metadata("design:type", String)
483
- ], AnyReqQuery.prototype, "filter", void 0);
484
- __decorate([
485
- type_1.t.optional,
486
- __metadata("design:type", Number)
487
- ], AnyReqQuery.prototype, "page", void 0);
520
+ AnyReqQuery.__type = ['test', 'filter', 'page', '&3!8&3"8\'3#85'];
488
521
  class Controller {
489
522
  anyReq(anyReqQuery) {
490
523
  return anyReqQuery;
491
524
  }
492
525
  }
526
+ Controller.__type = [() => __ΩHttpQueries, () => AnyReqQuery, 'anyReqQuery', 'anyReq', 'PP7"o!"2#"0$5'];
493
527
  __decorate([
494
528
  decorator_1.http.GET('my-action'),
495
- __param(0, decorator_1.http.queries()),
496
529
  __metadata("design:type", Function),
497
- __metadata("design:paramtypes", [AnyReqQuery]),
530
+ __metadata("design:paramtypes", [Object]),
498
531
  __metadata("design:returntype", void 0)
499
532
  ], Controller.prototype, "anyReq", null);
500
- const httpKernel = utils_1.createHttpKernel([Controller]);
501
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/my-action?test=123'))).json).toEqual({ test: '123' });
502
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/my-action'))).json).toEqual({});
503
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/my-action?filter=page&page=5'))).json).toEqual({ filter: 'page', page: 5 });
533
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
534
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/my-action?test=123'))).json).toEqual({ test: '123' });
535
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/my-action'))).json).toEqual({});
536
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/my-action?filter=page&page=5'))).json).toEqual({ filter: 'page', page: 5 });
504
537
  });
505
- globals_1.test('serializer options', async () => {
538
+ (0, globals_1.test)('serializer options', async () => {
506
539
  class User {
507
540
  }
508
- __decorate([
509
- type_1.t,
510
- __metadata("design:type", String)
511
- ], User.prototype, "username", void 0);
512
- __decorate([
513
- type_1.t.group('sensitive'),
514
- __metadata("design:type", String)
515
- ], User.prototype, "password", void 0);
541
+ User.__type = ['username', () => __ΩGroup, "sensitive", 'password', '&3!P&.#o""K3$5'];
516
542
  class Controller {
517
543
  anyReq() {
518
544
  return { username: 'Peter', password: 'secret' };
519
545
  }
520
546
  }
547
+ Controller.__type = [() => User, 'anyReq', 'PP7!0"5'];
521
548
  __decorate([
522
549
  decorator_1.http.GET().serialization({ groupsExclude: ['sensitive'] }),
523
- type_1.t.type(User),
524
550
  __metadata("design:type", Function),
525
551
  __metadata("design:paramtypes", []),
526
- __metadata("design:returntype", void 0)
552
+ __metadata("design:returntype", User)
527
553
  ], Controller.prototype, "anyReq", null);
528
- const httpKernel = utils_1.createHttpKernel([Controller]);
529
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/'))).json).toEqual({ username: 'Peter' });
554
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
555
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/'))).json).toEqual({ username: 'Peter' });
530
556
  });
531
- globals_1.test('hook after serializer', async () => {
557
+ (0, globals_1.test)('hook after serializer', async () => {
532
558
  class User {
533
559
  }
534
- __decorate([
535
- type_1.t,
536
- __metadata("design:type", String)
537
- ], User.prototype, "username", void 0);
538
- __decorate([
539
- type_1.t.group('sensitive'),
540
- __metadata("design:type", String)
541
- ], User.prototype, "password", void 0);
560
+ User.__type = ['username', () => __ΩGroup, "sensitive", 'password', '&3!P&.#o""K3$5'];
542
561
  class Controller {
543
562
  async anyReq() {
544
- await core_1.sleep(0.1);
563
+ await (0, core_1.sleep)(0.1);
545
564
  return { username: 'Peter', password: 'secret' };
546
565
  }
547
566
  }
567
+ Controller.__type = [() => User, 'anyReq', 'PP7!`0"5'];
548
568
  __decorate([
549
569
  decorator_1.http.GET().serialization({ groupsExclude: ['sensitive'] }),
550
- type_1.t.type(User),
551
570
  __metadata("design:type", Function),
552
571
  __metadata("design:paramtypes", []),
553
572
  __metadata("design:returntype", Promise)
@@ -557,37 +576,40 @@ globals_1.test('hook after serializer', async () => {
557
576
  event.result = { processingTime: event.controllerActionTime, data: event.result };
558
577
  }
559
578
  }
579
+ Listener.__type = [() => http_1.httpWorkflow.onResponse.event, 'event', 'onResponse', 'Pi!2""0#5'];
560
580
  __decorate([
561
581
  event_1.eventDispatcher.listen(http_1.httpWorkflow.onResponse),
562
582
  __metadata("design:type", Function),
563
583
  __metadata("design:paramtypes", [Object]),
564
584
  __metadata("design:returntype", void 0)
565
585
  ], Listener.prototype, "onResponse", null);
566
- const httpKernel = utils_1.createHttpKernel([Controller], [], [Listener]);
586
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller], [], [Listener]);
567
587
  const result = (await httpKernel.request(model_1.HttpRequest.GET('/'))).json;
568
- globals_1.expect(result.data).toEqual({ username: 'Peter' });
569
- globals_1.expect(result.processingTime).toBeGreaterThanOrEqual(99);
588
+ (0, globals_1.expect)(result.data).toEqual({ username: 'Peter' });
589
+ (0, globals_1.expect)(result.processingTime).toBeGreaterThanOrEqual(99);
570
590
  });
571
- globals_1.test('invalid route definition', async () => {
591
+ (0, globals_1.test)('invalid route definition', async () => {
572
592
  class Controller {
573
593
  doIt(user) {
574
594
  }
575
595
  }
596
+ Controller.__type = ['user', 'doIt', 'P"2!"0"5'];
576
597
  __decorate([
577
598
  decorator_1.http.GET(),
578
599
  __metadata("design:type", Function),
579
600
  __metadata("design:paramtypes", [Object]),
580
601
  __metadata("design:returntype", void 0)
581
602
  ], Controller.prototype, "doIt", null);
582
- const httpKernel = utils_1.createHttpKernel([Controller]);
583
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/'))).bodyString).toEqual('Not found');
603
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
604
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/'))).bodyString).toEqual('Internal error');
584
605
  });
585
- globals_1.test('inject request storage ClassType', async () => {
606
+ (0, globals_1.test)('inject request storage ClassType', async () => {
586
607
  class User {
587
608
  constructor(username) {
588
609
  this.username = username;
589
610
  }
590
611
  }
612
+ User.__type = ['username', 'constructor', 'P&2!:"0"5'];
591
613
  class Controller {
592
614
  doIt(user) {
593
615
  return { isUser: user instanceof User, username: user.username };
@@ -596,6 +618,7 @@ globals_1.test('inject request storage ClassType', async () => {
596
618
  return { isUser: user instanceof User };
597
619
  }
598
620
  }
621
+ Controller.__type = [() => User, 'user', 'doIt', () => User, 'doItOptional', 'PP7!2""0#PP7$2"8"0%5'];
599
622
  __decorate([
600
623
  decorator_1.http.GET(),
601
624
  __metadata("design:type", Function),
@@ -604,7 +627,6 @@ globals_1.test('inject request storage ClassType', async () => {
604
627
  ], Controller.prototype, "doIt", null);
605
628
  __decorate([
606
629
  decorator_1.http.GET('optional'),
607
- __param(0, injector_1.inject().optional),
608
630
  __metadata("design:type", Function),
609
631
  __metadata("design:paramtypes", [User]),
610
632
  __metadata("design:returntype", void 0)
@@ -616,64 +638,26 @@ globals_1.test('inject request storage ClassType', async () => {
616
638
  }
617
639
  }
618
640
  }
641
+ Listener.__type = [() => http_1.httpWorkflow.onAuth.event, 'event', 'onAuth', 'Pi!2""0#5'];
619
642
  __decorate([
620
643
  event_1.eventDispatcher.listen(http_1.httpWorkflow.onAuth),
621
644
  __metadata("design:type", Function),
622
645
  __metadata("design:paramtypes", [Object]),
623
646
  __metadata("design:returntype", void 0)
624
647
  ], Listener.prototype, "onAuth", null);
625
- const httpKernel = utils_1.createHttpKernel([Controller], [
648
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller], [
626
649
  {
627
- provide: User, scope: 'http', deps: [model_1.HttpRequest], useFactory(request) {
650
+ provide: User, scope: 'http',
651
+ useFactory: Object.assign(function useFactory(request) {
628
652
  return request.store.user;
629
- }
653
+ }, { __type: [() => model_1.HttpRequest, 'request', 'useFactory', 'PP7!2""/#'] })
630
654
  }
631
655
  ], [Listener]);
632
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/').headers({ authorization: 'yes' }))).json).toEqual({ isUser: true, username: 'bar' });
633
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/').headers({ authorization: 'no' }))).bodyString).toEqual('Internal error');
634
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/optional').headers({ authorization: 'no' }))).json).toEqual({ isUser: false });
656
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/').headers({ authorization: 'yes' }))).json).toEqual({ isUser: true, username: 'bar' });
657
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/').headers({ authorization: 'no' }))).bodyString).toEqual('Internal error');
658
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/optional').headers({ authorization: 'no' }))).json).toEqual({ isUser: false });
635
659
  });
636
- globals_1.test('inject request storage @inject', async () => {
637
- class User {
638
- constructor(username) {
639
- this.username = username;
640
- }
641
- }
642
- class Controller {
643
- doIt(user) {
644
- return { isUser: user instanceof User, username: user.username };
645
- }
646
- }
647
- __decorate([
648
- decorator_1.http.GET(),
649
- __param(0, injector_1.inject('user')),
650
- __metadata("design:type", Function),
651
- __metadata("design:paramtypes", [Object]),
652
- __metadata("design:returntype", void 0)
653
- ], Controller.prototype, "doIt", null);
654
- class Listener {
655
- onAuth(event) {
656
- event.request.store.user = new User('bar');
657
- }
658
- }
659
- __decorate([
660
- event_1.eventDispatcher.listen(http_1.httpWorkflow.onAuth),
661
- __metadata("design:type", Function),
662
- __metadata("design:paramtypes", [Object]),
663
- __metadata("design:returntype", void 0)
664
- ], Listener.prototype, "onAuth", null);
665
- const httpKernel = utils_1.createHttpKernel([Controller], [
666
- {
667
- provide: 'user', scope: 'http', deps: [model_1.HttpRequest], useFactory(request) {
668
- return request.store.user;
669
- }
670
- }
671
- ], [Listener]);
672
- const result = (await httpKernel.request(model_1.HttpRequest.GET('/'))).json;
673
- globals_1.expect(result.isUser).toBe(true);
674
- globals_1.expect(result.username).toBe('bar');
675
- });
676
- globals_1.test('custom request handling', async () => {
660
+ (0, globals_1.test)('custom request handling', async () => {
677
661
  class Listener {
678
662
  onRouteNotFound(event) {
679
663
  //CORS requirement for example
@@ -681,25 +665,27 @@ globals_1.test('custom request handling', async () => {
681
665
  event.send(new http_1.JSONResponse(true, 200));
682
666
  }
683
667
  }
668
+ Listener.__type = [() => http_1.httpWorkflow.onRouteNotFound.event, 'event', 'onRouteNotFound', 'Pi!2""0#5'];
684
669
  __decorate([
685
670
  event_1.eventDispatcher.listen(http_1.httpWorkflow.onRouteNotFound),
686
671
  __metadata("design:type", Function),
687
672
  __metadata("design:paramtypes", [Object]),
688
673
  __metadata("design:returntype", void 0)
689
674
  ], Listener.prototype, "onRouteNotFound", null);
690
- const httpKernel = utils_1.createHttpKernel([], [], [Listener]);
691
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.OPTIONS('/'))).json).toBe(true);
675
+ const httpKernel = (0, utils_1.createHttpKernel)([], [], [Listener]);
676
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.OPTIONS('/'))).json).toBe(true);
692
677
  });
693
- globals_1.test('race condition', async () => {
678
+ (0, globals_1.test)('race condition', async () => {
694
679
  let call = 0;
695
680
  class Listener {
696
681
  async onRouteNotFound(event) {
697
682
  if (call === 0) {
698
- await core_1.sleep(0.1);
683
+ await (0, core_1.sleep)(0.1);
699
684
  }
700
685
  call++;
701
686
  }
702
687
  }
688
+ Listener.__type = [() => http_1.httpWorkflow.onRouteNotFound.event, 'event', 'onRouteNotFound', 'Pi!2""0#5'];
703
689
  __decorate([
704
690
  event_1.eventDispatcher.listen(http_1.httpWorkflow.onAuth),
705
691
  __metadata("design:type", Function),
@@ -714,6 +700,7 @@ globals_1.test('race condition', async () => {
714
700
  return param2;
715
701
  }
716
702
  }
703
+ Controller.__type = ['param1', 'one', 'param2', 'second', 'P&2!"0"P&2#"0$5'];
717
704
  __decorate([
718
705
  decorator_1.http.GET('/one/:param1'),
719
706
  __metadata("design:type", Function),
@@ -726,33 +713,34 @@ globals_1.test('race condition', async () => {
726
713
  __metadata("design:paramtypes", [String]),
727
714
  __metadata("design:returntype", void 0)
728
715
  ], Controller.prototype, "second", null);
729
- const httpKernel = utils_1.createHttpKernel([Controller], [], [Listener]);
716
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller], [], [Listener]);
730
717
  const [a, b] = await Promise.all([
731
718
  httpKernel.request(model_1.HttpRequest.GET('/one/a')),
732
719
  httpKernel.request(model_1.HttpRequest.GET('/second/b')),
733
720
  ]);
734
- globals_1.expect(a.json).toBe('a');
735
- globals_1.expect(b.json).toBe('b');
721
+ (0, globals_1.expect)(a.json).toBe('a');
722
+ (0, globals_1.expect)(b.json).toBe('b');
736
723
  });
737
- globals_1.test('multiple methods', async () => {
724
+ (0, globals_1.test)('multiple methods', async () => {
738
725
  class Controller {
739
726
  one() {
740
727
  return true;
741
728
  }
742
729
  }
730
+ Controller.__type = ['one', 'P"0!5'];
743
731
  __decorate([
744
732
  decorator_1.http.GET('/one').POST(),
745
733
  __metadata("design:type", Function),
746
734
  __metadata("design:paramtypes", []),
747
735
  __metadata("design:returntype", void 0)
748
736
  ], Controller.prototype, "one", null);
749
- const httpKernel = utils_1.createHttpKernel([Controller], [], []);
750
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/one'))).json).toBe(true);
751
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.POST('/one'))).json).toBe(true);
752
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.PATCH('/one'))).bodyString).toBe('Not found');
753
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.PUT('/one'))).bodyString).toBe('Not found');
737
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller], [], []);
738
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/one'))).json).toBe(true);
739
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.POST('/one'))).json).toBe(true);
740
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.PATCH('/one'))).bodyString).toBe('Not found');
741
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.PUT('/one'))).bodyString).toBe('Not found');
754
742
  });
755
- globals_1.test('promise serializer', async () => {
743
+ (0, globals_1.test)('promise serializer', async () => {
756
744
  class Controller {
757
745
  async anyReq1() {
758
746
  return 'test';
@@ -761,6 +749,7 @@ globals_1.test('promise serializer', async () => {
761
749
  return 1;
762
750
  }
763
751
  }
752
+ Controller.__type = ['anyReq1', 'anyReq2', 'P"0!P&`0"5'];
764
753
  __decorate([
765
754
  decorator_1.http.GET('1'),
766
755
  __metadata("design:type", Function),
@@ -769,55 +758,53 @@ globals_1.test('promise serializer', async () => {
769
758
  ], Controller.prototype, "anyReq1", null);
770
759
  __decorate([
771
760
  decorator_1.http.GET('2'),
772
- type_1.t.string,
773
761
  __metadata("design:type", Function),
774
762
  __metadata("design:paramtypes", []),
775
763
  __metadata("design:returntype", Promise)
776
764
  ], Controller.prototype, "anyReq2", null);
777
- const httpKernel = utils_1.createHttpKernel([Controller]);
778
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/1'))).json).toBe('test');
779
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/2'))).json).toBe('1');
765
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
766
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/1'))).json).toBe('test');
767
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/2'))).json).toBe('1');
780
768
  });
781
- globals_1.test('unions', async () => {
769
+ (0, globals_1.test)('unions', async () => {
782
770
  class Controller {
783
771
  list(page) {
784
772
  return page;
785
773
  }
786
774
  }
775
+ Controller.__type = [() => __ΩHttpQuery, 'page', 'list', 'PP\')Jo!"2""0#5'];
787
776
  __decorate([
788
777
  decorator_1.http.GET('/list'),
789
- __param(0, decorator_1.http.query()),
790
- __param(0, type_1.t.union(type_1.t.number, type_1.t.boolean)),
791
778
  __metadata("design:type", Function),
792
779
  __metadata("design:paramtypes", [Object]),
793
780
  __metadata("design:returntype", void 0)
794
781
  ], Controller.prototype, "list", null);
795
- const httpKernel = utils_1.createHttpKernel([Controller]);
796
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/list?page=1'))).json).toEqual(1);
797
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/list?page=2222'))).json).toEqual(2222);
798
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/list?page=false'))).json).toEqual(false);
782
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
783
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/list?page=0'))).json).toEqual(0);
784
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/list?page=1'))).json).toEqual(1);
785
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/list?page=2222'))).json).toEqual(2222);
786
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/list?page=false'))).json).toEqual(false);
787
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/list?page=true'))).json).toEqual(true);
788
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/list?page=asdasdc'))).json).toMatchObject({
789
+ 'errors': [
790
+ {
791
+ 'code': 'type',
792
+ 'message': 'No value given',
793
+ 'path': 'page'
794
+ }
795
+ ],
796
+ });
799
797
  });
800
- globals_1.test('router dotToUrlPath', () => {
801
- globals_1.expect(router_1.dotToUrlPath('peter')).toBe('peter');
802
- globals_1.expect(router_1.dotToUrlPath('foo.bar')).toBe('foo[bar]');
803
- globals_1.expect(router_1.dotToUrlPath('foo.bar.deep')).toBe('foo[bar][deep]');
804
- globals_1.expect(router_1.dotToUrlPath('foo.bar.deep.very')).toBe('foo[bar][deep][very]');
798
+ (0, globals_1.test)('router dotToUrlPath', () => {
799
+ (0, globals_1.expect)((0, router_1.dotToUrlPath)('peter')).toBe('peter');
800
+ (0, globals_1.expect)((0, router_1.dotToUrlPath)('foo.bar')).toBe('foo[bar]');
801
+ (0, globals_1.expect)((0, router_1.dotToUrlPath)('foo.bar.deep')).toBe('foo[bar][deep]');
802
+ (0, globals_1.expect)((0, router_1.dotToUrlPath)('foo.bar.deep.very')).toBe('foo[bar][deep][very]');
805
803
  });
806
- globals_1.test('router url resolve', async () => {
804
+ (0, globals_1.test)('router url resolve', async () => {
807
805
  class AnyReqQuery {
808
806
  }
809
- __decorate([
810
- type_1.t.optional,
811
- __metadata("design:type", String)
812
- ], AnyReqQuery.prototype, "test", void 0);
813
- __decorate([
814
- type_1.t.optional,
815
- __metadata("design:type", String)
816
- ], AnyReqQuery.prototype, "filter", void 0);
817
- __decorate([
818
- type_1.t.optional,
819
- __metadata("design:type", Number)
820
- ], AnyReqQuery.prototype, "page", void 0);
807
+ AnyReqQuery.__type = ['test', 'filter', 'page', '&3!8&3"8\'3#85'];
821
808
  class Controller {
822
809
  first() {
823
810
  return '';
@@ -838,6 +825,7 @@ globals_1.test('router url resolve', async () => {
838
825
  return params;
839
826
  }
840
827
  }
828
+ 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'];
841
829
  __decorate([
842
830
  decorator_1.http.GET('').name('first'),
843
831
  __metadata("design:type", Function),
@@ -852,115 +840,63 @@ globals_1.test('router url resolve', async () => {
852
840
  ], Controller.prototype, "second", null);
853
841
  __decorate([
854
842
  decorator_1.http.GET('').name('secondQuery'),
855
- __param(0, decorator_1.http.query()),
856
843
  __metadata("design:type", Function),
857
- __metadata("design:paramtypes", [String]),
844
+ __metadata("design:paramtypes", [Object]),
858
845
  __metadata("design:returntype", void 0)
859
846
  ], Controller.prototype, "secondQuery", null);
860
847
  __decorate([
861
848
  decorator_1.http.GET('').name('secondQuery2'),
862
- __param(0, decorator_1.http.query('changed')),
863
849
  __metadata("design:type", Function),
864
- __metadata("design:paramtypes", [String]),
850
+ __metadata("design:paramtypes", [Object]),
865
851
  __metadata("design:returntype", void 0)
866
852
  ], Controller.prototype, "secondQuery2", null);
867
853
  __decorate([
868
854
  decorator_1.http.GET('third').name('third'),
869
- __param(0, decorator_1.http.queries()),
870
855
  __metadata("design:type", Function),
871
- __metadata("design:paramtypes", [AnyReqQuery]),
856
+ __metadata("design:paramtypes", [Object]),
872
857
  __metadata("design:returntype", void 0)
873
858
  ], Controller.prototype, "third", null);
874
859
  __decorate([
875
860
  decorator_1.http.GET('third2').name('third2'),
876
- __param(0, decorator_1.http.queries('deep')),
877
861
  __metadata("design:type", Function),
878
- __metadata("design:paramtypes", [AnyReqQuery]),
862
+ __metadata("design:paramtypes", [Object]),
879
863
  __metadata("design:returntype", void 0)
880
864
  ], Controller.prototype, "third2", null);
881
865
  const router = router_1.Router.forControllers([Controller]);
882
- globals_1.expect(router.resolveUrl('first')).toBe('/');
883
- globals_1.expect(router.resolveUrl('second', { peter: 'foo' })).toBe('/foo');
884
- globals_1.expect(router.resolveUrl('secondQuery', { peter: 'foo' })).toBe('/?peter=foo');
885
- globals_1.expect(router.resolveUrl('secondQuery2', { peter: 'foo' })).toBe('/?changed=foo');
886
- globals_1.expect(router.resolveUrl('third', {})).toBe('/third');
887
- globals_1.expect(router.resolveUrl('third', { params: { test: 123 } })).toBe('/third?test=123');
888
- globals_1.expect(router.resolveUrl('third', { params: { test: 123, filter: 'peter' } })).toBe('/third?test=123&filter=peter');
889
- globals_1.expect(router.resolveUrl('third2', {})).toBe('/third2');
890
- globals_1.expect(router.resolveUrl('third2', { params: { test: 123 } })).toBe('/third2?deep[test]=123');
891
- globals_1.expect(router.resolveUrl('third2', { params: { test: 123, filter: 'peter' } })).toBe('/third2?deep[test]=123&deep[filter]=peter');
866
+ (0, globals_1.expect)(router.resolveUrl('first')).toBe('/');
867
+ (0, globals_1.expect)(router.resolveUrl('second', { peter: 'foo' })).toBe('/foo');
868
+ (0, globals_1.expect)(router.resolveUrl('secondQuery', { peter: 'foo' })).toBe('/?peter=foo');
869
+ (0, globals_1.expect)(router.resolveUrl('secondQuery2', { peter: 'foo' })).toBe('/?changed=foo');
870
+ (0, globals_1.expect)(router.resolveUrl('third', {})).toBe('/third');
871
+ (0, globals_1.expect)(router.resolveUrl('third', { params: { test: 123 } })).toBe('/third?test=123');
872
+ (0, globals_1.expect)(router.resolveUrl('third', { params: { test: 123, filter: 'peter' } })).toBe('/third?test=123&filter=peter');
873
+ (0, globals_1.expect)(router.resolveUrl('third2', {})).toBe('/third2');
874
+ (0, globals_1.expect)(router.resolveUrl('third2', { params: { test: 123 } })).toBe('/third2?deep[test]=123');
875
+ (0, globals_1.expect)(router.resolveUrl('third2', { params: { test: 123, filter: 'peter' } })).toBe('/third2?deep[test]=123&deep[filter]=peter');
892
876
  });
893
- globals_1.test('destructing params', async () => {
894
- class DTO {
895
- }
896
- __decorate([
897
- type_1.t.required,
898
- __metadata("design:type", String)
899
- ], DTO.prototype, "name", void 0);
900
- __decorate([
901
- type_1.t.required,
902
- __metadata("design:type", String)
903
- ], DTO.prototype, "title", void 0);
877
+ (0, globals_1.test)('destructing params', async () => {
878
+ var __ΩDTO = ['name', 'title', 'P&4!&4"M'];
904
879
  class Controller {
905
880
  first({ name, title }) {
906
881
  return [name, title];
907
882
  }
908
883
  }
884
+ Controller.__type = [() => __ΩHttpBody, () => __ΩDTO, 'param0', 'first', 'Pn"o!"2#"0$5'];
909
885
  __decorate([
910
886
  decorator_1.http.GET(''),
911
- __param(0, decorator_1.http.body()),
912
887
  __metadata("design:type", Function),
913
- __metadata("design:paramtypes", [DTO]),
888
+ __metadata("design:paramtypes", [Object]),
914
889
  __metadata("design:returntype", void 0)
915
890
  ], Controller.prototype, "first", null);
916
- const httpKernel = utils_1.createHttpKernel([Controller]);
917
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/').json({ name: 'Peter', title: 'CTO' }))).json).toEqual(['Peter', 'CTO']);
891
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
892
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/').json({ name: 'Peter', title: 'CTO' }))).json).toEqual(['Peter', 'CTO']);
918
893
  });
919
- globals_1.test('dynamic parameter name', async () => {
920
- let Controller = class Controller {
921
- first(id) {
922
- return [id];
923
- }
924
- second(id, second) {
925
- return [id, second];
926
- }
927
- };
928
- __decorate([
929
- decorator_1.http.GET('first/:another'),
930
- __param(0, type_1.t.description('The identifier').name('another')),
931
- __metadata("design:type", Function),
932
- __metadata("design:paramtypes", [String]),
933
- __metadata("design:returntype", void 0)
934
- ], Controller.prototype, "first", null);
935
- __decorate([
936
- decorator_1.http.GET('second/:another2'),
937
- __param(0, type_1.t.description('The identifier').name('another2')),
938
- __param(1, decorator_1.http.query()),
939
- __metadata("design:type", Function),
940
- __metadata("design:paramtypes", [String, String]),
941
- __metadata("design:returntype", void 0)
942
- ], Controller.prototype, "second", null);
943
- Controller = __decorate([
944
- decorator_1.http.controller()
945
- ], Controller);
946
- const schema = type_1.getClassSchema(Controller);
947
- globals_1.expect(schema.getMethodProperties('first')[0].name).toBe('another');
948
- globals_1.expect(schema.getMethodProperties('second')[0].name).toBe('another2');
949
- globals_1.expect(schema.getMethodProperties('second')[1].name).toBe('second');
950
- const httpKernel = utils_1.createHttpKernel([Controller]);
951
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/first/peter'))).json).toEqual(['peter']);
952
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/second/peter?second=true'))).json).toEqual(['peter', 'true']);
953
- });
954
- globals_1.test('use http.response for serialization', async () => {
955
- const schemaString = type_1.t.schema({
956
- title: type_1.t.string
957
- });
958
- const errorSchema = type_1.t.schema({
959
- message: type_1.t.string
960
- });
894
+ (0, globals_1.test)('use http.response for serialization', async () => {
895
+ var __ΩDefaultResponse = ['title', 'P&4!M'];
896
+ var __ΩErrorResponse = ['message', 'P&4!M'];
961
897
  class Controller {
962
898
  action1() {
963
- return [{ title: 'a' }, { title: 1 }];
899
+ return [{ title: 'a' }, { title: '1' }];
964
900
  }
965
901
  action2() {
966
902
  return [{ title: 'a' }, { title: 1 }];
@@ -969,30 +905,83 @@ globals_1.test('use http.response for serialization', async () => {
969
905
  return new http_1.JSONResponse([{ message: 'error' }, { message: 1 }]).status(400);
970
906
  }
971
907
  }
908
+ Controller.__type = [() => __ΩDefaultResponse, 'action1', 'action2', 'action3', 'Pn!F0"P"0#P"0$5'];
972
909
  __decorate([
973
910
  decorator_1.http.GET('/action1'),
974
- type_1.t.array(schemaString),
975
911
  __metadata("design:type", Function),
976
912
  __metadata("design:paramtypes", []),
977
- __metadata("design:returntype", void 0)
913
+ __metadata("design:returntype", Array)
978
914
  ], Controller.prototype, "action1", null);
979
915
  __decorate([
980
- decorator_1.http.GET('/action2').response(200, `List`, type_1.t.array(schemaString)),
916
+ decorator_1.http.GET('/action2').response(200, `List`, [() => __ΩDefaultResponse, 'n!F']),
981
917
  __metadata("design:type", Function),
982
918
  __metadata("design:paramtypes", []),
983
919
  __metadata("design:returntype", void 0)
984
920
  ], Controller.prototype, "action2", null);
985
921
  __decorate([
986
922
  decorator_1.http.GET('/action3')
987
- .response(200, `List`, type_1.t.array(schemaString))
988
- .response(400, `Error`, type_1.t.array(errorSchema)),
923
+ .response(200, `List`, [() => __ΩDefaultResponse, 'n!F'])
924
+ .response(400, `Error`, [() => __ΩErrorResponse, 'n!F']),
989
925
  __metadata("design:type", Function),
990
926
  __metadata("design:paramtypes", []),
991
927
  __metadata("design:returntype", void 0)
992
928
  ], Controller.prototype, "action3", null);
993
- const httpKernel = utils_1.createHttpKernel([Controller]);
994
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/action1'))).json).toEqual([{ title: 'a' }, { title: '1' }]);
995
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/action2'))).json).toEqual([{ title: 'a' }, { title: '1' }]);
996
- globals_1.expect((await httpKernel.request(model_1.HttpRequest.GET('/action3'))).json).toEqual([{ message: 'error' }, { message: '1' }]);
929
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
930
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/action1'))).json).toEqual([{ title: 'a' }, { title: '1' }]);
931
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/action2'))).json).toEqual([{ title: 'a' }, { title: '1' }]);
932
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.GET('/action3'))).json).toEqual([{ message: 'error' }, { message: '1' }]);
933
+ });
934
+ (0, globals_1.test)('BodyValidation', async () => {
935
+ class User {
936
+ }
937
+ User.__type = [() => __ΩMinLength, 3, 'username', 'P&."o!"K3#5'];
938
+ class AddUserDto extends User {
939
+ }
940
+ AddUserDto.__type = [() => router_1.UploadedFile, 'imageUpload', 'P7!3"85'];
941
+ class Controller {
942
+ action1(user) {
943
+ return user;
944
+ }
945
+ action2(user) {
946
+ if (user.valid()) {
947
+ return user.value;
948
+ }
949
+ throw new http_1.HttpBadRequestError('Invalid: ' + user.error.getErrorMessageForPath('username'));
950
+ }
951
+ action3(user) {
952
+ if (user.valid()) {
953
+ return user.value;
954
+ }
955
+ throw new http_1.HttpBadRequestError('Invalid: ' + user.error.getErrorMessageForPath('username'));
956
+ }
957
+ }
958
+ 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'];
959
+ __decorate([
960
+ decorator_1.http.POST('/action1'),
961
+ __metadata("design:type", Function),
962
+ __metadata("design:paramtypes", [Object]),
963
+ __metadata("design:returntype", Object)
964
+ ], Controller.prototype, "action1", null);
965
+ __decorate([
966
+ decorator_1.http.POST('/action2'),
967
+ __metadata("design:type", Function),
968
+ __metadata("design:paramtypes", [Object]),
969
+ __metadata("design:returntype", User)
970
+ ], Controller.prototype, "action2", null);
971
+ __decorate([
972
+ decorator_1.http.POST('/action3'),
973
+ __metadata("design:type", Function),
974
+ __metadata("design:paramtypes", [Object]),
975
+ __metadata("design:returntype", User)
976
+ ], Controller.prototype, "action3", null);
977
+ const httpKernel = (0, utils_1.createHttpKernel)([Controller]);
978
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.POST('/action1').json({ username: 'Peter' }))).json).toEqual({ username: 'Peter' });
979
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.POST('/action1').json({ username: 'Pe' }))).json).toEqual({
980
+ errors: [{ code: 'minLength', message: 'Min length is 3', path: 'username' }], message: 'Validation error:\nusername(minLength): Min length is 3'
981
+ });
982
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.POST('/action2').json({ username: 'Peter' }))).json).toEqual({ username: 'Peter' });
983
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.POST('/action2').json({ username: 'Pe' }))).bodyString).toEqual(`{"message":"Invalid: Min length is 3"}`);
984
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.POST('/action3').json({ username: 'Peter' }))).json).toEqual({ username: 'Peter' });
985
+ (0, globals_1.expect)((await httpKernel.request(model_1.HttpRequest.POST('/action3').json({ username: 'Pe' }))).bodyString).toEqual(`{"message":"Invalid: Min length is 3"}`);
997
986
  });
998
987
  //# sourceMappingURL=router.spec.js.map