@tsed/common 7.0.0-beta.1 → 7.0.0-beta.10

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 (253) hide show
  1. package/lib/cjs/builder/PlatformBuilder.js +38 -27
  2. package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
  3. package/lib/cjs/builder/PlatformControllerBuilder.js +5 -8
  4. package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -1
  5. package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -1
  6. package/lib/cjs/config/services/PlatformConfiguration.js +2 -2
  7. package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -1
  8. package/lib/cjs/decorators/multer/multipartFile.js.map +1 -1
  9. package/lib/cjs/domain/EndpointMetadata.js +2 -66
  10. package/lib/cjs/domain/EndpointMetadata.js.map +1 -1
  11. package/lib/cjs/domain/PlatformContext.js.map +1 -1
  12. package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -1
  13. package/lib/cjs/exports.js +31 -0
  14. package/lib/cjs/exports.js.map +1 -0
  15. package/lib/cjs/index.js +66 -30
  16. package/lib/cjs/index.js.map +1 -1
  17. package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -1
  18. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +8 -8
  19. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  20. package/lib/cjs/middlewares/PlatformMulterMiddleware.js +25 -13
  21. package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -1
  22. package/lib/cjs/middlewares/__mock__/FakeCtrl.js +1 -1
  23. package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +1 -1
  24. package/lib/cjs/package.json +3 -0
  25. package/lib/cjs/services/FakeAdapter.js +55 -0
  26. package/lib/cjs/services/FakeAdapter.js.map +1 -0
  27. package/lib/cjs/services/Platform.js +30 -9
  28. package/lib/cjs/services/Platform.js.map +1 -1
  29. package/lib/cjs/services/PlatformAdapter.js +14 -0
  30. package/lib/cjs/services/PlatformAdapter.js.map +1 -0
  31. package/lib/cjs/services/PlatformApplication.js +9 -11
  32. package/lib/cjs/services/PlatformApplication.js.map +1 -1
  33. package/lib/cjs/services/PlatformHandler.js +11 -9
  34. package/lib/cjs/services/PlatformHandler.js.map +1 -1
  35. package/lib/cjs/services/PlatformMiddlewaresChain.js +56 -15
  36. package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
  37. package/lib/cjs/services/PlatformRequest.js +2 -2
  38. package/lib/cjs/services/PlatformResponse.js +5 -5
  39. package/lib/cjs/services/PlatformResponse.js.map +1 -1
  40. package/lib/cjs/services/PlatformRouter.js +14 -32
  41. package/lib/cjs/services/PlatformRouter.js.map +1 -1
  42. package/lib/cjs/services/PlatformTest.js +3 -2
  43. package/lib/cjs/services/PlatformTest.js.map +1 -1
  44. package/lib/cjs/utils/__mock__/Test1.js +8 -0
  45. package/lib/cjs/utils/__mock__/Test1.js.map +1 -0
  46. package/lib/cjs/utils/__mock__/Test2.js +8 -0
  47. package/lib/cjs/utils/__mock__/Test2.js.map +1 -0
  48. package/lib/cjs/utils/createContext.js +2 -2
  49. package/lib/cjs/utils/createContext.js.map +1 -1
  50. package/lib/cjs/utils/createHandlerMetadata.js +2 -2
  51. package/lib/cjs/utils/createHandlerMetadata.js.map +1 -1
  52. package/lib/cjs/utils/createHttpServer.js +3 -8
  53. package/lib/cjs/utils/createHttpServer.js.map +1 -1
  54. package/lib/cjs/utils/createHttpsServer.js +3 -8
  55. package/lib/cjs/utils/createHttpsServer.js.map +1 -1
  56. package/lib/cjs/utils/createInjector.js +11 -3
  57. package/lib/cjs/utils/createInjector.js.map +1 -1
  58. package/lib/cjs/utils/importProviders.js +29 -0
  59. package/lib/cjs/utils/importProviders.js.map +1 -0
  60. package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
  61. package/lib/esm/builder/PlatformBuilder.js +25 -14
  62. package/lib/esm/builder/PlatformBuilder.js.map +1 -1
  63. package/lib/esm/builder/PlatformControllerBuilder.js +8 -11
  64. package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -1
  65. package/lib/esm/config/interfaces/PlatformMulterSettings.js.map +1 -1
  66. package/lib/esm/config/services/PlatformConfiguration.js.map +1 -1
  67. package/lib/esm/decorators/multer/multerFileSize.js +1 -1
  68. package/lib/esm/decorators/multer/multerOptions.js +1 -1
  69. package/lib/esm/decorators/multer/multipartFile.js +1 -1
  70. package/lib/esm/decorators/multer/multipartFile.js.map +1 -1
  71. package/lib/esm/domain/ControllerProvider.js +1 -1
  72. package/lib/esm/domain/EndpointMetadata.js +1 -66
  73. package/lib/esm/domain/EndpointMetadata.js.map +1 -1
  74. package/lib/esm/domain/HandlerMetadata.js +1 -1
  75. package/lib/esm/domain/PlatformContext.js +3 -3
  76. package/lib/esm/domain/PlatformContext.js.map +1 -1
  77. package/lib/esm/domain/PlatformRouteDetails.js.map +1 -1
  78. package/lib/esm/exports.js +13 -0
  79. package/lib/esm/exports.js.map +1 -0
  80. package/lib/esm/index.js +66 -27
  81. package/lib/esm/index.js.map +1 -1
  82. package/lib/esm/interfaces/PlatformRouteOptions.js.map +1 -1
  83. package/lib/esm/middlewares/PlatformMulterMiddleware.js +16 -5
  84. package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -1
  85. package/lib/esm/middlewares/bindEndpointMiddleware.js.map +1 -1
  86. package/lib/esm/package.json +3 -0
  87. package/lib/esm/services/FakeAdapter.js +51 -0
  88. package/lib/esm/services/FakeAdapter.js.map +1 -0
  89. package/lib/esm/services/Platform.js +31 -10
  90. package/lib/esm/services/Platform.js.map +1 -1
  91. package/lib/esm/services/PlatformAdapter.js +10 -0
  92. package/lib/esm/services/PlatformAdapter.js.map +1 -0
  93. package/lib/esm/services/PlatformApplication.js +11 -13
  94. package/lib/esm/services/PlatformApplication.js.map +1 -1
  95. package/lib/esm/services/PlatformHandler.js +13 -11
  96. package/lib/esm/services/PlatformHandler.js.map +1 -1
  97. package/lib/esm/services/PlatformMiddlewaresChain.js +61 -20
  98. package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
  99. package/lib/esm/services/PlatformResponse.js +1 -1
  100. package/lib/esm/services/PlatformResponse.js.map +1 -1
  101. package/lib/esm/services/PlatformRouter.js +13 -31
  102. package/lib/esm/services/PlatformRouter.js.map +1 -1
  103. package/lib/esm/services/PlatformTest.js +7 -7
  104. package/lib/esm/services/PlatformTest.js.map +1 -1
  105. package/lib/esm/utils/__mock__/Test1.js +4 -0
  106. package/lib/esm/utils/__mock__/Test1.js.map +1 -0
  107. package/lib/esm/utils/__mock__/Test2.js +4 -0
  108. package/lib/esm/utils/__mock__/Test2.js.map +1 -0
  109. package/lib/esm/utils/createContext.js +5 -5
  110. package/lib/esm/utils/createContext.js.map +1 -1
  111. package/lib/esm/utils/createHandlerMetadata.js +3 -3
  112. package/lib/esm/utils/createHandlerMetadata.js.map +1 -1
  113. package/lib/esm/utils/createHttpServer.js +3 -8
  114. package/lib/esm/utils/createHttpServer.js.map +1 -1
  115. package/lib/esm/utils/createHttpsServer.js +3 -8
  116. package/lib/esm/utils/createHttpsServer.js.map +1 -1
  117. package/lib/esm/utils/createInjector.js +18 -10
  118. package/lib/esm/utils/createInjector.js.map +1 -1
  119. package/lib/esm/utils/importProviders.js +25 -0
  120. package/lib/esm/utils/importProviders.js.map +1 -0
  121. package/lib/esm/utils/setResponseHeaders.js.map +1 -1
  122. package/lib/esm/utils/useCtxHandler.js +1 -1
  123. package/lib/types/builder/PlatformBuilder.d.ts +7 -6
  124. package/lib/types/builder/PlatformControllerBuilder.d.ts +2 -1
  125. package/lib/types/config/interfaces/PlatformMulterSettings.d.ts +6 -130
  126. package/lib/types/config/services/PlatformConfiguration.d.ts +2 -1
  127. package/lib/types/domain/EndpointMetadata.d.ts +1 -50
  128. package/lib/types/domain/PlatformContext.d.ts +1 -1
  129. package/lib/types/domain/PlatformRouteDetails.d.ts +2 -3
  130. package/lib/types/exports.d.ts +12 -0
  131. package/lib/types/index.d.ts +63 -17
  132. package/lib/types/interfaces/PlatformRouteOptions.d.ts +1 -1
  133. package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +8 -3
  134. package/lib/types/middlewares/bindEndpointMiddleware.d.ts +2 -1
  135. package/lib/types/services/FakeAdapter.d.ts +30 -0
  136. package/lib/types/services/Platform.d.ts +10 -1
  137. package/lib/types/services/PlatformAdapter.d.ts +47 -0
  138. package/lib/types/services/PlatformApplication.d.ts +3 -3
  139. package/lib/types/services/PlatformHandler.d.ts +1 -1
  140. package/lib/types/services/PlatformMiddlewaresChain.d.ts +6 -2
  141. package/lib/types/services/PlatformResponse.d.ts +6 -6
  142. package/lib/types/services/PlatformRouter.d.ts +10 -7
  143. package/lib/types/services/PlatformTest.d.ts +2 -2
  144. package/lib/types/utils/__mock__/Test1.d.ts +3 -0
  145. package/lib/types/utils/__mock__/Test2.d.ts +3 -0
  146. package/lib/types/utils/createHandlerMetadata.d.ts +1 -1
  147. package/lib/types/utils/createHttpServer.d.ts +1 -1
  148. package/lib/types/utils/createHttpsServer.d.ts +2 -1
  149. package/lib/types/utils/createInjector.d.ts +5 -3
  150. package/lib/types/utils/importProviders.d.ts +10 -0
  151. package/package.json +38 -26
  152. package/readme.md +50 -57
  153. package/tsconfig.compile.esm.json +2 -12
  154. package/lib/cjs/config/index.js +0 -7
  155. package/lib/cjs/config/index.js.map +0 -1
  156. package/lib/cjs/config/interfaces/index.js +0 -8
  157. package/lib/cjs/config/interfaces/index.js.map +0 -1
  158. package/lib/cjs/decorators/httpServer.js +0 -32
  159. package/lib/cjs/decorators/httpServer.js.map +0 -1
  160. package/lib/cjs/decorators/httpsServer.js +0 -32
  161. package/lib/cjs/decorators/httpsServer.js.map +0 -1
  162. package/lib/cjs/decorators/index.js +0 -21
  163. package/lib/cjs/decorators/index.js.map +0 -1
  164. package/lib/cjs/decorators/method/acceptMime.js +0 -28
  165. package/lib/cjs/decorators/method/acceptMime.js.map +0 -1
  166. package/lib/cjs/decorators/method/endpointFn.js +0 -15
  167. package/lib/cjs/decorators/method/endpointFn.js.map +0 -1
  168. package/lib/cjs/decorators/method/location.js +0 -6
  169. package/lib/cjs/decorators/method/location.js.map +0 -1
  170. package/lib/cjs/decorators/method/redirect.js +0 -6
  171. package/lib/cjs/decorators/method/redirect.js.map +0 -1
  172. package/lib/cjs/decorators/method/route.js +0 -13
  173. package/lib/cjs/decorators/method/route.js.map +0 -1
  174. package/lib/cjs/decorators/method/view.js +0 -34
  175. package/lib/cjs/decorators/method/view.js.map +0 -1
  176. package/lib/cjs/decorators/multer/index.js +0 -7
  177. package/lib/cjs/decorators/multer/index.js.map +0 -1
  178. package/lib/cjs/domain/index.js +0 -10
  179. package/lib/cjs/domain/index.js.map +0 -1
  180. package/lib/cjs/interfaces/PathType.js +0 -3
  181. package/lib/cjs/interfaces/PathType.js.map +0 -1
  182. package/lib/cjs/interfaces/PlatformAdapter.js +0 -3
  183. package/lib/cjs/interfaces/PlatformAdapter.js.map +0 -1
  184. package/lib/cjs/interfaces/index.js +0 -21
  185. package/lib/cjs/interfaces/index.js.map +0 -1
  186. package/lib/cjs/middlewares/index.js +0 -7
  187. package/lib/cjs/middlewares/index.js.map +0 -1
  188. package/lib/cjs/services/FakeRawDriver.js +0 -26
  189. package/lib/cjs/services/FakeRawDriver.js.map +0 -1
  190. package/lib/cjs/services/index.js +0 -12
  191. package/lib/cjs/services/index.js.map +0 -1
  192. package/lib/cjs/utils/index.js +0 -11
  193. package/lib/cjs/utils/index.js.map +0 -1
  194. package/lib/esm/config/index.js +0 -4
  195. package/lib/esm/config/index.js.map +0 -1
  196. package/lib/esm/config/interfaces/index.js +0 -5
  197. package/lib/esm/config/interfaces/index.js.map +0 -1
  198. package/lib/esm/decorators/httpServer.js +0 -28
  199. package/lib/esm/decorators/httpServer.js.map +0 -1
  200. package/lib/esm/decorators/httpsServer.js +0 -28
  201. package/lib/esm/decorators/httpsServer.js.map +0 -1
  202. package/lib/esm/decorators/index.js +0 -18
  203. package/lib/esm/decorators/index.js.map +0 -1
  204. package/lib/esm/decorators/method/acceptMime.js +0 -24
  205. package/lib/esm/decorators/method/acceptMime.js.map +0 -1
  206. package/lib/esm/decorators/method/endpointFn.js +0 -11
  207. package/lib/esm/decorators/method/endpointFn.js.map +0 -1
  208. package/lib/esm/decorators/method/location.js +0 -2
  209. package/lib/esm/decorators/method/location.js.map +0 -1
  210. package/lib/esm/decorators/method/redirect.js +0 -2
  211. package/lib/esm/decorators/method/redirect.js.map +0 -1
  212. package/lib/esm/decorators/method/route.js +0 -2
  213. package/lib/esm/decorators/method/route.js.map +0 -1
  214. package/lib/esm/decorators/method/view.js +0 -30
  215. package/lib/esm/decorators/method/view.js.map +0 -1
  216. package/lib/esm/decorators/multer/index.js +0 -4
  217. package/lib/esm/decorators/multer/index.js.map +0 -1
  218. package/lib/esm/domain/index.js +0 -7
  219. package/lib/esm/domain/index.js.map +0 -1
  220. package/lib/esm/interfaces/PathType.js +0 -2
  221. package/lib/esm/interfaces/PathType.js.map +0 -1
  222. package/lib/esm/interfaces/PlatformAdapter.js +0 -2
  223. package/lib/esm/interfaces/PlatformAdapter.js.map +0 -1
  224. package/lib/esm/interfaces/index.js +0 -18
  225. package/lib/esm/interfaces/index.js.map +0 -1
  226. package/lib/esm/middlewares/index.js +0 -4
  227. package/lib/esm/middlewares/index.js.map +0 -1
  228. package/lib/esm/services/FakeRawDriver.js +0 -22
  229. package/lib/esm/services/FakeRawDriver.js.map +0 -1
  230. package/lib/esm/services/index.js +0 -9
  231. package/lib/esm/services/index.js.map +0 -1
  232. package/lib/esm/utils/index.js +0 -8
  233. package/lib/esm/utils/index.js.map +0 -1
  234. package/lib/types/config/index.d.ts +0 -3
  235. package/lib/types/config/interfaces/index.d.ts +0 -97
  236. package/lib/types/decorators/httpServer.d.ts +0 -28
  237. package/lib/types/decorators/httpsServer.d.ts +0 -28
  238. package/lib/types/decorators/index.d.ts +0 -14
  239. package/lib/types/decorators/method/acceptMime.d.ts +0 -19
  240. package/lib/types/decorators/method/endpointFn.d.ts +0 -9
  241. package/lib/types/decorators/method/location.d.ts +0 -1
  242. package/lib/types/decorators/method/redirect.d.ts +0 -1
  243. package/lib/types/decorators/method/route.d.ts +0 -1
  244. package/lib/types/decorators/method/view.d.ts +0 -25
  245. package/lib/types/decorators/multer/index.d.ts +0 -3
  246. package/lib/types/domain/index.d.ts +0 -6
  247. package/lib/types/interfaces/PathType.d.ts +0 -1
  248. package/lib/types/interfaces/PlatformAdapter.d.ts +0 -19
  249. package/lib/types/interfaces/index.d.ts +0 -17
  250. package/lib/types/middlewares/index.d.ts +0 -3
  251. package/lib/types/services/FakeRawDriver.d.ts +0 -15
  252. package/lib/types/services/index.d.ts +0 -8
  253. package/lib/types/utils/index.d.ts +0 -7
@@ -1,17 +1,21 @@
1
1
  "use strict";
2
- var _PlatformBuilder_injector, _PlatformBuilder_rootModule, _PlatformBuilder_promise, _PlatformBuilder_adapter, _PlatformBuilder_servers;
2
+ var _PlatformBuilder_injector, _PlatformBuilder_rootModule, _PlatformBuilder_adapter, _PlatformBuilder_promise, _PlatformBuilder_servers, _PlatformBuilder_listeners;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.PlatformBuilder = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const core_1 = require("@tsed/core");
7
7
  const di_1 = require("@tsed/di");
8
- const components_scan_1 = require("@tsed/components-scan");
9
8
  const platform_middlewares_1 = require("@tsed/platform-middlewares");
10
9
  const Platform_1 = require("../services/Platform");
11
10
  const PlatformApplication_1 = require("../services/PlatformApplication");
12
- const utils_1 = require("../utils");
13
11
  const getStaticsOptions_1 = require("../utils/getStaticsOptions");
14
12
  const getConfiguration_1 = require("../utils/getConfiguration");
13
+ const PlatformAdapter_1 = require("../services/PlatformAdapter");
14
+ const importProviders_1 = require("../utils/importProviders");
15
+ const createInjector_1 = require("../utils/createInjector");
16
+ const printRoutes_1 = require("../utils/printRoutes");
17
+ const createHttpServer_1 = require("../utils/createHttpServer");
18
+ const createHttpsServer_1 = require("../utils/createHttpsServer");
15
19
  /**
16
20
  * @platform
17
21
  */
@@ -22,29 +26,30 @@ class PlatformBuilder {
22
26
  this.current = new Date();
23
27
  _PlatformBuilder_injector.set(this, void 0);
24
28
  _PlatformBuilder_rootModule.set(this, void 0);
25
- _PlatformBuilder_promise.set(this, void 0);
26
29
  _PlatformBuilder_adapter.set(this, void 0);
30
+ _PlatformBuilder_promise.set(this, void 0);
27
31
  _PlatformBuilder_servers.set(this, void 0);
28
- (0, tslib_1.__classPrivateFieldSet)(this, _PlatformBuilder_rootModule, module, "f");
32
+ _PlatformBuilder_listeners.set(this, []);
33
+ tslib_1.__classPrivateFieldSet(this, _PlatformBuilder_rootModule, module, "f");
29
34
  const adapterKlass = adapter || PlatformBuilder.adapter;
30
35
  const name = (0, core_1.nameOf)(adapterKlass).replace("Platform", "").toLowerCase();
31
36
  const configuration = (0, getConfiguration_1.getConfiguration)(settings, module);
32
37
  configuration.PLATFORM_NAME = name;
33
38
  this.name = name;
34
- (0, tslib_1.__classPrivateFieldSet)(this, _PlatformBuilder_adapter, new adapterKlass(this), "f");
35
- (0, tslib_1.__classPrivateFieldSet)(this, _PlatformBuilder_injector, (0, utils_1.createInjector)({
36
- settings: configuration,
37
- providers: (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").providers
39
+ tslib_1.__classPrivateFieldSet(this, _PlatformBuilder_injector, (0, createInjector_1.createInjector)({
40
+ adapter: adapterKlass,
41
+ settings: configuration
38
42
  }), "f");
43
+ tslib_1.__classPrivateFieldSet(this, _PlatformBuilder_adapter, tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_injector, "f").get(PlatformAdapter_1.PlatformAdapter), "f");
39
44
  this.createHttpServers();
40
- (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").onInit && (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").onInit();
45
+ tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").onInit && tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").onInit();
41
46
  this.log("Injector created...");
42
47
  }
43
48
  get injector() {
44
- return (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_injector, "f");
49
+ return tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_injector, "f");
45
50
  }
46
51
  get rootModule() {
47
- return (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_injector, "f").get((0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_rootModule, "f"));
52
+ return tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_injector, "f").get(tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_rootModule, "f"));
48
53
  }
49
54
  get app() {
50
55
  return this.injector.get(PlatformApplication_1.PlatformApplication);
@@ -52,6 +57,9 @@ class PlatformBuilder {
52
57
  get platform() {
53
58
  return this.injector.get(Platform_1.Platform);
54
59
  }
60
+ get adapter() {
61
+ return tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_adapter, "f");
62
+ }
55
63
  /**
56
64
  * Return the settings configured by the decorator @@Configuration@@.
57
65
  *
@@ -146,8 +154,8 @@ class PlatformBuilder {
146
154
  (0, di_1.setLoggerLevel)(this.injector);
147
155
  await this.importProviders();
148
156
  await this.loadInjector();
149
- (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").useContext && (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").useContext();
150
- (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").useRouter && (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").useRouter();
157
+ tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").useContext && tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").useContext();
158
+ tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").useRouter && tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").useRouter();
151
159
  await this.loadRoutes();
152
160
  await this.logRoutes();
153
161
  return this;
@@ -156,7 +164,7 @@ class PlatformBuilder {
156
164
  const { injector } = this;
157
165
  this.log("Build providers");
158
166
  const container = (0, di_1.createContainer)();
159
- container.addProvider((0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_rootModule, "f"), {
167
+ container.addProvider(tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_rootModule, "f"), {
160
168
  type: "server:module",
161
169
  scope: di_1.ProviderScope.SINGLETON
162
170
  });
@@ -165,7 +173,7 @@ class PlatformBuilder {
165
173
  await this.callHook("$afterInit");
166
174
  }
167
175
  async listen(network = true) {
168
- if (!(0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_promise, "f")) {
176
+ if (!tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_promise, "f")) {
169
177
  await this.bootstrap();
170
178
  }
171
179
  await this.callHook("$beforeListen");
@@ -177,7 +185,10 @@ class PlatformBuilder {
177
185
  }
178
186
  async stop() {
179
187
  await this.callHook("$onDestroy");
180
- return this.injector.destroy();
188
+ await this.injector.destroy();
189
+ tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_listeners, "f").map((server) => {
190
+ return new Promise((resolve) => server.close(() => resolve(undefined)));
191
+ });
181
192
  }
182
193
  async ready() {
183
194
  const { startedAt } = this;
@@ -208,15 +219,15 @@ class PlatformBuilder {
208
219
  return this;
209
220
  }
210
221
  async bootstrap() {
211
- (0, tslib_1.__classPrivateFieldSet)(this, _PlatformBuilder_promise, (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_promise, "f") || this.runLifecycle(), "f");
212
- return (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_promise, "f");
222
+ tslib_1.__classPrivateFieldSet(this, _PlatformBuilder_promise, tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_promise, "f") || this.runLifecycle(), "f");
223
+ return tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_promise, "f");
213
224
  }
214
225
  async loadRoutes() {
215
226
  var _a;
216
- (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").beforeLoadRoutes && (await (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").beforeLoadRoutes());
227
+ tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").beforeLoadRoutes && (await tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").beforeLoadRoutes());
217
228
  // istanbul ignore next
218
229
  if (((_a = this.settings.logger) === null || _a === void 0 ? void 0 : _a.level) !== "off") {
219
- const { PlatformLogMiddleware } = await Promise.resolve().then(() => (0, tslib_1.__importStar)(require("@tsed/platform-log-middleware")));
230
+ const { PlatformLogMiddleware } = await Promise.resolve().then(() => tslib_1.__importStar(require("@tsed/platform-log-middleware")));
220
231
  this.app.use(PlatformLogMiddleware);
221
232
  }
222
233
  this.log("Load routes");
@@ -231,7 +242,7 @@ class PlatformBuilder {
231
242
  await this.callHook("$onRoutesInit");
232
243
  await this.loadStatics("$afterRoutesInit");
233
244
  await this.callHook("$afterRoutesInit");
234
- (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").afterLoadRoutes && (await (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").afterLoadRoutes());
245
+ tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").afterLoadRoutes && (await tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").afterLoadRoutes());
235
246
  }
236
247
  diff() {
237
248
  const ms = di_1.colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);
@@ -240,7 +251,7 @@ class PlatformBuilder {
240
251
  }
241
252
  async importProviders() {
242
253
  this.injector.logger.debug("Scan components");
243
- const providers = await (0, components_scan_1.importProviders)(this.injector.settings, ["imports", "mount", "componentsScan"]);
254
+ const providers = await (0, importProviders_1.importProviders)(this.injector.settings, ["imports", "mount", "componentsScan"]);
244
255
  const routes = providers.filter((provider) => !!provider.route).map(({ route, token }) => ({ route, token }));
245
256
  this.settings.set("routes", routes);
246
257
  this.log("Providers loaded...");
@@ -256,20 +267,20 @@ class PlatformBuilder {
256
267
  });
257
268
  }
258
269
  createHttpServers() {
259
- (0, tslib_1.__classPrivateFieldSet)(this, _PlatformBuilder_servers, [(0, utils_1.createHttpServer)((0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_injector, "f"), this.callback()), (0, utils_1.createHttpsServer)((0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_injector, "f"), this.callback())].filter(Boolean), "f");
270
+ tslib_1.__classPrivateFieldSet(this, _PlatformBuilder_servers, [(0, createHttpServer_1.createHttpServer)(tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_injector, "f"), this.callback()), (0, createHttpsServer_1.createHttpsServer)(tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_injector, "f"), this.callback())].filter(Boolean), "f");
260
271
  }
261
272
  async listenServers() {
262
- await Promise.all((0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_servers, "f").map((cb) => cb && cb()));
273
+ tslib_1.__classPrivateFieldSet(this, _PlatformBuilder_listeners, await Promise.all(tslib_1.__classPrivateFieldGet(this, _PlatformBuilder_servers, "f").map((cb) => cb && cb())), "f");
263
274
  }
264
275
  async logRoutes() {
265
276
  var _a;
266
277
  const { logger, platform } = this;
267
278
  this.log("Routes mounted...");
268
279
  if (!((_a = this.settings.logger) === null || _a === void 0 ? void 0 : _a.disableRoutesSummary) && !this.disableBootstrapLog) {
269
- logger.info((0, utils_1.printRoutes)(await this.injector.alterAsync("$logRoutes", platform.getRoutes())));
280
+ logger.info((0, printRoutes_1.printRoutes)(await this.injector.alterAsync("$logRoutes", platform.getRoutes())));
270
281
  }
271
282
  }
272
283
  }
273
284
  exports.PlatformBuilder = PlatformBuilder;
274
- _PlatformBuilder_injector = new WeakMap(), _PlatformBuilder_rootModule = new WeakMap(), _PlatformBuilder_promise = new WeakMap(), _PlatformBuilder_adapter = new WeakMap(), _PlatformBuilder_servers = new WeakMap();
285
+ _PlatformBuilder_injector = new WeakMap(), _PlatformBuilder_rootModule = new WeakMap(), _PlatformBuilder_adapter = new WeakMap(), _PlatformBuilder_promise = new WeakMap(), _PlatformBuilder_servers = new WeakMap(), _PlatformBuilder_listeners = new WeakMap();
275
286
  //# sourceMappingURL=PlatformBuilder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformBuilder.ts"],"names":[],"mappings":";;;;;AAAA,qCAAwC;AACxC,iCAA4G;AAC5G,2DAAsD;AACtD,qEAAiE;AACjE,mDAA8C;AAC9C,yEAAoE;AACpE,oCAA0F;AAE1F,kEAA6D;AAE7D,gEAA2D;AAI3D;;GAEG;AACH,MAAa,eAAe;IAa1B,YAAsB,OAAuD,EAAE,MAAY,EAAE,QAAqC;QAVzH,SAAI,GAAW,EAAE,CAAC;QACjB,cAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,YAAO,GAAG,IAAI,IAAI,EAAE,CAAC;QAE/B,4CAA2B;QAC3B,8CAAuB;QACvB,2CAAwB;QACxB,2CAAuC;QACvC,2CAAkC;QAGhC,oCAAA,IAAI,+BAAe,MAAM,MAAA,CAAC;QAC1B,MAAM,YAAY,GAAG,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC;QACxD,MAAM,IAAI,GAAG,IAAA,aAAM,EAAC,YAAY,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAExE,MAAM,aAAa,GAAG,IAAA,mCAAgB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACzD,aAAa,CAAC,aAAa,GAAG,IAAI,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,oCAAA,IAAI,4BAAY,IAAI,YAAY,CAAC,IAAI,CAAC,MAAA,CAAC;QAEvC,o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Provider, ProviderScope, setLoggerLevel} from \"@tsed/di\";\nimport {importProviders} from \"@tsed/components-scan\";\nimport {getMiddlewaresForHook} from \"@tsed/platform-middlewares\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {createHttpServer, createHttpsServer, createInjector, printRoutes} from \"../utils\";\nimport {PlatformStaticsSettings} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {getStaticsOptions} from \"../utils/getStaticsOptions\";\nimport {Route} from \"../interfaces/Route\";\nimport {getConfiguration} from \"../utils/getConfiguration\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {PlatformAdapter, PlatformBuilderSettings} from \"../interfaces/PlatformAdapter\";\n\n/**\n * @platform\n */\nexport class PlatformBuilder<App = TsED.Application, Router = TsED.Router> {\n public static adapter: Type<PlatformAdapter>;\n\n readonly name: string = \"\";\n protected startedAt = new Date();\n protected current = new Date();\n\n #injector: InjectorService;\n #rootModule: Type<any>;\n #promise: Promise<this>;\n #adapter: PlatformAdapter<App, Router>;\n #servers: (() => Promise<void>)[];\n\n protected constructor(adapter: Type<PlatformAdapter<App, Router>> | undefined, module: Type, settings: Partial<TsED.Configuration>) {\n this.#rootModule = module;\n const adapterKlass = adapter || PlatformBuilder.adapter;\n const name = nameOf(adapterKlass).replace(\"Platform\", \"\").toLowerCase();\n\n const configuration = getConfiguration(settings, module);\n configuration.PLATFORM_NAME = name;\n this.name = name;\n this.#adapter = new adapterKlass(this);\n\n this.#injector = createInjector({\n settings: configuration,\n providers: this.#adapter.providers\n });\n\n this.createHttpServers();\n\n this.#adapter.onInit && this.#adapter.onInit();\n\n this.log(\"Injector created...\");\n }\n\n get injector(): InjectorService {\n return this.#injector;\n }\n\n get rootModule(): any {\n return this.#injector.get(this.#rootModule);\n }\n\n get app(): PlatformApplication<App, Router> {\n return this.injector.get<PlatformApplication<App, Router>>(PlatformApplication)!;\n }\n\n get platform() {\n return this.injector.get<Platform>(Platform)!;\n }\n\n /**\n * Return the settings configured by the decorator @@Configuration@@.\n *\n * ```typescript\n * @Configuration({\n * rootDir: Path.resolve(__dirname),\n * port: 8000,\n * httpsPort: 8080,\n * mount: {\n * \"/rest\": \"${rootDir}/controllers/**\\/*.js\"\n * }\n * })\n * export class Server {\n * $onInit(){\n * console.log(this.settings); // {rootDir, port, httpsPort,...}\n * }\n * }\n * ```\n *\n * @returns {PlatformConfiguration}\n */\n get settings() {\n return this.injector.settings;\n }\n\n get logger() {\n return this.injector.logger;\n }\n\n get disableBootstrapLog() {\n return this.settings.logger?.disableBootstrapLog;\n }\n\n static create<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>) {\n return this.build(module, {\n httpsPort: false,\n httpPort: false,\n ...settings,\n disableComponentsScan: true\n });\n }\n\n static build<App = TsED.Application, Router = TsED.Router>(\n module: Type<any>,\n {adapter, ...settings}: PlatformBuilderSettings<App, Router>\n ) {\n return new PlatformBuilder(adapter, module, settings);\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>) {\n return this.build<App, Router>(module, settings).bootstrap();\n }\n\n callback(): (req: IncomingMessage, res: ServerResponse) => void;\n callback(req: IncomingMessage, res: ServerResponse): void;\n callback(req?: IncomingMessage, res?: ServerResponse) {\n if (req && res) {\n return this.app.callback()(req, res);\n }\n\n return this.app.callback();\n }\n\n log(...data: any[]) {\n return !this.disableBootstrapLog && this.logger.info(...data, this.diff());\n }\n\n /**\n * Add classes to the components list\n * @param classes\n */\n public addComponents(classes: any | any[]) {\n this.settings.componentsScan = this.settings.componentsScan.concat(classes);\n\n return this;\n }\n\n /**\n * Add classes decorated by @@Controller@@ to components container.\n *\n * ### Example\n *\n * ```typescript\n * @Controller('/ctrl')\n * class MyController{\n * }\n *\n * platform.addControllers('/rest', [MyController])\n * ```\n *\n * ::: tip\n * If the MyController class isn't decorated, the class will be ignored.\n * :::\n *\n * @param {string} endpoint\n * @param {any[]} controllers\n */\n public addControllers(endpoint: string, controllers: any | string | (any | string)[]) {\n this.settings.mount[endpoint] = (this.settings.mount[endpoint] || []).concat(controllers);\n }\n\n public async runLifecycle() {\n setLoggerLevel(this.injector);\n\n await this.importProviders();\n await this.loadInjector();\n\n this.#adapter.useContext && this.#adapter.useContext();\n this.#adapter.useRouter && this.#adapter.useRouter();\n\n await this.loadRoutes();\n await this.logRoutes();\n\n return this;\n }\n\n async loadInjector() {\n const {injector} = this;\n this.log(\"Build providers\");\n\n const container = createContainer();\n\n container.addProvider(this.#rootModule, {\n type: \"server:module\",\n scope: ProviderScope.SINGLETON\n });\n\n await injector.load(container);\n\n this.log(\"Settings and injector loaded...\");\n\n await this.callHook(\"$afterInit\");\n }\n\n async listen(network = true) {\n if (!this.#promise) {\n await this.bootstrap();\n }\n\n await this.callHook(\"$beforeListen\");\n\n if (network) {\n await this.listenServers();\n }\n\n await this.callHook(\"$afterListen\");\n\n await this.ready();\n }\n\n async stop() {\n await this.callHook(\"$onDestroy\");\n return this.injector.destroy();\n }\n\n public async ready() {\n const {startedAt} = this;\n\n await this.callHook(\"$onReady\");\n await this.injector.emit(\"$onServerReady\");\n\n this.log(`Started in ${new Date().getTime() - startedAt.getTime()} ms`);\n }\n\n async callHook(hook: string, ...args: any[]) {\n const {injector} = this;\n\n if (!this.disableBootstrapLog) {\n injector.logger.debug(`\\x1B[1mCall hook ${hook}\\x1B[22m`);\n }\n\n // Load middlewares for the given hook\n this.loadMiddlewaresFor(hook);\n\n // call hooks added by providers\n await injector.emit(hook, ...args);\n }\n\n async loadStatics(hook: string): Promise<void> {\n const statics = this.settings.get<PlatformStaticsSettings>(\"statics\");\n\n getStaticsOptions(statics).forEach(({path, options}) => {\n if (options.hook === hook) {\n this.platform.app.statics(path, options);\n }\n });\n }\n\n useProvider(token: Type<any>, settings?: Partial<IProvider>) {\n this.injector.addProvider(token, settings);\n\n return this;\n }\n\n async bootstrap() {\n this.#promise = this.#promise || this.runLifecycle();\n\n return this.#promise;\n }\n\n protected async loadRoutes() {\n this.#adapter.beforeLoadRoutes && (await this.#adapter.beforeLoadRoutes());\n\n // istanbul ignore next\n if (this.settings.logger?.level !== \"off\") {\n const {PlatformLogMiddleware} = await import(\"@tsed/platform-log-middleware\");\n this.app.use(PlatformLogMiddleware);\n }\n\n this.log(\"Load routes\");\n\n if (this.rootModule.$beforeRoutesInit) {\n await this.rootModule.$beforeRoutesInit();\n this.rootModule.$beforeRoutesInit = () => {};\n }\n\n await this.loadStatics(\"$beforeRoutesInit\");\n await this.callHook(\"$beforeRoutesInit\");\n\n const routes = this.injector.settings.get<Route[]>(\"routes\");\n\n this.platform.addRoutes(routes);\n\n await this.callHook(\"$onRoutesInit\");\n\n await this.loadStatics(\"$afterRoutesInit\");\n\n await this.callHook(\"$afterRoutesInit\");\n\n this.#adapter.afterLoadRoutes && (await this.#adapter.afterLoadRoutes());\n }\n\n protected diff() {\n const ms = colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);\n this.current = new Date();\n return ms;\n }\n\n protected async importProviders() {\n this.injector.logger.debug(\"Scan components\");\n\n const providers = await importProviders(this.injector.settings, [\"imports\", \"mount\", \"componentsScan\"]);\n const routes = providers.filter((provider) => !!provider.route).map(({route, token}) => ({route, token}));\n\n this.settings.set(\"routes\", routes);\n this.log(\"Providers loaded...\");\n }\n\n /**\n * Load middlewares from configuration for the given hook\n * @param hook\n * @protected\n */\n protected loadMiddlewaresFor(hook: string): void {\n return getMiddlewaresForHook(hook, this.settings, \"$beforeRoutesInit\").forEach(({use}) => {\n this.app.use(use);\n });\n }\n\n protected createHttpServers() {\n this.#servers = [createHttpServer(this.#injector, this.callback()), createHttpsServer(this.#injector, this.callback())].filter(\n Boolean\n ) as any[];\n }\n\n protected async listenServers(): Promise<void> {\n await Promise.all(this.#servers.map((cb) => cb && cb()));\n }\n\n protected async logRoutes() {\n const {logger, platform} = this;\n\n this.log(\"Routes mounted...\");\n\n if (!this.settings.logger?.disableRoutesSummary && !this.disableBootstrapLog) {\n logger.info(printRoutes(await this.injector.alterAsync(\"$logRoutes\", platform.getRoutes())));\n }\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformBuilder.ts"],"names":[],"mappings":";;;;;AAAA,qCAAwC;AACxC,iCAA+G;AAC/G,qEAAiE;AACjE,mDAA8C;AAC9C,yEAAoE;AAEpE,kEAA6D;AAE7D,gEAA2D;AAE3D,iEAAqF;AACrF,8DAAyD;AACzD,4DAAuD;AACvD,sDAAiD;AACjD,gEAA2D;AAC3D,kEAA6D;AAG7D;;GAEG;AACH,MAAa,eAAe;IAa1B,YAAsB,OAAuD,EAAE,MAAY,EAAE,QAAqC;QAVzH,SAAI,GAAW,EAAE,CAAC;QACjB,cAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,YAAO,GAAG,IAAI,IAAI,EAAE,CAAC;QAC/B,4CAAoC;QACpC,8CAAgC;QAChC,2CAAgD;QAChD,2CAAwB;QACxB,2CAAmD;QACnD,qCAAwC,EAAE,EAAC;QAGzC,+BAAA,IAAI,+BAAe,MAAM,MAAA,CAAC;QAC1B,MAAM,YAAY,GAAuC,OAAO,IAAK,eAAe,CAAC,OAAe,CAAC;QACrG,MAAM,IAAI,GAAG,IAAA,aAAM,EAAC,YAAY,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAExE,MAAM,aAAa,GAAG,IAAA,mCAAgB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACzD,aAAa,CAAC,aAAa,GAAG,IAAI,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,+BAAA,IAAI,6BAAa,IAAA,+BAAc,EAAC;YAC9B,OAAO,EAAE,YAAY;YACrB,QAAQ,EAAE,aAAa;SACxB,CAAC,MAAA,CAAC;QAEH,+BAAA,IAAI,4BAAY,+BA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AE;YAC5E,MAAM,CAAC,IAAI,CAAC,IAAA,yBAAW,EAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;SAC9F;IACH,CAAC;CACF;AAvVD,0CAuVC","sourcesContent":["import {nameOf, Type} from \"@tsed/core\";\nimport {colors, createContainer, InjectorService, ProviderOpts, ProviderScope, setLoggerLevel} from \"@tsed/di\";\nimport {getMiddlewaresForHook} from \"@tsed/platform-middlewares\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformStaticsSettings} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {getStaticsOptions} from \"../utils/getStaticsOptions\";\nimport {Route} from \"../interfaces/Route\";\nimport {getConfiguration} from \"../utils/getConfiguration\";\nimport type {IncomingMessage, Server, ServerResponse} from \"http\";\nimport {PlatformAdapter, PlatformBuilderSettings} from \"../services/PlatformAdapter\";\nimport {importProviders} from \"../utils/importProviders\";\nimport {createInjector} from \"../utils/createInjector\";\nimport {printRoutes} from \"../utils/printRoutes\";\nimport {createHttpServer} from \"../utils/createHttpServer\";\nimport {createHttpsServer} from \"../utils/createHttpsServer\";\nimport type Https from \"https\";\n\n/**\n * @platform\n */\nexport class PlatformBuilder<App = TsED.Application, Router = TsED.Router> {\n public static adapter: Type<PlatformAdapter<any, any>>;\n\n readonly name: string = \"\";\n protected startedAt = new Date();\n protected current = new Date();\n readonly #injector: InjectorService;\n readonly #rootModule: Type<any>;\n readonly #adapter: PlatformAdapter<App, Router>;\n #promise: Promise<this>;\n #servers: (() => Promise<Server | Https.Server>)[];\n #listeners: (Server | Https.Server)[] = [];\n\n protected constructor(adapter: Type<PlatformAdapter<App, Router>> | undefined, module: Type, settings: Partial<TsED.Configuration>) {\n this.#rootModule = module;\n const adapterKlass: Type<PlatformAdapter<App, Router>> = adapter || (PlatformBuilder.adapter as any);\n const name = nameOf(adapterKlass).replace(\"Platform\", \"\").toLowerCase();\n\n const configuration = getConfiguration(settings, module);\n configuration.PLATFORM_NAME = name;\n this.name = name;\n\n this.#injector = createInjector({\n adapter: adapterKlass,\n settings: configuration\n });\n\n this.#adapter = this.#injector.get<PlatformAdapter<App, Router>>(PlatformAdapter)!;\n\n this.createHttpServers();\n\n this.#adapter.onInit && this.#adapter.onInit();\n\n this.log(\"Injector created...\");\n }\n\n get injector(): InjectorService {\n return this.#injector;\n }\n\n get rootModule(): any {\n return this.#injector.get(this.#rootModule);\n }\n\n get app(): PlatformApplication<App, Router> {\n return this.injector.get<PlatformApplication<App, Router>>(PlatformApplication)!;\n }\n\n get platform() {\n return this.injector.get<Platform>(Platform)!;\n }\n\n get adapter() {\n return this.#adapter;\n }\n\n /**\n * Return the settings configured by the decorator @@Configuration@@.\n *\n * ```typescript\n * @Configuration({\n * rootDir: Path.resolve(__dirname),\n * port: 8000,\n * httpsPort: 8080,\n * mount: {\n * \"/rest\": \"${rootDir}/controllers/**\\/*.js\"\n * }\n * })\n * export class Server {\n * $onInit(){\n * console.log(this.settings); // {rootDir, port, httpsPort,...}\n * }\n * }\n * ```\n *\n * @returns {PlatformConfiguration}\n */\n get settings() {\n return this.injector.settings;\n }\n\n get logger() {\n return this.injector.logger;\n }\n\n get disableBootstrapLog() {\n return this.settings.logger?.disableBootstrapLog;\n }\n\n static create<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>) {\n return this.build(module, {\n httpsPort: false,\n httpPort: false,\n ...settings,\n disableComponentsScan: true\n });\n }\n\n static build<App = TsED.Application, Router = TsED.Router>(\n module: Type<any>,\n {adapter, ...settings}: PlatformBuilderSettings<App, Router>\n ) {\n return new PlatformBuilder(adapter, module, settings);\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>) {\n return this.build<App, Router>(module, settings).bootstrap();\n }\n\n callback(): (req: IncomingMessage, res: ServerResponse) => void;\n callback(req: IncomingMessage, res: ServerResponse): void;\n callback(req?: IncomingMessage, res?: ServerResponse) {\n if (req && res) {\n return this.app.callback()(req, res);\n }\n\n return this.app.callback();\n }\n\n log(...data: any[]) {\n return !this.disableBootstrapLog && this.logger.info(...data, this.diff());\n }\n\n /**\n * Add classes to the components list\n * @param classes\n */\n public addComponents(classes: any | any[]) {\n this.settings.componentsScan = this.settings.componentsScan.concat(classes);\n\n return this;\n }\n\n /**\n * Add classes decorated by @@Controller@@ to components container.\n *\n * ### Example\n *\n * ```typescript\n * @Controller('/ctrl')\n * class MyController{\n * }\n *\n * platform.addControllers('/rest', [MyController])\n * ```\n *\n * ::: tip\n * If the MyController class isn't decorated, the class will be ignored.\n * :::\n *\n * @param {string} endpoint\n * @param {any[]} controllers\n */\n public addControllers(endpoint: string, controllers: any | string | (any | string)[]) {\n this.settings.mount[endpoint] = (this.settings.mount[endpoint] || []).concat(controllers);\n }\n\n public async runLifecycle() {\n setLoggerLevel(this.injector);\n\n await this.importProviders();\n await this.loadInjector();\n\n this.#adapter.useContext && this.#adapter.useContext();\n this.#adapter.useRouter && this.#adapter.useRouter();\n\n await this.loadRoutes();\n await this.logRoutes();\n\n return this;\n }\n\n async loadInjector() {\n const {injector} = this;\n this.log(\"Build providers\");\n\n const container = createContainer();\n\n container.addProvider(this.#rootModule, {\n type: \"server:module\",\n scope: ProviderScope.SINGLETON\n });\n\n await injector.load(container);\n\n this.log(\"Settings and injector loaded...\");\n\n await this.callHook(\"$afterInit\");\n }\n\n async listen(network = true) {\n if (!this.#promise) {\n await this.bootstrap();\n }\n\n await this.callHook(\"$beforeListen\");\n\n if (network) {\n await this.listenServers();\n }\n\n await this.callHook(\"$afterListen\");\n\n await this.ready();\n }\n\n async stop() {\n await this.callHook(\"$onDestroy\");\n await this.injector.destroy();\n\n this.#listeners.map((server) => {\n return new Promise((resolve) => server.close(() => resolve(undefined)));\n });\n }\n\n public async ready() {\n const {startedAt} = this;\n\n await this.callHook(\"$onReady\");\n await this.injector.emit(\"$onServerReady\");\n\n this.log(`Started in ${new Date().getTime() - startedAt.getTime()} ms`);\n }\n\n async callHook(hook: string, ...args: any[]) {\n const {injector} = this;\n\n if (!this.disableBootstrapLog) {\n injector.logger.debug(`\\x1B[1mCall hook ${hook}\\x1B[22m`);\n }\n\n // Load middlewares for the given hook\n this.loadMiddlewaresFor(hook);\n\n // call hooks added by providers\n await injector.emit(hook, ...args);\n }\n\n async loadStatics(hook: string): Promise<void> {\n const statics = this.settings.get<PlatformStaticsSettings>(\"statics\");\n\n getStaticsOptions(statics).forEach(({path, options}) => {\n if (options.hook === hook) {\n this.platform.app.statics(path, options);\n }\n });\n }\n\n useProvider(token: Type<any>, settings?: Partial<ProviderOpts>) {\n this.injector.addProvider(token, settings);\n\n return this;\n }\n\n async bootstrap() {\n this.#promise = this.#promise || this.runLifecycle();\n\n return this.#promise;\n }\n\n protected async loadRoutes() {\n this.#adapter.beforeLoadRoutes && (await this.#adapter.beforeLoadRoutes());\n\n // istanbul ignore next\n if (this.settings.logger?.level !== \"off\") {\n const {PlatformLogMiddleware} = await import(\"@tsed/platform-log-middleware\");\n this.app.use(PlatformLogMiddleware);\n }\n\n this.log(\"Load routes\");\n\n if (this.rootModule.$beforeRoutesInit) {\n await this.rootModule.$beforeRoutesInit();\n this.rootModule.$beforeRoutesInit = () => {};\n }\n\n await this.loadStatics(\"$beforeRoutesInit\");\n await this.callHook(\"$beforeRoutesInit\");\n\n const routes = this.injector.settings.get<Route[]>(\"routes\");\n\n this.platform.addRoutes(routes);\n\n await this.callHook(\"$onRoutesInit\");\n\n await this.loadStatics(\"$afterRoutesInit\");\n\n await this.callHook(\"$afterRoutesInit\");\n\n this.#adapter.afterLoadRoutes && (await this.#adapter.afterLoadRoutes());\n }\n\n protected diff() {\n const ms = colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);\n this.current = new Date();\n return ms;\n }\n\n protected async importProviders() {\n this.injector.logger.debug(\"Scan components\");\n\n const providers = await importProviders(this.injector.settings, [\"imports\", \"mount\", \"componentsScan\"]);\n const routes = providers.filter((provider) => !!provider.route).map(({route, token}) => ({route, token}));\n\n this.settings.set(\"routes\", routes);\n this.log(\"Providers loaded...\");\n }\n\n /**\n * Load middlewares from configuration for the given hook\n * @param hook\n * @protected\n */\n protected loadMiddlewaresFor(hook: string): void {\n return getMiddlewaresForHook(hook, this.settings, \"$beforeRoutesInit\").forEach(({use}) => {\n this.app.use(use);\n });\n }\n\n protected createHttpServers() {\n this.#servers = [createHttpServer(this.#injector, this.callback()), createHttpsServer(this.#injector, this.callback())].filter(\n Boolean\n ) as any[];\n }\n\n protected async listenServers(): Promise<void> {\n this.#listeners = await Promise.all(this.#servers.map((cb) => cb && cb()));\n }\n\n protected async logRoutes() {\n const {logger, platform} = this;\n\n this.log(\"Routes mounted...\");\n\n if (!this.settings.logger?.disableRoutesSummary && !this.disableBootstrapLog) {\n logger.info(printRoutes(await this.injector.alterAsync(\"$logRoutes\", platform.getRoutes())));\n }\n }\n}\n"]}
@@ -45,22 +45,18 @@ exports.createRouter = createRouter;
45
45
  * @ignore
46
46
  * @param injector
47
47
  * @param provider
48
+ * @param parentUseBefore
48
49
  */
49
- function buildRouter(injector, provider) {
50
+ function buildRouter(injector, provider, parentUseBefore = []) {
50
51
  const { middlewares: { useBefore }, children } = provider;
51
52
  // Controller lifecycle
52
53
  const router = createRouter(injector, provider);
53
54
  if (!router.isBuilt) {
54
55
  router.isBuilt = true;
55
56
  const platformMiddlewaresChain = injector.get(PlatformMiddlewaresChain_1.PlatformMiddlewaresChain);
56
- useBefore // Controller before-middleware
57
- .filter((o) => typeof o === "function")
58
- .forEach((middleware) => {
59
- router.use(middleware);
60
- });
61
57
  // build all endpoints and his middlewares
62
58
  (0, schema_1.getOperationsRoutes)(provider.token).forEach((operationRoute) => {
63
- const handlers = platformMiddlewaresChain === null || platformMiddlewaresChain === void 0 ? void 0 : platformMiddlewaresChain.get(provider, operationRoute);
59
+ const handlers = platformMiddlewaresChain === null || platformMiddlewaresChain === void 0 ? void 0 : platformMiddlewaresChain.get(provider, operationRoute, parentUseBefore);
64
60
  router.addRoute({
65
61
  handlers,
66
62
  token: operationRoute.token,
@@ -69,6 +65,7 @@ function buildRouter(injector, provider) {
69
65
  isFinal: operationRoute.isFinal
70
66
  });
71
67
  });
68
+ const middlewares = [...parentUseBefore, ...useBefore];
72
69
  // build children controllers
73
70
  children.forEach((child) => {
74
71
  const childProvider = injector.getProvider(child);
@@ -76,7 +73,7 @@ function buildRouter(injector, provider) {
76
73
  if (!childProvider) {
77
74
  throw new Error("Controller component not found in the ControllerRegistry");
78
75
  }
79
- router.use(childProvider.path, buildRouter(injector, childProvider));
76
+ router.use(childProvider.path, buildRouter(injector, childProvider, middlewares));
80
77
  });
81
78
  }
82
79
  return router;
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformControllerBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformControllerBuilder.ts"],"names":[],"mappings":";;;AACA,iCAAwE;AACxE,yCAAmE;AACnE,qEAAgE;AAChE,+DAA0D;AAE1D,mFAA8E;AAE9E,oBAAe,CAAC,cAAc,CAAC,iBAAY,CAAC,UAAU,EAAE,uCAAkB,EAAE;IAC1E,QAAQ,CAAC,QAA4B,EAAE,MAAW,EAAE,EAAC,QAAQ,EAAC;QAC5D,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,+BAAc,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;CACF,CAAC,CAAC;AAEH;;GAEG;AACH,SAAS,YAAY,CAAC,MAA0B;IAC9C,OAAO,CAAC,MAAM,KAAK,yBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACtF,CAAC;AAED;;GAEG;AACH,SAAgB,S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AmB,EAAmB,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE;YAC/E,MAAM,QAAQ,GAAG,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAE,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;YAEzE,MAAM,CAAC,QAAQ,CAAC;gBACd,QAAQ;gBACR,KAAK,EAAE,cAAc,CAAC,KAAK;gBAC3B,MAAM,EAAE,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC;gBAC3C,IAAI,EAAE,cAAc,CAAC,IAAI;gBACzB,OAAO,EAAE,cAAc,CAAC,OAAO;aAChC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,6BAA6B;QAC7B,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAgB,EAAE,EAAE;YACpC,MAAM,aAAa,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAuB,CAAC;YAExE,0BAA0B;YAC1B,IAAI,CAAC,aAAa,EAAE;gBAClB,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;aAC7E;YAED,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA/CD,kCA+CC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {GlobalProviders, InjectorService, ProviderType} from \"@tsed/di\";\nimport {getOperationsRoutes, OperationMethods} from \"@tsed/schema\";\nimport {ControllerProvider} from \"../domain/ControllerProvider\";\nimport {PlatformRouter} from \"../services/PlatformRouter\";\nimport {EndpointMetadata} from \"../domain/EndpointMetadata\";\nimport {PlatformMiddlewaresChain} from \"../services/PlatformMiddlewaresChain\";\n\nGlobalProviders.createRegistry(ProviderType.CONTROLLER, ControllerProvider, {\n onInvoke(provider: ControllerProvider, locals: any, {injector}) {\n const router = createRouter(injector, provider);\n locals.set(PlatformRouter, router);\n }\n});\n\n/**\n * @ignore\n */\nfunction formatMethod(method: string | undefined) {\n return (method === OperationMethods.CUSTOM ? \"use\" : method || \"use\").toLowerCase();\n}\n\n/**\n * @ignore\n */\nexport function getRouter(injector: InjectorService, provider: ControllerProvider) {\n return injector.get(provider.tokenRouter)!;\n}\n\n/**\n * @ignore\n */\nexport function createRouter(injector: InjectorService, provider: ControllerProvider): PlatformRouter {\n const token = provider.tokenRouter;\n\n if (injector.has(token)) {\n return getRouter(injector, provider);\n }\n\n const router = PlatformRouter.create(injector, provider.routerOptions);\n\n return injector\n .add(token, {\n useValue: router\n })\n .invoke<PlatformRouter>(token);\n}\n\n/**\n * @ignore\n * @param injector\n * @param provider\n */\nexport function buildRouter(injector: InjectorService, provider: ControllerProvider) {\n const {\n middlewares: {useBefore},\n children\n } = provider;\n\n // Controller lifecycle\n const router = createRouter(injector, provider);\n\n if (!router.isBuilt) {\n router.isBuilt = true;\n\n const platformMiddlewaresChain = injector.get<PlatformMiddlewaresChain>(PlatformMiddlewaresChain);\n\n useBefore // Controller before-middleware\n .filter((o) => typeof o === \"function\")\n .forEach((middleware: any) => {\n router.use(middleware);\n });\n\n // build all endpoints and his middlewares\n getOperationsRoutes<EndpointMetadata>(provider.token).forEach((operationRoute) => {\n const handlers = platformMiddlewaresChain?.get(provider, operationRoute);\n\n router.addRoute({\n handlers,\n token: operationRoute.token,\n method: formatMethod(operationRoute.method),\n path: operationRoute.path,\n isFinal: operationRoute.isFinal\n });\n });\n\n // build children controllers\n children.forEach((child: Type<any>) => {\n const childProvider = injector.getProvider(child) as ControllerProvider;\n\n /* istanbul ignore next */\n if (!childProvider) {\n throw new Error(\"Controller component not found in the ControllerRegistry\");\n }\n\n router.use(childProvider.path, buildRouter(injector, childProvider));\n });\n }\n\n return router;\n}\n"]}
1
+ {"version":3,"file":"PlatformControllerBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformControllerBuilder.ts"],"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AAI,EAAE,WAAW,CAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;QACpF,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA1CD,kCA0CC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {GlobalProviders, InjectorService, ProviderType} from \"@tsed/di\";\nimport {getOperationsRoutes, OperationMethods} from \"@tsed/schema\";\nimport {ControllerProvider} from \"../domain/ControllerProvider\";\nimport {PlatformRouter} from \"../services/PlatformRouter\";\nimport {PlatformMiddlewaresChain} from \"../services/PlatformMiddlewaresChain\";\n\nGlobalProviders.createRegistry(ProviderType.CONTROLLER, ControllerProvider, {\n onInvoke(provider: ControllerProvider, locals: any, {injector}) {\n const router = createRouter(injector, provider);\n locals.set(PlatformRouter, router);\n }\n});\n\n/**\n * @ignore\n */\nfunction formatMethod(method: string | undefined) {\n return (method === OperationMethods.CUSTOM ? \"use\" : method || \"use\").toLowerCase();\n}\n\n/**\n * @ignore\n */\nexport function getRouter(injector: InjectorService, provider: ControllerProvider) {\n return injector.get(provider.tokenRouter)!;\n}\n\n/**\n * @ignore\n */\nexport function createRouter(injector: InjectorService, provider: ControllerProvider): PlatformRouter {\n const token = provider.tokenRouter;\n\n if (injector.has(token)) {\n return getRouter(injector, provider);\n }\n\n const router = PlatformRouter.create(injector, provider.routerOptions);\n\n return injector\n .add(token, {\n useValue: router\n })\n .invoke<PlatformRouter>(token);\n}\n\n/**\n * @ignore\n * @param injector\n * @param provider\n * @param parentUseBefore\n */\nexport function buildRouter(injector: InjectorService, provider: ControllerProvider, parentUseBefore: any[] = []) {\n const {\n middlewares: {useBefore},\n children\n } = provider;\n\n // Controller lifecycle\n const router = createRouter(injector, provider);\n\n if (!router.isBuilt) {\n router.isBuilt = true;\n\n const platformMiddlewaresChain = injector.get<PlatformMiddlewaresChain>(PlatformMiddlewaresChain);\n\n // build all endpoints and his middlewares\n getOperationsRoutes(provider.token).forEach((operationRoute) => {\n const handlers = platformMiddlewaresChain?.get(provider, operationRoute, parentUseBefore);\n\n router.addRoute({\n handlers,\n token: operationRoute.token,\n method: formatMethod(operationRoute.method),\n path: operationRoute.path,\n isFinal: operationRoute.isFinal\n });\n });\n\n const middlewares: any[] = [...parentUseBefore, ...useBefore];\n // build children controllers\n children.forEach((child: Type<any>) => {\n const childProvider = injector.getProvider(child) as ControllerProvider;\n\n /* istanbul ignore next */\n if (!childProvider) {\n throw new Error(\"Controller component not found in the ControllerRegistry\");\n }\n\n router.use(childProvider.path, buildRouter(injector, childProvider, middlewares));\n });\n }\n\n return router;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformMulterSettings.js","sourceRoot":"","sources":["../../../../src/config/interfaces/PlatformMulterSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {Request} from \"express\";\nimport {FileFilterCallback} from \"multer\";\nimport {Readable} from \"stream\";\n\ndeclare global {\n namespace TsED {\n export interface MulterFile {\n /** Name of the form field associated with this file. */\n fieldname: string;\n /** Name of the file on the uploader's computer. */\n originalname: string;\n /** Value of the `Content-Type` header for this file. */\n mimetype: string;\n /** Size of the file in bytes. */\n size: number;\n /**\n * A readable stream of this file. Only available to the `_handleFile`\n * callback for custom `StorageEngine`s.\n */\n stream: Readable;\n /** `DiskStorage` only: Directory to which this file has been uploaded. */\n destination: string;\n /** `DiskStorage` only: Name of this file within `destination`. */\n filename: string;\n /** `DiskStorage` only: Full path to the uploaded file. */\n path: string;\n /** `MemoryStorage` only: A Buffer containing the entire file. */\n buffer: Buffer;\n }\n\n export interface MulterStorageEngine {}\n\n export interface MulterOptions {\n /**\n * A `StorageEngine` responsible for processing files uploaded via Multer.\n * Takes precedence over `dest`.\n */\n storage?: MulterStorageEngine;\n /**\n * The destination directory for uploaded files. If `storage` is not set\n * and `dest` is, Multer will create a `DiskStorage` instance configured\n * to store files at `dest` with random filenames.\n *\n * Ignored if `storage` is set.\n */\n dest?: string;\n /**\n * An object specifying various limits on incoming data. This object is\n * passed to Busboy directly, and the details of properties can be found\n * at https://github.com/mscdex/busboy#busboy-methods.\n */\n limits?: {\n /** Maximum size of each form field name in bytes. (Default: 100) */\n fieldNameSize?: number;\n /** Maximum size of each form field value in bytes. (Default: 1048576) */\n fieldSize?: number;\n /** Maximum number of non-file form fields. (Default: Infinity) */\n fields?: number;\n /** Maximum size of each file in bytes. (Default: Infinity) */\n fileSize?: number;\n /** Maximum number of file fields. (Default: Infinity) */\n files?: number;\n /** Maximum number of parts (non-file fields + files). (Default: Infinity) */\n parts?: number;\n /** Maximum number of headers. (Default: 2000) */\n headerPairs?: number;\n };\n /** Preserve the full path of the original filename rather than the basename. (Default: false) */\n preservePath?: boolean;\n /**\n * Optional function to control which files are uploaded. This is called\n * for every file that is processed.\n *\n * @param req The Express `Request` object.\n * @param file Object containing information about the processed file.\n * @param callback a function to control which files should be uploaded and which should be skipped.\n */\n fileFilter?(req: Request, file: MulterFile, callback: FileFilterCallback): void;\n }\n\n export interface MulterField {\n name: string;\n maxCount?: number;\n }\n\n export type MulterHandler = (req: any, res: any) => Promise<any>;\n\n export interface Multer {\n /**\n * Returns middleware that processes a single file associated with the\n * given form field.\n *\n * The `Request` object will be populated with a `file` object containing\n * information about the processed file.\n *\n * @param fieldName Name of the multipart form field to process.\n */\n single(fieldName: string): MulterHandler;\n\n /**\n * Returns middleware that processes multiple files sharing the same field\n * name.\n *\n * The `Request` object will be populated with a `files` array containing\n * an information object for each processed file.\n *\n * @param fieldName Shared name of the multipart form fields to process.\n * @param maxCount Optional. Maximum number of files to process. (default: Infinity)\n * @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if more than `maxCount` files are associated with `fieldName`\n */\n array(fieldName: string, maxCount?: number): MulterHandler;\n\n /**\n * Returns middleware that processes multiple files associated with the\n * given form fields.\n *\n * The `Request` object will be populated with a `files` object which\n * maps each field name to an array of the associated file information\n * objects.\n *\n * @param fields Array of `Field` objects describing multipart form fields to process.\n * @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if more than `maxCount` files are associated with `fieldName` for any field.\n */\n fields(fields: MulterField[]): MulterHandler;\n\n /**\n * Returns middleware that processes all files contained in the multipart\n * request.\n *\n * The `Request` object will be populated with a `files` array containing\n * an information object for each processed file.\n */\n any(): MulterHandler;\n\n /**\n * Returns middleware that accepts only non-file multipart form fields.\n *\n * @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if any file is encountered.\n */\n none(): MulterHandler;\n }\n }\n}\n\nexport type PlatformMulter = TsED.Multer;\nexport type PlatformMulterSettings = TsED.MulterOptions;\nexport type PlatformMulterFile = TsED.MulterFile;\nexport type PlatformMulterField = TsED.MulterField;\n"]}
1
+ {"version":3,"file":"PlatformMulterSettings.js","sourceRoot":"","sources":["../../../../src/config/interfaces/PlatformMulterSettings.ts"],"names":[],"mappings":"","sourcesContent":["import type {Express} from \"express\";\nimport type multer from \"multer\";\n\ndeclare global {\n namespace TsED {\n export type MulterFile = Express.Multer.File;\n export type MulterStorageEngine = multer.StorageEngine;\n export type MulterOptions = multer.Options;\n export type MulterField = multer.Field;\n export type Multer = multer.Multer;\n }\n}\n\nexport type PlatformMulter = TsED.Multer;\nexport type PlatformMulterSettings = TsED.MulterOptions;\nexport type PlatformMulterFile = TsED.MulterFile;\nexport type PlatformMulterField = TsED.MulterField;\n"]}
@@ -170,12 +170,12 @@ let PlatformConfiguration = class PlatformConfiguration extends di_1.DIConfigura
170
170
  };
171
171
  }
172
172
  };
173
- PlatformConfiguration = (0, tslib_1.__decorate)([
173
+ PlatformConfiguration = tslib_1.__decorate([
174
174
  (0, di_1.Injectable)({
175
175
  scope: di_1.ProviderScope.SINGLETON,
176
176
  global: true
177
177
  }),
178
- (0, tslib_1.__metadata)("design:paramtypes", [])
178
+ tslib_1.__metadata("design:paramtypes", [])
179
179
  ], PlatformConfiguration);
180
180
  exports.PlatformConfiguration = PlatformConfiguration;
181
181
  //# sourceMappingURL=PlatformConfiguration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformConfiguration.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ACN,OAAO,GAAG,CAAC;YACb,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA1MY,qBAAqB;IAJjC,IAAA,eAAU,EAAC;QACV,KAAK,EAAE,kBAAa,CAAC,SAAS;QAC9B,MAAM,EAAE,IAAI;KACb,CAAC;;GACW,qBAAqB,CA0MjC;AA1MY,sDAAqB","sourcesContent":["import {Env, getHostInfoFromPort} from \"@tsed/core\";\nimport {DIConfiguration, Injectable, ProviderScope} from \"@tsed/di\";\nimport {$log} from \"@tsed/logger\";\nimport Https from \"https\";\nimport {EndpointDirectoriesSettings, PlatformLoggerSettings} from \"../interfaces\";\nimport {ConverterSettings} from \"../interfaces/ConverterSettings\";\n\nconst rootDir = process.cwd();\n\n/**\n * `PlatformConfiguration` contains all information about your Server configuration.\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n global: true\n})\nexport class PlatformConfiguration extends DIConfiguration {\n constructor() {\n super({rootDir});\n }\n\n get version() {\n return this.getRaw(\"version\");\n }\n\n set version(v: string) {\n this.setRaw(\"version\", v);\n }\n\n get rootDir() {\n return this.getRaw(\"rootDir\");\n }\n\n set rootDir(value: string) {\n this.setRaw(\"rootDir\", value);\n }\n\n get port(): string | number | false {\n return this.httpPort;\n }\n\n set port(value: string | number | false) {\n this.httpPort = value;\n }\n\n get httpsOptions(): Https.ServerOptions {\n return this.getRaw(\"httpsOptions\");\n }\n\n set httpsOptions(value: Https.ServerOptions) {\n this.setRaw(\"httpsOptions\", value);\n }\n\n get httpPort(): string | number | false {\n return this.getRaw(\"httpPort\");\n }\n\n set httpPort(value: string | number | false) {\n this.setRaw(\"httpPort\", value);\n }\n\n get httpsPort(): string | number | false {\n return this.getRaw(\"httpsPort\");\n }\n\n set httpsPort(value: string | number | false) {\n this.setRaw(\"httpsPort\", value);\n }\n\n get env(): Env {\n return this.getRaw(\"env\");\n }\n\n set env(value: Env) {\n this.setRaw(\"env\", value);\n }\n\n get mount(): EndpointDirectoriesSettings {\n return this.get(\"mount\");\n }\n\n set mount(value: EndpointDirectoriesSettings) {\n this.setRaw(\"mount\", value);\n }\n\n get componentsScan(): string[] {\n return this.resolve(this.getRaw(\"componentsScan\"));\n }\n\n set componentsScan(value: string[]) {\n this.setRaw(\"componentsScan\", value);\n }\n\n get statics(): EndpointDirectoriesSettings {\n return this.getRaw(\"statics\") || this.getRaw(\"serveStatic\") || {};\n }\n\n set statics(value: EndpointDirectoriesSettings) {\n this.setRaw(\"statics\", value);\n }\n\n get acceptMimes(): string[] {\n return this.getRaw(\"acceptMimes\");\n }\n\n set acceptMimes(value: string[]) {\n this.setRaw(\"acceptMimes\", value || []);\n }\n\n get debug(): boolean {\n return this.logger.level === \"debug\";\n }\n\n set debug(debug: boolean) {\n this.logger = {...this.logger, level: debug ? \"debug\" : \"info\"};\n }\n\n get converter(): Partial<ConverterSettings> {\n return this.get(\"converter\") || {};\n }\n\n set converter(options: Partial<ConverterSettings>) {\n this.setRaw(\"converter\", options);\n }\n\n get logger(): Partial<PlatformLoggerSettings> {\n return this.get(\"logger\");\n }\n\n set logger(value: Partial<PlatformLoggerSettings>) {\n const logger = {...this.logger, ...value};\n logger.debug = logger.level === \"debug\";\n\n this.setRaw(\"logger\", logger);\n this.setRaw(\"debug\", logger.debug);\n\n if (logger.format) {\n $log.appenders.set(\"stdout\", {\n type: \"stdout\",\n levels: [\"info\", \"debug\"],\n layout: {\n type: \"pattern\",\n pattern: logger.format\n }\n });\n\n $log.appenders.set(\"stderr\", {\n levels: [\"trace\", \"fatal\", \"error\", \"warn\"],\n type: \"stderr\",\n layout: {\n type: \"pattern\",\n pattern: logger.format\n }\n });\n }\n }\n\n get exclude() {\n return this.get(\"exclude\");\n }\n\n set exclude(exclude: string[]) {\n this.setRaw(\"exclude\", exclude);\n }\n\n get additionalProperties() {\n return this.get(\"converter.additionalProperties\") === \"accept\";\n }\n\n /**\n *\n * @returns {string|number}\n */\n getHttpPort(): ReturnType<typeof getHostInfoFromPort> {\n return getHostInfoFromPort(\"http\", this.getRaw(\"httpPort\"));\n }\n\n /**\n *\n * @param settings\n */\n setHttpPort(settings: {address: string; port: number}) {\n this.setRaw(\"httpPort\", `${settings.address}:${settings.port}`);\n }\n\n /**\n *\n * @returns {string|number}\n */\n getHttpsPort() {\n return getHostInfoFromPort(\"https\", this.getRaw(\"httpsPort\"));\n }\n\n /**\n *\n * @param settings\n */\n setHttpsPort(settings: {address: string; port: number}) {\n this.setRaw(\"httpsPort\", `${settings.address}:${settings.port}`);\n }\n\n getBestHost() {\n const {httpsPort, httpPort} = this;\n\n if (httpsPort) {\n return this.getHttpsPort();\n }\n\n if (httpPort) {\n return this.getHttpPort();\n }\n\n return {\n toString() {\n return \"/\";\n }\n };\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformConfiguration.js","sourceRoot":"","sources":["../../../../src/config/services/PlatformConfiguration.ts"],"names":[],"mappings":";;;;AAAA,qCAAoD;AACpD,iCAAoE;AACpE,yCAAkC;AAMlC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAE9B;;GAEG;AAKH,IAAa,qBAAqB,GAAlC,MAAa,qBAAsB,SAAQ,oBAAe;IACxD;QACE,KAAK,CAAC,EAAC,OAAO,EAAC,CAAC,CAAC;IACnB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IAED,IAAI,OAAO,CAAC,CAAS;QACnB,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IAED,IAAI,OAAO,CAAC,KAAa;QACvB,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,IAAI,CAAC,KAA8B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AO,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;IAChE,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,QAAyC;QACpD,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,WAAW;QACT,MAAM,EAAC,SAAS,EAAE,QAAQ,EAAC,GAAG,IAAI,CAAC;QAEnC,IAAI,SAAS,EAAE;YACb,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC;SAC5B;QAED,IAAI,QAAQ,EAAE;YACZ,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;SAC3B;QAED,OAAO;YACL,QAAQ;gBACN,OAAO,GAAG,CAAC;YACb,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA1MY,qBAAqB;IAJjC,IAAA,eAAU,EAAC;QACV,KAAK,EAAE,kBAAa,CAAC,SAAS;QAC9B,MAAM,EAAE,IAAI;KACb,CAAC;;GACW,qBAAqB,CA0MjC;AA1MY,sDAAqB","sourcesContent":["import {Env, getHostInfoFromPort} from \"@tsed/core\";\nimport {DIConfiguration, Injectable, ProviderScope} from \"@tsed/di\";\nimport {$log} from \"@tsed/logger\";\nimport Https from \"https\";\nimport {ConverterSettings} from \"../interfaces/ConverterSettings\";\nimport {EndpointDirectoriesSettings} from \"../interfaces/EndpointDirectoriesSettings\";\nimport {PlatformLoggerSettings} from \"../interfaces/PlatformLoggerSettings\";\n\nconst rootDir = process.cwd();\n\n/**\n * `PlatformConfiguration` contains all information about your Server configuration.\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n global: true\n})\nexport class PlatformConfiguration extends DIConfiguration {\n constructor() {\n super({rootDir});\n }\n\n get version() {\n return this.getRaw(\"version\");\n }\n\n set version(v: string) {\n this.setRaw(\"version\", v);\n }\n\n get rootDir() {\n return this.getRaw(\"rootDir\");\n }\n\n set rootDir(value: string) {\n this.setRaw(\"rootDir\", value);\n }\n\n get port(): string | number | false {\n return this.httpPort;\n }\n\n set port(value: string | number | false) {\n this.httpPort = value;\n }\n\n get httpsOptions(): Https.ServerOptions {\n return this.getRaw(\"httpsOptions\");\n }\n\n set httpsOptions(value: Https.ServerOptions) {\n this.setRaw(\"httpsOptions\", value);\n }\n\n get httpPort(): string | number | false {\n return this.getRaw(\"httpPort\");\n }\n\n set httpPort(value: string | number | false) {\n this.setRaw(\"httpPort\", value);\n }\n\n get httpsPort(): string | number | false {\n return this.getRaw(\"httpsPort\");\n }\n\n set httpsPort(value: string | number | false) {\n this.setRaw(\"httpsPort\", value);\n }\n\n get env(): Env {\n return this.getRaw(\"env\");\n }\n\n set env(value: Env) {\n this.setRaw(\"env\", value);\n }\n\n get mount(): EndpointDirectoriesSettings {\n return this.get(\"mount\");\n }\n\n set mount(value: EndpointDirectoriesSettings) {\n this.setRaw(\"mount\", value);\n }\n\n get componentsScan(): string[] {\n return this.resolve(this.getRaw(\"componentsScan\"));\n }\n\n set componentsScan(value: string[]) {\n this.setRaw(\"componentsScan\", value);\n }\n\n get statics(): EndpointDirectoriesSettings {\n return this.getRaw(\"statics\") || this.getRaw(\"serveStatic\") || {};\n }\n\n set statics(value: EndpointDirectoriesSettings) {\n this.setRaw(\"statics\", value);\n }\n\n get acceptMimes(): string[] {\n return this.getRaw(\"acceptMimes\");\n }\n\n set acceptMimes(value: string[]) {\n this.setRaw(\"acceptMimes\", value || []);\n }\n\n get debug(): boolean {\n return this.logger.level === \"debug\";\n }\n\n set debug(debug: boolean) {\n this.logger = {...this.logger, level: debug ? \"debug\" : \"info\"};\n }\n\n get converter(): Partial<ConverterSettings> {\n return this.get(\"converter\") || {};\n }\n\n set converter(options: Partial<ConverterSettings>) {\n this.setRaw(\"converter\", options);\n }\n\n get logger(): Partial<PlatformLoggerSettings> {\n return this.get(\"logger\");\n }\n\n set logger(value: Partial<PlatformLoggerSettings>) {\n const logger = {...this.logger, ...value};\n logger.debug = logger.level === \"debug\";\n\n this.setRaw(\"logger\", logger);\n this.setRaw(\"debug\", logger.debug);\n\n if (logger.format) {\n $log.appenders.set(\"stdout\", {\n type: \"stdout\",\n levels: [\"info\", \"debug\"],\n layout: {\n type: \"pattern\",\n pattern: logger.format\n }\n });\n\n $log.appenders.set(\"stderr\", {\n levels: [\"trace\", \"fatal\", \"error\", \"warn\"],\n type: \"stderr\",\n layout: {\n type: \"pattern\",\n pattern: logger.format\n }\n });\n }\n }\n\n get exclude() {\n return this.get(\"exclude\");\n }\n\n set exclude(exclude: string[]) {\n this.setRaw(\"exclude\", exclude);\n }\n\n get additionalProperties() {\n return this.get(\"converter.additionalProperties\") === \"accept\";\n }\n\n /**\n *\n * @returns {string|number}\n */\n getHttpPort(): ReturnType<typeof getHostInfoFromPort> {\n return getHostInfoFromPort(\"http\", this.getRaw(\"httpPort\"));\n }\n\n /**\n *\n * @param settings\n */\n setHttpPort(settings: {address: string; port: number}) {\n this.setRaw(\"httpPort\", `${settings.address}:${settings.port}`);\n }\n\n /**\n *\n * @returns {string|number}\n */\n getHttpsPort() {\n return getHostInfoFromPort(\"https\", this.getRaw(\"httpsPort\"));\n }\n\n /**\n *\n * @param settings\n */\n setHttpsPort(settings: {address: string; port: number}) {\n this.setRaw(\"httpsPort\", `${settings.address}:${settings.port}`);\n }\n\n getBestHost() {\n const {httpsPort, httpPort} = this;\n\n if (httpsPort) {\n return this.getHttpsPort();\n }\n\n if (httpPort) {\n return this.getHttpPort();\n }\n\n return {\n toString() {\n return \"/\";\n }\n };\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"multipartFile.js","sourceRoot":"","sources":["../../../../src/decorators/multer/multipartFile.ts"],"names":[],"mappings":";;;AAAA,qCAAyG;AACzG,2DAA2D;AAC3D,yCAAuD;AAEvD,yFAAwG;AAExG,SAAS,UAAU,CAAC,IAAY,EAAE,QAA4B;IAC5D,OAAO;QACL,MAAM,EAAE;YACN;gBACE,IAAI;gBACJ,QAAQ;aACT;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,SAAgB,aAAa,CAAC,IAAY,EAAE,QAAiB;IAC3D,OAAO,CAAC,GAAG,IAAyB,EAAQ,EAAE;QAC5C,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAC1C,MAAM,QAAQ,GAAG,eAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,KAAe,CAAC,KAAK,KAAK,CAAC;QAExF,IAAI,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAE,CAAC;QAEtD,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEtE,MAAM,UAAU,GAAG,IAAA,oBAAa,EAC9B,IAAA,eAAM,EAAC,IAAI,CAAC,EACZ,IAAA,0BAAmB,EAAC,IAAA,iBAAU,EAAC,mDAAwB,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrF,IAAA,0BAAQ,EAAC;YACP,SAAS,EAAE,4BAAU,CAAC,KAAK;YAC3B,QAAQ,EAAE,oBAAoB;YAC9B,UAAU;YACV,aAAa,EAAE,IAAI;SACpB,CAAC,CACH,CAAC;QAEF,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC;AAtBD,sCAsBC","sourcesContent":["import {DecoratorParameters, Metadata, StoreMerge, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {ParamTypes, UseParam} from \"@tsed/platform-params\";\nimport {Consumes, InFile, Returns} from \"@tsed/schema\";\nimport {PlatformMulterFile} from \"../../config/interfaces/PlatformMulterSettings\";\nimport {MulterInputOptions, PlatformMulterMiddleware} from \"../../middlewares/PlatformMulterMiddleware\";\n\nfunction mapOptions(name: string, maxCount: number | undefined): MulterInputOptions {\n return {\n fields: [\n {\n name,\n maxCount\n }\n ]\n };\n}\n\n/**\n * Define a parameter as Multipart file.\n *\n * ```typescript\n * import {Controller, Post} from \"@tsed/common\";\n * import {MulterOptions, MultipartFile} from \"@tsed/common\";\n * import {Multer} from \"@types/multer\";\n *\n * type MulterFile = Express.Multer.File;\n *\n * @Controller('/')\n * class MyCtrl {\n * @Post('/file')\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file2')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile, @MultipartFile(\"file2\") file2: MulterFile) {\n *\n * }\n *\n * @Post('/files')\n * private uploadFile(@MultipartFile(\"file1\") files: MulterFile[]) {\n *\n * }\n * }\n * ```\n *\n * > See the tutorial on the [multer configuration](/tutorials/multer.md).\n *\n * @param name\n * @param maxCount\n * @returns Function\n * @decorator\n * @input\n */\nexport function MultipartFile(name: string, maxCount?: number): ParameterDecorator {\n return (...args: DecoratorParameters): void => {\n const [target, propertyKey, index] = args;\n const multiple = Metadata.getParamTypes(target, propertyKey)[index as number] === Array;\n\n name = (typeof name === \"object\" ? undefined : name)!;\n\n const expression = [name, !multiple && \"0\"].filter(Boolean).join(\".\");\n\n const decorators = useDecorators(\n InFile(name),\n useMethodDecorators(StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))),\n UseParam({\n paramType: ParamTypes.FILES,\n dataPath: \"$ctx.request.files\",\n expression,\n useValidation: true\n })\n );\n\n decorators(...args);\n };\n}\n\nexport type MultipartFile = PlatformMulterFile;\n"]}
1
+ {"version":3,"file":"multipartFile.js","sourceRoot":"","sources":["../../../../src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tBD,sCAsBC","sourcesContent":["import {DecoratorParameters, Metadata, StoreMerge, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {ParamTypes, UseParam} from \"@tsed/platform-params\";\nimport {InFile} from \"@tsed/schema\";\nimport {PlatformMulterFile} from \"../../config/interfaces/PlatformMulterSettings\";\nimport {MulterInputOptions, PlatformMulterMiddleware} from \"../../middlewares/PlatformMulterMiddleware\";\n\nfunction mapOptions(name: string, maxCount: number | undefined): MulterInputOptions {\n return {\n fields: [\n {\n name,\n maxCount\n }\n ]\n };\n}\n\n/**\n * Define a parameter as Multipart file.\n *\n * ```typescript\n * import {Controller, Post} from \"@tsed/common\";\n * import {MulterOptions, MultipartFile} from \"@tsed/common\";\n * import {Multer} from \"@types/multer\";\n *\n * type MulterFile = Express.Multer.File;\n *\n * @Controller('/')\n * class MyCtrl {\n * @Post('/file')\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file2')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile, @MultipartFile(\"file2\") file2: MulterFile) {\n *\n * }\n *\n * @Post('/files')\n * private uploadFile(@MultipartFile(\"file1\") files: MulterFile[]) {\n *\n * }\n * }\n * ```\n *\n * > See the tutorial on the [multer configuration](/tutorials/multer.md).\n *\n * @param name\n * @param maxCount\n * @returns Function\n * @decorator\n * @input\n */\nexport function MultipartFile(name: string, maxCount?: number): ParameterDecorator {\n return (...args: DecoratorParameters): void => {\n const [target, propertyKey, index] = args;\n const multiple = Metadata.getParamTypes(target, propertyKey)[index as number] === Array;\n\n name = (typeof name === \"object\" ? undefined : name)!;\n\n const expression = [name, !multiple && \"0\"].filter(Boolean).join(\".\");\n\n const decorators = useDecorators(\n InFile(name),\n useMethodDecorators(StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))),\n UseParam({\n paramType: ParamTypes.FILES,\n dataPath: \"$ctx.request.files\",\n expression,\n useValidation: true\n })\n );\n\n decorators(...args);\n };\n}\n\nexport type MultipartFile = PlatformMulterFile;\n"]}
@@ -1,70 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EndpointMetadata = void 0;
4
- const tslib_1 = require("tslib");
5
- const core_1 = require("@tsed/core");
6
- const schema_1 = require("@tsed/schema");
7
- /**
8
- * EndpointMetadata contains metadata about a controller and his method.
9
- * Each annotation (@Get, @Body...) attached to a method are stored in a endpoint.
10
- * EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.
11
- *
12
- * Example :
13
- *
14
- * @Controller("/my-path")
15
- * provide MyClass {
16
- *
17
- * @Get("/")
18
- * @Authenticated()
19
- * public myMethod(){}
20
- * }
21
- *
22
- */
23
- let EndpointMetadata = class EndpointMetadata extends schema_1.JsonMethodStore {
24
- get targetName() {
25
- return (0, core_1.nameOf)(this.token);
26
- }
27
- get params() {
28
- return this.parameters;
29
- }
30
- get view() {
31
- return this.store.get("view");
32
- }
33
- set view(view) {
34
- this.store.set("view", view);
35
- }
36
- get acceptMimes() {
37
- return this.store.get("acceptMimes", []);
38
- }
39
- set acceptMimes(mimes) {
40
- this.store.set("acceptMimes", mimes);
41
- }
42
- /**
43
- * Get an endpoint.
44
- * @param target
45
- * @param propertyKey
46
- * @param descriptor
47
- */
48
- static get(target, propertyKey, descriptor) {
49
- descriptor = descriptor || (0, core_1.descriptorOf)((0, core_1.prototypeOf)(target), propertyKey);
50
- return schema_1.JsonEntityStore.from((0, core_1.prototypeOf)(target), propertyKey, descriptor);
51
- }
52
- addOperationPath(method, path, options = {}) {
53
- return this.operation.addOperationPath(method, path, options);
54
- }
55
- /**
56
- * Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.
57
- *
58
- * @param key
59
- * @returns {any}
60
- */
61
- get(key) {
62
- const ctrlValue = core_1.Store.from(this.target).get(key);
63
- return (0, core_1.deepMerge)(ctrlValue, this.store.get(key));
64
- }
65
- };
66
- EndpointMetadata = (0, tslib_1.__decorate)([
67
- (0, schema_1.JsonEntityComponent)(core_1.DecoratorTypes.METHOD)
68
- ], EndpointMetadata);
69
- exports.EndpointMetadata = EndpointMetadata;
4
+ var schema_1 = require("@tsed/schema");
5
+ Object.defineProperty(exports, "EndpointMetadata", { enumerable: true, get: function () { return schema_1.EndpointMetadata; } });
70
6
  //# sourceMappingURL=EndpointMetadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EndpointMetadata.js","sourceRoot":"","sources":["../../../src/domain/EndpointMetadata.ts"],"names":[],"mappings":";;;;AAAA,qCAAqG;AAErG,yCAAmF;AAYnF;;;;;;;;;;;;;;;GAeG;AAEH,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,wBAAe;IACnD,IAAI,UAAU;QACZ,OAAO,IAAA,aAAM,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,UAA6B,CAAC;IAC5C,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAwB,CAAC;IACvD,CAAC;IAED,IAAI,IAAI,CAAC,IAAyB;QAChC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAW,aAAa,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,WAAW,CAAC,KAAe;QAC7B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,MAAiB,EAAE,WAA4B,EAAE,UAA+B;QACzF,UAAU,GAAG,UAAU,IAAI,IAAA,mBAAY,EAAC,IAAA,kBAAW,EAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;QAE1E,OAAO,wBAAe,CAAC,IAAI,CAAmB,IAAA,kBAAW,EAAC,MAAM,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IAC9F,CAAC;IAED,gBAAgB,CAAC,MAAc,EAAE,IAAqB,EAAE,UAAe,EAAE;QACvE,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAU,GAAQ;QACnB,MAAM,SAAS,GAAG,YAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEnD,OAAO,IAAA,gBAAS,EAAI,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;CACF,CAAA;AApDY,gBAAgB;IAD5B,IAAA,4BAAmB,EAAC,qBAAc,CAAC,MAAM,CAAC;GAC9B,gBAAgB,CAoD5B;AApDY,4CAAgB","sourcesContent":["import {DecoratorTypes, deepMerge, descriptorOf, nameOf, prototypeOf, Store, Type} from \"@tsed/core\";\nimport {ParamMetadata} from \"@tsed/platform-params\";\nimport {JsonEntityComponent, JsonEntityStore, JsonMethodStore} from \"@tsed/schema\";\n\nexport interface EndpointViewOptions {\n path: string;\n options: any;\n}\n\nexport interface EndpointRedirectOptions {\n status: number | undefined;\n url: string;\n}\n\n/**\n * EndpointMetadata contains metadata about a controller and his method.\n * Each annotation (@Get, @Body...) attached to a method are stored in a endpoint.\n * EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.\n *\n * Example :\n *\n * @Controller(\"/my-path\")\n * provide MyClass {\n *\n * @Get(\"/\")\n * @Authenticated()\n * public myMethod(){}\n * }\n *\n */\n@JsonEntityComponent(DecoratorTypes.METHOD)\nexport class EndpointMetadata extends JsonMethodStore {\n get targetName(): string {\n return nameOf(this.token);\n }\n\n get params(): ParamMetadata[] {\n return this.parameters as ParamMetadata[];\n }\n\n get view(): EndpointViewOptions {\n return this.store.get(\"view\") as EndpointViewOptions;\n }\n\n set view(view: EndpointViewOptions) {\n this.store.set(\"view\", view);\n }\n\n get acceptMimes(): string[] {\n return this.store.get<string[]>(\"acceptMimes\", []);\n }\n\n set acceptMimes(mimes: string[]) {\n this.store.set(\"acceptMimes\", mimes);\n }\n\n /**\n * Get an endpoint.\n * @param target\n * @param propertyKey\n * @param descriptor\n */\n static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): EndpointMetadata {\n descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);\n\n return JsonEntityStore.from<EndpointMetadata>(prototypeOf(target), propertyKey, descriptor);\n }\n\n addOperationPath(method: string, path: string | RegExp, options: any = {}) {\n return this.operation.addOperationPath(method, path, options);\n }\n\n /**\n * Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.\n *\n * @param key\n * @returns {any}\n */\n get<T = any>(key: any): T {\n const ctrlValue = Store.from(this.target).get(key);\n\n return deepMerge<T>(ctrlValue, this.store.get(key));\n }\n}\n"]}
1
+ {"version":3,"file":"EndpointMetadata.js","sourceRoot":"","sources":["../../../src/domain/EndpointMetadata.ts"],"names":[],"mappings":";;;AAAA,uCAA8C;AAAtC,0GAAA,gBAAgB,OAAA","sourcesContent":["export {EndpointMetadata} from \"@tsed/schema\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":";;;AAAA,iCAAqE;AAGrE,yEAAoE;AACpE,iEAA4D;AAC5D,mEAA8D;AAiB9D,MAAa,eAAgB,SAAQ,cAAS;IAoB5C,YAAY,EACV,KAAK,EACL,QAAQ,EACR,iBAAiB,GAAG,EAAE,EACtB,aAAa,GAAG,mCAAgB,E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AO,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAS,CAAC;IAClC,CAAC;CACF;AAhID,0CAgIC","sourcesContent":["import {ContextMethods, DIContext, DIContextOptions} from \"@tsed/di\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {EndpointMetadata} from \"./EndpointMetadata\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\ndeclare global {\n namespace TsED {\n export interface Context extends PlatformContext {}\n }\n}\n\nexport interface PlatformContextOptions extends DIContextOptions {\n event: {\n response?: ServerResponse;\n request?: IncomingMessage;\n };\n ignoreUrlPatterns?: any[];\n endpoint?: EndpointMetadata;\n}\n\nexport class PlatformContext extends DIContext implements ContextMethods {\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n public endpoint: EndpointMetadata;\n /**\n * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n */\n public data: any;\n /**\n * The current @@PlatformResponse@@.\n */\n public response: PlatformResponse;\n /**\n * The current @@PlatformRequest@@.\n */\n public request: PlatformRequest;\n\n private ignoreUrlPatterns: RegExp[] = [];\n\n constructor({\n event,\n endpoint,\n ignoreUrlPatterns = [],\n ResponseKlass = PlatformResponse,\n RequestKlass = PlatformRequest,\n ...options\n }: PlatformContextOptions) {\n super({\n ...options,\n ignoreLog: () => {\n return this.ignoreUrlPatterns.find((reg) => !!this.url.match(reg));\n }\n });\n\n endpoint && (this.endpoint = endpoint);\n\n this.ignoreUrlPatterns = ignoreUrlPatterns.map((pattern: string | RegExp) =>\n typeof pattern === \"string\" ? new RegExp(pattern, \"gi\") : pattern\n );\n\n this.response = new ResponseKlass(event, this);\n this.request = new RequestKlass(event, this);\n\n this.response.request = this.request;\n this.request.response = this.response;\n\n this.request.request.$ctx = this;\n this.request.request.id = this.id;\n this.logger.url = this.url;\n\n this.container.set(PlatformResponse, this.response);\n this.container.set(PlatformRequest, this.request);\n this.container.set(PlatformContext, this);\n\n this.response.setHeader(\"x-request-id\", this.id);\n }\n\n get url() {\n return this.request.url;\n }\n\n get app() {\n return this.injector.get<PlatformApplication>(PlatformApplication)!;\n }\n\n async destroy() {\n await super.destroy();\n\n delete this.request?.request?.$ctx;\n\n this.response.destroy();\n this.request.destroy();\n\n // @ts-ignore\n delete this.endpoint;\n // @ts-ignore\n delete this.response;\n // @ts-ignore\n delete this.request;\n }\n\n isDone() {\n if (!this.request || !this.response) {\n return true;\n }\n\n if (this.request?.isAborted()) {\n return true;\n }\n\n return this.response?.isDone();\n }\n\n /**\n * Return the framework request instance (Express, Koa, etc...)\n */\n getRequest<Req = any>(): Req {\n return this.request.getRequest<Req>();\n }\n\n /**\n * Return the framework response instance (Express, Koa, etc...)\n */\n getResponse<Res = any>(): Res {\n return this.response.getResponse<Res>();\n }\n\n /**\n * Get Node.js request\n */\n getReq(): IncomingMessage {\n return this.request.getReq();\n }\n\n /**\n * Get Node.js response\n */\n getRes(): ServerResponse {\n return this.response.getRes();\n }\n\n /**\n * Return the original application instance.\n */\n getApp<T = any>(): T {\n return this.app.getApp() as any;\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":";;;AAAA,iCAAqE;AAGrE,yEAAoE;AACpE,iEAA4D;AAC5D,mEAA8D;AAiB9D,MAAa,eAAgB,SAAQ,cAAS;IAoB5C,YAAY,EACV,KAAK,EACL,QAAQ,EACR,iBAAiB,GAAG,EAAE,EACtB,aAAa,GAAG,mCAAgB,EAChC,YAAY,GAAG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,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAS,CAAC;IAClC,CAAC;CACF;AAhID,0CAgIC","sourcesContent":["import {ContextMethods, DIContext, DIContextOptions} from \"@tsed/di\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\ndeclare global {\n namespace TsED {\n export interface Context extends PlatformContext {}\n }\n}\n\nexport interface PlatformContextOptions extends DIContextOptions {\n event: {\n response?: ServerResponse;\n request?: IncomingMessage;\n };\n ignoreUrlPatterns?: any[];\n endpoint?: EndpointMetadata;\n}\n\nexport class PlatformContext extends DIContext implements ContextMethods {\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n public endpoint: EndpointMetadata;\n /**\n * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n */\n public data: any;\n /**\n * The current @@PlatformResponse@@.\n */\n public response: PlatformResponse;\n /**\n * The current @@PlatformRequest@@.\n */\n public request: PlatformRequest;\n\n private ignoreUrlPatterns: RegExp[] = [];\n\n constructor({\n event,\n endpoint,\n ignoreUrlPatterns = [],\n ResponseKlass = PlatformResponse,\n RequestKlass = PlatformRequest,\n ...options\n }: PlatformContextOptions) {\n super({\n ...options,\n ignoreLog: () => {\n return this.ignoreUrlPatterns.find((reg) => !!this.url.match(reg));\n }\n });\n\n endpoint && (this.endpoint = endpoint);\n\n this.ignoreUrlPatterns = ignoreUrlPatterns.map((pattern: string | RegExp) =>\n typeof pattern === \"string\" ? new RegExp(pattern, \"gi\") : pattern\n );\n\n this.response = new ResponseKlass(event, this);\n this.request = new RequestKlass(event, this);\n\n this.response.request = this.request;\n this.request.response = this.response;\n\n this.request.request.$ctx = this;\n this.request.request.id = this.id;\n this.logger.url = this.url;\n\n this.container.set(PlatformResponse, this.response);\n this.container.set(PlatformRequest, this.request);\n this.container.set(PlatformContext, this);\n\n this.response.setHeader(\"x-request-id\", this.id);\n }\n\n get url() {\n return this.request.url;\n }\n\n get app() {\n return this.injector.get<PlatformApplication>(PlatformApplication)!;\n }\n\n async destroy() {\n await super.destroy();\n\n delete this.request?.request?.$ctx;\n\n this.response.destroy();\n this.request.destroy();\n\n // @ts-ignore\n delete this.endpoint;\n // @ts-ignore\n delete this.response;\n // @ts-ignore\n delete this.request;\n }\n\n isDone() {\n if (!this.request || !this.response) {\n return true;\n }\n\n if (this.request?.isAborted()) {\n return true;\n }\n\n return this.response?.isDone();\n }\n\n /**\n * Return the framework request instance (Express, Koa, etc...)\n */\n getRequest<Req = any>(): Req {\n return this.request.getRequest<Req>();\n }\n\n /**\n * Return the framework response instance (Express, Koa, etc...)\n */\n getResponse<Res = any>(): Res {\n return this.response.getResponse<Res>();\n }\n\n /**\n * Get Node.js request\n */\n getReq(): IncomingMessage {\n return this.request.getReq();\n }\n\n /**\n * Get Node.js response\n */\n getRes(): ServerResponse {\n return this.response.getRes();\n }\n\n /**\n * Return the original application instance.\n */\n getApp<T = any>(): T {\n return this.app.getApp() as any;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformRouteDetails.js","sourceRoot":"","sources":["../../../src/domain/PlatformRouteDetails.ts"],"names":[],"mappings":";;;AAAA,2DAAgE;AAChE,yCAAgD;AAWhD,MAAa,oBAAqB,SAAQ,2BAAoC;IAI5E,YAAY,UAAyC,EAAE;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAoB,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,4BAAU,CAAC,QAAQ,CAAC,CAAC;IACpH,CAAC;IAED,MAAM;QACJ,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF;AApBD,oDAoBC","sourcesContent":["import {ParamMetadata, ParamTypes} from \"@tsed/platform-params\";\nimport {JsonOperationRoute} from \"@tsed/schema\";\nimport {EndpointMetadata} from \"./EndpointMetadata\";\nimport {ControllerProvider} from \"./ControllerProvider\";\n\nexport interface PlatformRouterDetailsOptions {\n provider: ControllerProvider;\n endpoint: EndpointMetadata;\n method: string;\n url: string;\n}\n\nexport class PlatformRouteDetails extends JsonOperationRoute<EndpointMetadata> {\n readonly rawBody: boolean;\n readonly provider: ControllerProvider;\n\n constructor(options: Partial<PlatformRouteDetails> = {}) {\n super(options);\n this.rawBody = !!this.endpoint.parameters.find((param: ParamMetadata) => param.paramType === ParamTypes.RAW_BODY);\n }\n\n toJSON() {\n return {\n method: this.method,\n name: this.name,\n url: this.url,\n className: this.className,\n methodClassName: this.methodClassName,\n parameters: this.parameters,\n rawBody: this.rawBody\n };\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformRouteDetails.js","sourceRoot":"","sources":["../../../src/domain/PlatformRouteDetails.ts"],"names":[],"mappings":";;;AAAA,2DAAiD;AACjD,yCAAkE;AAUlE,MAAa,oBAAqB,SAAQ,2BAAoC;IAI5E,YAAY,UAAyC,EAAE;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,4BAAU,CAAC,QAAQ,CAAC,CAAC;IACrG,CAAC;IAED,MAAM;QACJ,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF;AApBD,oDAoBC","sourcesContent":["import {ParamTypes} from \"@tsed/platform-params\";\nimport {EndpointMetadata, JsonOperationRoute} from \"@tsed/schema\";\nimport {ControllerProvider} from \"./ControllerProvider\";\n\nexport interface PlatformRouterDetailsOptions {\n provider: ControllerProvider;\n endpoint: EndpointMetadata;\n method: string;\n url: string;\n}\n\nexport class PlatformRouteDetails extends JsonOperationRoute<EndpointMetadata> {\n readonly rawBody: boolean;\n readonly provider: ControllerProvider;\n\n constructor(options: Partial<PlatformRouteDetails> = {}) {\n super(options);\n this.rawBody = !!this.endpoint.parameters.find((param) => param.paramType === ParamTypes.RAW_BODY);\n }\n\n toJSON() {\n return {\n method: this.method,\n name: this.name,\n url: this.url,\n className: this.className,\n methodClassName: this.methodClassName,\n parameters: this.parameters,\n rawBody: this.rawBody\n };\n }\n}\n"]}