@tsed/common 7.0.0-alpha.2 → 7.0.0-beta.11

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 (414) hide show
  1. package/lib/cjs/builder/PlatformBuilder.js +281 -0
  2. package/lib/cjs/builder/PlatformBuilder.js.map +1 -0
  3. package/lib/cjs/builder/PlatformControllerBuilder.js +82 -0
  4. package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -0
  5. package/lib/cjs/config/interfaces/ConverterSettings.js +3 -0
  6. package/lib/cjs/config/interfaces/ConverterSettings.js.map +1 -0
  7. package/lib/cjs/config/interfaces/PlatformLoggerSettings.js +3 -0
  8. package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -0
  9. package/lib/cjs/config/interfaces/PlatformMulterSettings.js +3 -0
  10. package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -0
  11. package/lib/cjs/config/interfaces/PlatformStaticsSettings.js +3 -0
  12. package/lib/cjs/config/interfaces/PlatformStaticsSettings.js.map +1 -0
  13. package/lib/cjs/config/services/PlatformConfiguration.js +187 -0
  14. package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -0
  15. package/lib/cjs/constants/routerOptions.js +5 -0
  16. package/lib/cjs/constants/routerOptions.js.map +1 -0
  17. package/lib/cjs/decorators/multer/multerFileSize.js +35 -0
  18. package/lib/cjs/decorators/multer/multerFileSize.js.map +1 -0
  19. package/lib/cjs/decorators/multer/multerOptions.js +52 -0
  20. package/lib/cjs/decorators/multer/multerOptions.js.map +1 -0
  21. package/lib/cjs/decorators/multer/multipartFile.js +78 -0
  22. package/lib/cjs/decorators/multer/multipartFile.js.map +1 -0
  23. package/lib/cjs/decorators/params/error.js +20 -0
  24. package/lib/cjs/decorators/params/error.js.map +1 -0
  25. package/lib/cjs/decorators/params/next.js +21 -0
  26. package/lib/cjs/decorators/params/next.js.map +1 -0
  27. package/lib/cjs/decorators/params/request.js +39 -0
  28. package/lib/cjs/decorators/params/request.js.map +1 -0
  29. package/lib/cjs/decorators/params/response.js +33 -0
  30. package/lib/cjs/decorators/params/response.js.map +1 -0
  31. package/lib/cjs/domain/AnyToPromiseWithCtx.js +27 -0
  32. package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -0
  33. package/lib/cjs/domain/ControllerProvider.js +51 -0
  34. package/lib/cjs/domain/ControllerProvider.js.map +1 -0
  35. package/lib/cjs/domain/EndpointMetadata.js +6 -0
  36. package/lib/cjs/domain/EndpointMetadata.js.map +1 -0
  37. package/lib/cjs/domain/HandlerMetadata.js +57 -0
  38. package/lib/cjs/domain/HandlerMetadata.js.map +1 -0
  39. package/lib/cjs/domain/PlatformContext.js +92 -0
  40. package/lib/cjs/domain/PlatformContext.js.map +1 -0
  41. package/lib/cjs/domain/PlatformRouteDetails.js +24 -0
  42. package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -0
  43. package/lib/cjs/exports.js +31 -0
  44. package/lib/cjs/exports.js.map +1 -0
  45. package/lib/cjs/index.js +68 -0
  46. package/lib/cjs/index.js.map +1 -0
  47. package/lib/cjs/interfaces/AfterInit.js +3 -0
  48. package/lib/cjs/interfaces/AfterInit.js.map +1 -0
  49. package/lib/cjs/interfaces/AfterListen.js +3 -0
  50. package/lib/cjs/interfaces/AfterListen.js.map +1 -0
  51. package/lib/cjs/interfaces/AfterRoutesInit.js +3 -0
  52. package/lib/cjs/interfaces/AfterRoutesInit.js.map +1 -0
  53. package/lib/cjs/interfaces/BeforeInit.js +3 -0
  54. package/lib/cjs/interfaces/BeforeInit.js.map +1 -0
  55. package/lib/cjs/interfaces/BeforeListen.js +3 -0
  56. package/lib/cjs/interfaces/BeforeListen.js.map +1 -0
  57. package/lib/cjs/interfaces/BeforeRoutesInit.js +3 -0
  58. package/lib/cjs/interfaces/BeforeRoutesInit.js.map +1 -0
  59. package/lib/cjs/interfaces/HandlerType.js +17 -0
  60. package/lib/cjs/interfaces/HandlerType.js.map +1 -0
  61. package/lib/cjs/interfaces/IncomingEvent.js +3 -0
  62. package/lib/cjs/interfaces/IncomingEvent.js.map +1 -0
  63. package/lib/cjs/interfaces/OnReady.js +3 -0
  64. package/lib/cjs/interfaces/OnReady.js.map +1 -0
  65. package/lib/cjs/interfaces/OnRequest.js +3 -0
  66. package/lib/cjs/interfaces/OnRequest.js.map +1 -0
  67. package/lib/cjs/interfaces/OnResponse.js +3 -0
  68. package/lib/cjs/interfaces/OnResponse.js.map +1 -0
  69. package/lib/cjs/interfaces/OnRoutesInit.js +3 -0
  70. package/lib/cjs/interfaces/OnRoutesInit.js.map +1 -0
  71. package/lib/cjs/interfaces/PlatformRouteOptions.js +3 -0
  72. package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -0
  73. package/lib/cjs/interfaces/ResponseErrorObject.js +3 -0
  74. package/lib/cjs/interfaces/ResponseErrorObject.js.map +1 -0
  75. package/lib/cjs/interfaces/Route.js +3 -0
  76. package/lib/cjs/interfaces/Route.js.map +1 -0
  77. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +37 -0
  78. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
  79. package/lib/cjs/middlewares/PlatformMulterMiddleware.js +67 -0
  80. package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -0
  81. package/lib/cjs/middlewares/__mock__/FakeCtrl.js +12 -0
  82. package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +1 -0
  83. package/lib/cjs/middlewares/bindEndpointMiddleware.js +13 -0
  84. package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +1 -0
  85. package/lib/cjs/package.json +3 -0
  86. package/lib/cjs/services/FakeAdapter.js +55 -0
  87. package/lib/cjs/services/FakeAdapter.js.map +1 -0
  88. package/lib/cjs/services/Platform.js +128 -0
  89. package/lib/cjs/services/Platform.js.map +1 -0
  90. package/lib/cjs/services/PlatformAdapter.js +14 -0
  91. package/lib/cjs/services/PlatformAdapter.js.map +1 -0
  92. package/lib/cjs/services/PlatformApplication.js +32 -0
  93. package/lib/cjs/services/PlatformApplication.js.map +1 -0
  94. package/lib/cjs/services/PlatformHandler.js +235 -0
  95. package/lib/cjs/services/PlatformHandler.js.map +1 -0
  96. package/lib/cjs/services/PlatformMiddlewaresChain.js +75 -0
  97. package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -0
  98. package/lib/cjs/services/PlatformRequest.js +138 -0
  99. package/lib/cjs/services/PlatformRequest.js.map +1 -0
  100. package/lib/cjs/services/PlatformResponse.js +271 -0
  101. package/lib/cjs/services/PlatformResponse.js.map +1 -0
  102. package/lib/cjs/services/PlatformRouter.js +108 -0
  103. package/lib/cjs/services/PlatformRouter.js.map +1 -0
  104. package/lib/cjs/services/PlatformTest.js +173 -0
  105. package/lib/cjs/services/PlatformTest.js.map +1 -0
  106. package/lib/cjs/utils/__mock__/Test1.js +8 -0
  107. package/lib/cjs/utils/__mock__/Test1.js.map +1 -0
  108. package/lib/cjs/utils/__mock__/Test2.js +8 -0
  109. package/lib/cjs/utils/__mock__/Test2.js.map +1 -0
  110. package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js +12 -0
  111. package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js.map +1 -0
  112. package/lib/cjs/utils/__mock__/module1/Module1.js +19 -0
  113. package/lib/cjs/utils/__mock__/module1/Module1.js.map +1 -0
  114. package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js +17 -0
  115. package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js.map +1 -0
  116. package/lib/cjs/utils/__mock__/module1/services/M1Service.js +17 -0
  117. package/lib/cjs/utils/__mock__/module1/services/M1Service.js.map +1 -0
  118. package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js +15 -0
  119. package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js.map +1 -0
  120. package/lib/cjs/utils/__mock__/module1/submodule/SubService.js +12 -0
  121. package/lib/cjs/utils/__mock__/module1/submodule/SubService.js.map +1 -0
  122. package/lib/cjs/utils/__mock__/module2/Module2.js +18 -0
  123. package/lib/cjs/utils/__mock__/module2/Module2.js.map +1 -0
  124. package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js +12 -0
  125. package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js.map +1 -0
  126. package/lib/cjs/utils/createContext.js +38 -0
  127. package/lib/cjs/utils/createContext.js.map +1 -0
  128. package/lib/cjs/utils/createHandlerMetadata.js +49 -0
  129. package/lib/cjs/utils/createHandlerMetadata.js.map +1 -0
  130. package/lib/cjs/utils/createHttpServer.js +29 -0
  131. package/lib/cjs/utils/createHttpServer.js.map +1 -0
  132. package/lib/cjs/utils/createHttpsServer.js +29 -0
  133. package/lib/cjs/utils/createHttpsServer.js.map +1 -0
  134. package/lib/cjs/utils/createInjector.js +46 -0
  135. package/lib/cjs/utils/createInjector.js.map +1 -0
  136. package/lib/cjs/utils/getConfiguration.js +46 -0
  137. package/lib/cjs/utils/getConfiguration.js.map +1 -0
  138. package/lib/cjs/utils/getStaticsOptions.js +21 -0
  139. package/lib/cjs/utils/getStaticsOptions.js.map +1 -0
  140. package/lib/cjs/utils/listenServer.js +21 -0
  141. package/lib/cjs/utils/listenServer.js.map +1 -0
  142. package/lib/cjs/utils/mapReturnedResponse.js +15 -0
  143. package/lib/cjs/utils/mapReturnedResponse.js.map +1 -0
  144. package/lib/cjs/utils/printRoutes.js +36 -0
  145. package/lib/cjs/utils/printRoutes.js.map +1 -0
  146. package/lib/cjs/utils/setResponseHeaders.js +35 -0
  147. package/lib/cjs/utils/setResponseHeaders.js.map +1 -0
  148. package/lib/cjs/utils/useCtxHandler.js +15 -0
  149. package/lib/cjs/utils/useCtxHandler.js.map +1 -0
  150. package/lib/esm/builder/PlatformBuilder.js +277 -0
  151. package/lib/esm/builder/PlatformBuilder.js.map +1 -0
  152. package/lib/esm/builder/PlatformControllerBuilder.js +76 -0
  153. package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -0
  154. package/lib/esm/config/interfaces/ConverterSettings.js +2 -0
  155. package/lib/esm/config/interfaces/ConverterSettings.js.map +1 -0
  156. package/lib/esm/config/interfaces/PlatformLoggerSettings.js +2 -0
  157. package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -0
  158. package/lib/esm/config/interfaces/PlatformMulterSettings.js +2 -0
  159. package/lib/esm/config/interfaces/PlatformMulterSettings.js.map +1 -0
  160. package/lib/esm/config/interfaces/PlatformStaticsSettings.js +2 -0
  161. package/lib/esm/config/interfaces/PlatformStaticsSettings.js.map +1 -0
  162. package/lib/esm/config/services/PlatformConfiguration.js +184 -0
  163. package/lib/esm/config/services/PlatformConfiguration.js.map +1 -0
  164. package/lib/esm/constants/routerOptions.js +2 -0
  165. package/lib/esm/constants/routerOptions.js.map +1 -0
  166. package/lib/esm/decorators/multer/multerFileSize.js +31 -0
  167. package/lib/esm/decorators/multer/multerFileSize.js.map +1 -0
  168. package/lib/esm/decorators/multer/multerOptions.js +48 -0
  169. package/lib/esm/decorators/multer/multerOptions.js.map +1 -0
  170. package/lib/esm/decorators/multer/multipartFile.js +74 -0
  171. package/lib/esm/decorators/multer/multipartFile.js.map +1 -0
  172. package/lib/esm/decorators/params/error.js +16 -0
  173. package/lib/esm/decorators/params/error.js.map +1 -0
  174. package/lib/esm/decorators/params/next.js +17 -0
  175. package/lib/esm/decorators/params/next.js.map +1 -0
  176. package/lib/esm/decorators/params/request.js +34 -0
  177. package/lib/esm/decorators/params/request.js.map +1 -0
  178. package/lib/esm/decorators/params/response.js +28 -0
  179. package/lib/esm/decorators/params/response.js.map +1 -0
  180. package/lib/esm/domain/AnyToPromiseWithCtx.js +23 -0
  181. package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -0
  182. package/lib/esm/domain/ControllerProvider.js +47 -0
  183. package/lib/esm/domain/ControllerProvider.js.map +1 -0
  184. package/lib/esm/domain/EndpointMetadata.js +2 -0
  185. package/lib/esm/domain/EndpointMetadata.js.map +1 -0
  186. package/lib/esm/domain/HandlerMetadata.js +53 -0
  187. package/lib/esm/domain/HandlerMetadata.js.map +1 -0
  188. package/lib/esm/domain/PlatformContext.js +88 -0
  189. package/lib/esm/domain/PlatformContext.js.map +1 -0
  190. package/lib/esm/domain/PlatformRouteDetails.js +20 -0
  191. package/lib/esm/domain/PlatformRouteDetails.js.map +1 -0
  192. package/lib/esm/exports.js +13 -0
  193. package/lib/esm/exports.js.map +1 -0
  194. package/lib/esm/index.js +65 -0
  195. package/lib/esm/index.js.map +1 -0
  196. package/lib/esm/interfaces/AfterInit.js +2 -0
  197. package/lib/esm/interfaces/AfterInit.js.map +1 -0
  198. package/lib/esm/interfaces/AfterListen.js +2 -0
  199. package/lib/esm/interfaces/AfterListen.js.map +1 -0
  200. package/lib/esm/interfaces/AfterRoutesInit.js +2 -0
  201. package/lib/esm/interfaces/AfterRoutesInit.js.map +1 -0
  202. package/lib/esm/interfaces/BeforeInit.js +2 -0
  203. package/lib/esm/interfaces/BeforeInit.js.map +1 -0
  204. package/lib/esm/interfaces/BeforeListen.js +2 -0
  205. package/lib/esm/interfaces/BeforeListen.js.map +1 -0
  206. package/lib/esm/interfaces/BeforeRoutesInit.js +2 -0
  207. package/lib/esm/interfaces/BeforeRoutesInit.js.map +1 -0
  208. package/lib/esm/interfaces/HandlerType.js +14 -0
  209. package/lib/esm/interfaces/HandlerType.js.map +1 -0
  210. package/lib/esm/interfaces/IncomingEvent.js +2 -0
  211. package/lib/esm/interfaces/IncomingEvent.js.map +1 -0
  212. package/lib/esm/interfaces/OnReady.js +2 -0
  213. package/lib/esm/interfaces/OnReady.js.map +1 -0
  214. package/lib/esm/interfaces/OnRequest.js +2 -0
  215. package/lib/esm/interfaces/OnRequest.js.map +1 -0
  216. package/lib/esm/interfaces/OnResponse.js +2 -0
  217. package/lib/esm/interfaces/OnResponse.js.map +1 -0
  218. package/lib/esm/interfaces/OnRoutesInit.js +2 -0
  219. package/lib/esm/interfaces/OnRoutesInit.js.map +1 -0
  220. package/lib/esm/interfaces/PlatformRouteOptions.js +2 -0
  221. package/lib/esm/interfaces/PlatformRouteOptions.js.map +1 -0
  222. package/lib/esm/interfaces/ResponseErrorObject.js +2 -0
  223. package/lib/esm/interfaces/ResponseErrorObject.js.map +1 -0
  224. package/lib/esm/interfaces/Route.js +2 -0
  225. package/lib/esm/interfaces/Route.js.map +1 -0
  226. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +34 -0
  227. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
  228. package/lib/esm/middlewares/PlatformMulterMiddleware.js +63 -0
  229. package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -0
  230. package/lib/esm/middlewares/__mock__/FakeCtrl.js +9 -0
  231. package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +1 -0
  232. package/lib/esm/middlewares/bindEndpointMiddleware.js +9 -0
  233. package/lib/esm/middlewares/bindEndpointMiddleware.js.map +1 -0
  234. package/lib/esm/package.json +3 -0
  235. package/lib/esm/services/FakeAdapter.js +51 -0
  236. package/lib/esm/services/FakeAdapter.js.map +1 -0
  237. package/lib/esm/services/Platform.js +125 -0
  238. package/lib/esm/services/Platform.js.map +1 -0
  239. package/lib/esm/services/PlatformAdapter.js +10 -0
  240. package/lib/esm/services/PlatformAdapter.js.map +1 -0
  241. package/lib/esm/services/PlatformApplication.js +29 -0
  242. package/lib/esm/services/PlatformApplication.js.map +1 -0
  243. package/lib/esm/services/PlatformHandler.js +232 -0
  244. package/lib/esm/services/PlatformHandler.js.map +1 -0
  245. package/lib/esm/services/PlatformMiddlewaresChain.js +72 -0
  246. package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -0
  247. package/lib/esm/services/PlatformRequest.js +135 -0
  248. package/lib/esm/services/PlatformRequest.js.map +1 -0
  249. package/lib/esm/services/PlatformResponse.js +268 -0
  250. package/lib/esm/services/PlatformResponse.js.map +1 -0
  251. package/lib/esm/services/PlatformRouter.js +105 -0
  252. package/lib/esm/services/PlatformRouter.js.map +1 -0
  253. package/lib/esm/services/PlatformTest.js +168 -0
  254. package/lib/esm/services/PlatformTest.js.map +1 -0
  255. package/lib/esm/utils/__mock__/Test1.js +4 -0
  256. package/lib/esm/utils/__mock__/Test1.js.map +1 -0
  257. package/lib/esm/utils/__mock__/Test2.js +4 -0
  258. package/lib/esm/utils/__mock__/Test2.js.map +1 -0
  259. package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js +9 -0
  260. package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js.map +1 -0
  261. package/lib/esm/utils/__mock__/module1/Module1.js +16 -0
  262. package/lib/esm/utils/__mock__/module1/Module1.js.map +1 -0
  263. package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js +14 -0
  264. package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js.map +1 -0
  265. package/lib/esm/utils/__mock__/module1/services/M1Service.js +14 -0
  266. package/lib/esm/utils/__mock__/module1/services/M1Service.js.map +1 -0
  267. package/lib/esm/utils/__mock__/module1/submodule/SubModule.js +12 -0
  268. package/lib/esm/utils/__mock__/module1/submodule/SubModule.js.map +1 -0
  269. package/lib/esm/utils/__mock__/module1/submodule/SubService.js +9 -0
  270. package/lib/esm/utils/__mock__/module1/submodule/SubService.js.map +1 -0
  271. package/lib/esm/utils/__mock__/module2/Module2.js +15 -0
  272. package/lib/esm/utils/__mock__/module2/Module2.js.map +1 -0
  273. package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js +9 -0
  274. package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js.map +1 -0
  275. package/lib/esm/utils/createContext.js +34 -0
  276. package/lib/esm/utils/createContext.js.map +1 -0
  277. package/lib/esm/utils/createHandlerMetadata.js +45 -0
  278. package/lib/esm/utils/createHandlerMetadata.js.map +1 -0
  279. package/lib/esm/utils/createHttpServer.js +24 -0
  280. package/lib/esm/utils/createHttpServer.js.map +1 -0
  281. package/lib/esm/utils/createHttpsServer.js +24 -0
  282. package/lib/esm/utils/createHttpsServer.js.map +1 -0
  283. package/lib/esm/utils/createInjector.js +42 -0
  284. package/lib/esm/utils/createInjector.js.map +1 -0
  285. package/lib/esm/utils/getConfiguration.js +42 -0
  286. package/lib/esm/utils/getConfiguration.js.map +1 -0
  287. package/lib/esm/utils/getStaticsOptions.js +17 -0
  288. package/lib/esm/utils/getStaticsOptions.js.map +1 -0
  289. package/lib/esm/utils/listenServer.js +17 -0
  290. package/lib/esm/utils/listenServer.js.map +1 -0
  291. package/lib/esm/utils/mapReturnedResponse.js +11 -0
  292. package/lib/esm/utils/mapReturnedResponse.js.map +1 -0
  293. package/lib/esm/utils/printRoutes.js +32 -0
  294. package/lib/esm/utils/printRoutes.js.map +1 -0
  295. package/lib/esm/utils/setResponseHeaders.js +31 -0
  296. package/lib/esm/utils/setResponseHeaders.js.map +1 -0
  297. package/lib/esm/utils/useCtxHandler.js +11 -0
  298. package/lib/esm/utils/useCtxHandler.js.map +1 -0
  299. package/lib/{builder → types/builder}/PlatformBuilder.d.ts +30 -34
  300. package/lib/types/builder/PlatformControllerBuilder.d.ts +18 -0
  301. package/lib/{config → types/config}/interfaces/ConverterSettings.d.ts +0 -0
  302. package/lib/{config → types/config}/interfaces/PlatformLoggerSettings.d.ts +0 -0
  303. package/lib/types/config/interfaces/PlatformMulterSettings.d.ts +14 -0
  304. package/lib/{config → types/config}/interfaces/PlatformStaticsSettings.d.ts +1 -0
  305. package/lib/{config → types/config}/services/PlatformConfiguration.d.ts +24 -17
  306. package/lib/{constants → types/constants}/routerOptions.d.ts +0 -0
  307. package/lib/{decorators → types/decorators}/multer/multerFileSize.d.ts +0 -0
  308. package/lib/{decorators → types/decorators}/multer/multerOptions.d.ts +0 -0
  309. package/lib/{decorators → types/decorators}/multer/multipartFile.d.ts +0 -0
  310. package/lib/{decorators → types/decorators}/params/error.d.ts +0 -0
  311. package/lib/{decorators → types/decorators}/params/next.d.ts +0 -0
  312. package/lib/{decorators → types/decorators}/params/request.d.ts +0 -0
  313. package/lib/{decorators → types/decorators}/params/response.d.ts +0 -0
  314. package/lib/{domain → types/domain}/AnyToPromiseWithCtx.d.ts +0 -0
  315. package/lib/types/domain/ControllerProvider.d.ts +24 -0
  316. package/lib/types/domain/EndpointMetadata.d.ts +1 -0
  317. package/lib/{domain → types/domain}/HandlerMetadata.d.ts +2 -2
  318. package/lib/{domain → types/domain}/PlatformContext.d.ts +1 -1
  319. package/lib/types/domain/PlatformRouteDetails.d.ts +22 -0
  320. package/lib/types/exports.d.ts +12 -0
  321. package/lib/types/index.d.ts +64 -0
  322. package/lib/{interfaces → types/interfaces}/AfterInit.d.ts +0 -0
  323. package/lib/{interfaces → types/interfaces}/AfterListen.d.ts +0 -0
  324. package/lib/{interfaces → types/interfaces}/AfterRoutesInit.d.ts +0 -0
  325. package/lib/{interfaces → types/interfaces}/BeforeInit.d.ts +0 -0
  326. package/lib/{interfaces → types/interfaces}/BeforeListen.d.ts +0 -0
  327. package/lib/{interfaces → types/interfaces}/BeforeRoutesInit.d.ts +0 -0
  328. package/lib/{interfaces → types/interfaces}/HandlerType.d.ts +0 -0
  329. package/lib/{interfaces → types/interfaces}/IncomingEvent.d.ts +0 -0
  330. package/lib/{interfaces → types/interfaces}/OnReady.d.ts +0 -0
  331. package/lib/{interfaces → types/interfaces}/OnRequest.d.ts +0 -0
  332. package/lib/{interfaces → types/interfaces}/OnResponse.d.ts +0 -0
  333. package/lib/{interfaces → types/interfaces}/OnRoutesInit.d.ts +0 -0
  334. package/lib/{interfaces → types/interfaces}/PlatformRouteOptions.d.ts +5 -3
  335. package/lib/{interfaces → types/interfaces}/ResponseErrorObject.d.ts +0 -0
  336. package/lib/{interfaces → types/interfaces}/Route.d.ts +0 -0
  337. package/lib/{middlewares → types/middlewares}/PlatformAcceptMimesMiddleware.d.ts +0 -0
  338. package/lib/{middlewares → types/middlewares}/PlatformMulterMiddleware.d.ts +8 -3
  339. package/lib/{middlewares/data → types/middlewares/__mock__}/FakeCtrl.d.ts +0 -0
  340. package/lib/types/middlewares/bindEndpointMiddleware.d.ts +6 -0
  341. package/lib/types/services/FakeAdapter.d.ts +30 -0
  342. package/lib/{services → types/services}/Platform.d.ts +22 -7
  343. package/lib/types/services/PlatformAdapter.d.ts +47 -0
  344. package/lib/{services → types/services}/PlatformApplication.d.ts +3 -3
  345. package/lib/{services → types/services}/PlatformHandler.d.ts +1 -1
  346. package/lib/types/services/PlatformMiddlewaresChain.d.ts +10 -0
  347. package/lib/{services → types/services}/PlatformRequest.d.ts +2 -1
  348. package/lib/{services → types/services}/PlatformResponse.d.ts +10 -10
  349. package/lib/{services → types/services}/PlatformRouter.d.ts +12 -8
  350. package/lib/{services → types/services}/PlatformTest.d.ts +6 -5
  351. package/lib/types/utils/__mock__/Test1.d.ts +3 -0
  352. package/lib/types/utils/__mock__/Test2.d.ts +3 -0
  353. package/lib/types/utils/__mock__/controllers/rest/TestCtrl.d.ts +2 -0
  354. package/lib/types/utils/__mock__/module1/Module1.d.ts +2 -0
  355. package/lib/types/utils/__mock__/module1/controllers/M1Ctrl1.d.ts +5 -0
  356. package/lib/types/utils/__mock__/module1/services/M1Service.d.ts +5 -0
  357. package/lib/types/utils/__mock__/module1/submodule/SubModule.d.ts +2 -0
  358. package/lib/types/utils/__mock__/module1/submodule/SubService.d.ts +2 -0
  359. package/lib/types/utils/__mock__/module2/Module2.d.ts +2 -0
  360. package/lib/types/utils/__mock__/module2/controllers/M2Ctrl.d.ts +2 -0
  361. package/lib/{utils → types/utils}/createContext.d.ts +0 -0
  362. package/lib/{utils → types/utils}/createHandlerMetadata.d.ts +1 -1
  363. package/lib/types/utils/createHttpServer.d.ts +4 -0
  364. package/lib/types/utils/createHttpsServer.d.ts +5 -0
  365. package/lib/types/utils/createInjector.d.ts +9 -0
  366. package/lib/types/utils/getConfiguration.d.ts +2 -0
  367. package/lib/types/utils/getStaticsOptions.d.ts +5 -0
  368. package/lib/types/utils/listenServer.d.ts +7 -0
  369. package/lib/{utils → types/utils}/mapReturnedResponse.d.ts +0 -0
  370. package/lib/{utils → types/utils}/printRoutes.d.ts +0 -0
  371. package/lib/{utils → types/utils}/setResponseHeaders.d.ts +0 -0
  372. package/lib/{utils → types/utils}/useCtxHandler.d.ts +0 -0
  373. package/package.json +47 -34
  374. package/readme.md +50 -57
  375. package/tsconfig.compile.esm.json +13 -0
  376. package/lib/PlatformModule.d.ts +0 -15
  377. package/lib/builder/PlatformControllerBuilder.d.ts +0 -19
  378. package/lib/config/index.d.ts +0 -3
  379. package/lib/config/interfaces/EndpointDirectoriesSettings.d.ts +0 -3
  380. package/lib/config/interfaces/PlatformMulterSettings.d.ts +0 -138
  381. package/lib/config/interfaces/index.d.ts +0 -84
  382. package/lib/decorators/httpServer.d.ts +0 -27
  383. package/lib/decorators/httpsServer.d.ts +0 -27
  384. package/lib/decorators/index.d.ts +0 -13
  385. package/lib/decorators/method/acceptMime.d.ts +0 -19
  386. package/lib/decorators/method/endpointFn.d.ts +0 -8
  387. package/lib/decorators/method/location.d.ts +0 -1
  388. package/lib/decorators/method/redirect.d.ts +0 -1
  389. package/lib/decorators/method/route.d.ts +0 -1
  390. package/lib/decorators/multer/index.d.ts +0 -3
  391. package/lib/domain/ControllerProvider.d.ts +0 -53
  392. package/lib/domain/EndpointMetadata.d.ts +0 -88
  393. package/lib/domain/PlatformRouteDetails.d.ts +0 -29
  394. package/lib/domain/index.d.ts +0 -6
  395. package/lib/index.d.ts +0 -22
  396. package/lib/index.js +0 -3651
  397. package/lib/index.js.map +0 -1
  398. package/lib/index.modern.js +0 -3464
  399. package/lib/index.modern.js.map +0 -1
  400. package/lib/interfaces/PathType.d.ts +0 -1
  401. package/lib/interfaces/PlatformRouterMethods.d.ts +0 -10
  402. package/lib/interfaces/index.d.ts +0 -17
  403. package/lib/middlewares/bindEndpointMiddleware.d.ts +0 -5
  404. package/lib/middlewares/index.d.ts +0 -3
  405. package/lib/registries/ControllerRegistry.d.ts +0 -1
  406. package/lib/services/FakeRawDriver.d.ts +0 -15
  407. package/lib/services/index.d.ts +0 -7
  408. package/lib/utils/createHttpServer.d.ts +0 -3
  409. package/lib/utils/createHttpsServer.d.ts +0 -3
  410. package/lib/utils/createInjector.d.ts +0 -2
  411. package/lib/utils/createPlatformApplication.d.ts +0 -2
  412. package/lib/utils/getControllerPath.d.ts +0 -2
  413. package/lib/utils/index.d.ts +0 -8
  414. package/lib/utils/listenServer.d.ts +0 -10
@@ -0,0 +1,168 @@
1
+ import { DITest } from "@tsed/di";
2
+ import { PlatformBuilder } from "../builder/PlatformBuilder.js";
3
+ import { PlatformContext } from "../domain/PlatformContext.js";
4
+ import { createInjector } from "../utils/createInjector.js";
5
+ import { PlatformApplication } from "./PlatformApplication.js";
6
+ import { getConfiguration } from "../utils/getConfiguration.js";
7
+ import accepts from "accepts";
8
+ /**
9
+ * @platform
10
+ */
11
+ export class PlatformTest extends DITest {
12
+ static async create(settings = {}) {
13
+ DITest.injector = PlatformTest.createInjector(getConfiguration(settings));
14
+ await DITest.createContainer(settings);
15
+ }
16
+ /**
17
+ * Create a new injector with the right default services
18
+ */
19
+ static createInjector(settings = {}) {
20
+ return createInjector({
21
+ settings: DITest.configure({ httpPort: false, httpsPort: false, ...settings })
22
+ });
23
+ }
24
+ /**
25
+ * Load the server silently without listening port and configure it on test profile.
26
+ * @decorator
27
+ * @param mod
28
+ * @param listen
29
+ * @param settings
30
+ * @returns {Promise<void>}
31
+ */
32
+ static bootstrap(mod, { listen, ...settings } = {}) {
33
+ return async function before() {
34
+ let instance;
35
+ const adapter = settings.platform || settings.adapter || PlatformTest.adapter;
36
+ /* istanbul ignore next */
37
+ if (!adapter) {
38
+ throw new Error("Platform adapter is not specified. Have you added at least `import @tsed/platform-express` (or equivalent) on your Server.ts ?");
39
+ }
40
+ // @ts-ignore
41
+ settings = DITest.configure(settings);
42
+ settings.adapter = adapter;
43
+ const configuration = getConfiguration(settings, mod);
44
+ const disableComponentsScan = configuration.disableComponentsScan || !!process.env.WEBPACK;
45
+ if (!disableComponentsScan) {
46
+ const { importProviders } = await import("@tsed/components-scan");
47
+ await importProviders(configuration);
48
+ }
49
+ instance = await PlatformBuilder.build(mod, configuration).bootstrap();
50
+ await instance.listen(!!listen);
51
+ // used by inject method
52
+ DITest.injector = instance.injector;
53
+ };
54
+ }
55
+ /**
56
+ * It injects services into the test function where you can alter, spy on, and manipulate them.
57
+ *
58
+ * The inject function has two parameters
59
+ *
60
+ * * an array of Service dependency injection tokens,
61
+ * * a test function whose parameters correspond exactly to each item in the injection token array.
62
+ *
63
+ * @param targets
64
+ * @param func
65
+ */
66
+ static inject(targets, func) {
67
+ return async () => {
68
+ if (!DITest.hasInjector()) {
69
+ await PlatformTest.create();
70
+ }
71
+ const injector = DITest.injector;
72
+ const deps = [];
73
+ for (const target of targets) {
74
+ deps.push(injector.has(target) ? injector.get(target) : await injector.invoke(target));
75
+ }
76
+ return await func(...deps);
77
+ };
78
+ }
79
+ /**
80
+ * Return the raw application (express or koa).
81
+ * Use this callback with SuperTest.
82
+ *
83
+ * ```typescript
84
+ * let request: SuperTest.SuperTest<SuperTest.Test>;
85
+ * beforeEach(PlatformTest.bootstrap(Server, {
86
+ * mount: {
87
+ * "/rest": [ProductsController]
88
+ * }
89
+ * }));
90
+ * beforeEach(() => {
91
+ * request = SuperTest(PlatformTest.callback());
92
+ * });
93
+ * ```
94
+ */
95
+ static callback() {
96
+ var _a;
97
+ return (_a = DITest.injector.get(PlatformApplication)) === null || _a === void 0 ? void 0 : _a.callback();
98
+ }
99
+ static createRequest(options = {}) {
100
+ return {
101
+ headers: {},
102
+ get(key) {
103
+ return this.headers[key.toLowerCase()];
104
+ },
105
+ accepts(mime) {
106
+ return accepts(this).types([].concat(mime));
107
+ },
108
+ ...options
109
+ };
110
+ }
111
+ static createResponse(options = {}) {
112
+ return {
113
+ headers: {},
114
+ locals: {},
115
+ statusCode: 200,
116
+ status(code) {
117
+ this.statusCode = code;
118
+ return this;
119
+ },
120
+ contentType(content) {
121
+ this.set("content-type", content);
122
+ },
123
+ contentLength(content) {
124
+ this.set("content-length", content);
125
+ },
126
+ redirect(status, path) {
127
+ this.statusCode = status;
128
+ this.set("location", path);
129
+ },
130
+ location(path) {
131
+ this.set("location", path);
132
+ },
133
+ get(key) {
134
+ return this.headers[key.toLowerCase()];
135
+ },
136
+ getHeaders() {
137
+ return this.headers;
138
+ },
139
+ set(key, value) {
140
+ this.headers[key.toLowerCase()] = value;
141
+ return this;
142
+ },
143
+ send(data) {
144
+ this.data = data;
145
+ },
146
+ json(data) {
147
+ this.data = data;
148
+ },
149
+ ...options
150
+ };
151
+ }
152
+ static createRequestContext(options = {}) {
153
+ var _a, _b, _c, _d;
154
+ const event = {
155
+ request: ((_a = options === null || options === void 0 ? void 0 : options.request) === null || _a === void 0 ? void 0 : _a.request) || ((_b = options === null || options === void 0 ? void 0 : options.event) === null || _b === void 0 ? void 0 : _b.request) || PlatformTest.createRequest(),
156
+ response: ((_c = options === null || options === void 0 ? void 0 : options.response) === null || _c === void 0 ? void 0 : _c.response) || ((_d = options === null || options === void 0 ? void 0 : options.event) === null || _d === void 0 ? void 0 : _d.response) || PlatformTest.createResponse()
157
+ };
158
+ return new PlatformContext({
159
+ id: "id",
160
+ injector: DITest.injector,
161
+ logger: DITest.injector.logger,
162
+ url: "/",
163
+ ...options,
164
+ event
165
+ });
166
+ }
167
+ }
168
+ //# sourceMappingURL=PlatformTest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformTest.js","sourceRoot":"","sources":["../../../src/services/PlatformTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAiC,MAAM,UAAU,CAAC;AAEhE,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAyB,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAE3D,OA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AAK,CAAC;gBACxC,OAAO,IAAI,CAAC;YACd,CAAC;YACD,IAAI,CAAC,IAAS;gBACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACnB,CAAC;YACD,IAAI,CAAC,IAAS;gBACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACnB,CAAC;YACD,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,oBAAoB,CAAC,UAAiD,EAAE;;QAC7E,MAAM,KAAK,GAAG;YACZ,OAAO,EAAE,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,0CAAE,OAAO,MAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,0CAAE,OAAO,CAAA,IAAI,YAAY,CAAC,aAAa,EAAE;YAC7F,QAAQ,EAAE,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,0CAAE,QAAQ,MAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,0CAAE,QAAQ,CAAA,IAAI,YAAY,CAAC,cAAc,EAAE;SACnG,CAAC;QAEF,OAAO,IAAI,eAAe,CAAC;YACzB,EAAE,EAAE,IAAI;YACR,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;YAC9B,GAAG,EAAE,GAAG;YACR,GAAG,OAAO;YACV,KAAK;SACN,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import {DITest, DITestOptions, InjectorService} from \"@tsed/di\";\nimport {Type} from \"@tsed/core\";\nimport {PlatformBuilder} from \"../builder/PlatformBuilder\";\nimport {PlatformContext, PlatformContextOptions} from \"../domain/PlatformContext\";\nimport {createInjector} from \"../utils/createInjector\";\nimport {PlatformApplication} from \"./PlatformApplication\";\nimport {getConfiguration} from \"../utils/getConfiguration\";\nimport {PlatformAdapter, PlatformBuilderSettings} from \"./PlatformAdapter\";\nimport accepts from \"accepts\";\n\n/**\n * @platform\n */\nexport class PlatformTest extends DITest {\n public static adapter: Type<PlatformAdapter>;\n\n static async create(settings: DITestOptions = {}) {\n DITest.injector = PlatformTest.createInjector(getConfiguration(settings));\n await DITest.createContainer(settings);\n }\n\n /**\n * Create a new injector with the right default services\n */\n static createInjector(settings: any = {}): InjectorService {\n return createInjector({\n settings: DITest.configure({httpPort: false, httpsPort: false, ...settings})\n });\n }\n\n /**\n * Load the server silently without listening port and configure it on test profile.\n * @decorator\n * @param mod\n * @param listen\n * @param settings\n * @returns {Promise<void>}\n */\n static bootstrap(mod: any, {listen, ...settings}: Partial<PlatformBuilderSettings & {listen: boolean}> = {}): () => Promise<void> {\n return async function before(): Promise<void> {\n let instance: PlatformBuilder;\n const adapter: Type<PlatformAdapter> = settings.platform || settings.adapter || PlatformTest.adapter;\n\n /* istanbul ignore next */\n if (!adapter) {\n throw new Error(\n \"Platform adapter is not specified. Have you added at least `import @tsed/platform-express` (or equivalent) on your Server.ts ?\"\n );\n }\n\n // @ts-ignore\n settings = DITest.configure(settings);\n settings.adapter = adapter as any;\n\n const configuration = getConfiguration(settings, mod);\n const disableComponentsScan = configuration.disableComponentsScan || !!process.env.WEBPACK;\n\n if (!disableComponentsScan) {\n const {importProviders} = await import(\"@tsed/components-scan\");\n await importProviders(configuration);\n }\n\n instance = await PlatformBuilder.build(mod, configuration).bootstrap();\n await instance.listen(!!listen);\n\n // used by inject method\n DITest.injector = instance.injector;\n };\n }\n\n /**\n * It injects services into the test function where you can alter, spy on, and manipulate them.\n *\n * The inject function has two parameters\n *\n * * an array of Service dependency injection tokens,\n * * a test function whose parameters correspond exactly to each item in the injection token array.\n *\n * @param targets\n * @param func\n */\n static inject<T>(targets: any[], func: (...args: any[]) => Promise<T> | T): () => Promise<T> {\n return async (): Promise<T> => {\n if (!DITest.hasInjector()) {\n await PlatformTest.create();\n }\n\n const injector: InjectorService = DITest.injector;\n const deps = [];\n\n for (const target of targets) {\n deps.push(injector.has(target) ? injector.get(target) : await injector.invoke(target));\n }\n\n return await func(...deps);\n };\n }\n\n /**\n * Return the raw application (express or koa).\n * Use this callback with SuperTest.\n *\n * ```typescript\n * let request: SuperTest.SuperTest<SuperTest.Test>;\n * beforeEach(PlatformTest.bootstrap(Server, {\n * mount: {\n * \"/rest\": [ProductsController]\n * }\n * }));\n * beforeEach(() => {\n * request = SuperTest(PlatformTest.callback());\n * });\n * ```\n */\n static callback() {\n return DITest.injector.get<PlatformApplication>(PlatformApplication)?.callback();\n }\n\n static createRequest(options: any = {}): any {\n return {\n headers: {},\n get(key: string) {\n return this.headers[key.toLowerCase()];\n },\n accepts(mime?: string | string[]) {\n return accepts(this).types([].concat(mime as never));\n },\n ...options\n };\n }\n\n static createResponse(options: any = {}): any {\n return {\n headers: {},\n locals: {},\n statusCode: 200,\n status(code: number) {\n this.statusCode = code;\n return this;\n },\n contentType(content: string) {\n this.set(\"content-type\", content);\n },\n contentLength(content: number) {\n this.set(\"content-length\", content);\n },\n redirect(status: number, path: string) {\n this.statusCode = status;\n this.set(\"location\", path);\n },\n location(path: string) {\n this.set(\"location\", path);\n },\n get(key: string) {\n return this.headers[key.toLowerCase()];\n },\n getHeaders() {\n return this.headers;\n },\n set(key: string, value: any) {\n this.headers[key.toLowerCase()] = value;\n return this;\n },\n send(data: any) {\n this.data = data;\n },\n json(data: any) {\n this.data = data;\n },\n ...options\n };\n }\n\n static createRequestContext(options: Partial<PlatformContextOptions & any> = {}) {\n const event = {\n request: options?.request?.request || options?.event?.request || PlatformTest.createRequest(),\n response: options?.response?.response || options?.event?.response || PlatformTest.createResponse()\n };\n\n return new PlatformContext({\n id: \"id\",\n injector: DITest.injector,\n logger: DITest.injector.logger,\n url: \"/\",\n ...options,\n event\n });\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export const value1 = "value";
2
+ export class Test1 {
3
+ }
4
+ //# sourceMappingURL=Test1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Test1.js","sourceRoot":"","sources":["../../../../src/utils/__mock__/Test1.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC;AAE9B,MAAM,OAAO,KAAK;CAAG","sourcesContent":["export const value1 = \"value\";\n\nexport class Test1 {}\n"]}
@@ -0,0 +1,4 @@
1
+ export const value2 = "value";
2
+ export class Test2 {
3
+ }
4
+ //# sourceMappingURL=Test2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Test2.js","sourceRoot":"","sources":["../../../../src/utils/__mock__/Test2.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC;AAE9B,MAAM,OAAO,KAAK;CAAG","sourcesContent":["export const value2 = \"value\";\n\nexport class Test2 {}\n"]}
@@ -0,0 +1,9 @@
1
+ import { __decorate } from "tslib";
2
+ import { Controller } from "@tsed/di";
3
+ let TestCtrl = class TestCtrl {
4
+ };
5
+ TestCtrl = __decorate([
6
+ Controller("/root")
7
+ ], TestCtrl);
8
+ export { TestCtrl };
9
+ //# sourceMappingURL=TestCtrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestCtrl.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/controllers/rest/TestCtrl.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,IAAa,QAAQ,GAArB,MAAa,QAAQ;CAAG,CAAA;AAAX,QAAQ;IADpB,UAAU,CAAC,OAAO,CAAC;GACP,QAAQ,CAAG;SAAX,QAAQ","sourcesContent":["import {Controller} from \"@tsed/di\";\n\n@Controller(\"/root\")\nexport class TestCtrl {}\n"]}
@@ -0,0 +1,16 @@
1
+ import { __decorate } from "tslib";
2
+ import { SubModule } from "./submodule/SubModule.js";
3
+ import { Module } from "@tsed/di";
4
+ import { M1Ctrl1 } from "./controllers/M1Ctrl1.js";
5
+ let Module1 = class Module1 {
6
+ };
7
+ Module1 = __decorate([
8
+ Module({
9
+ mount: {
10
+ "/m1": [M1Ctrl1]
11
+ },
12
+ imports: [SubModule]
13
+ })
14
+ ], Module1);
15
+ export { Module1 };
16
+ //# sourceMappingURL=Module1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Module1.js","sourceRoot":"","sources":["../../../../../src/utils/__mock__/module1/Module1.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAQ9C,IAAa,OAAO,GAApB,MAAa,OAAO;CAAG,CAAA;AAAV,OAAO;IANnB,MAAM,CAAC;QACN,KAAK,EAAE;YACL,KAAK,EAAE,CAAC,OAAO,CAAC;SACjB;QACD,OAAO,EAAE,CAAC,SAAS,CAAC;KACrB,CAAC;GACW,OAAO,CAAG;SAAV,OAAO","sourcesContent":["import {SubModule} from \"./submodule/SubModule\";\nimport {Module} from \"@tsed/di\";\nimport {M1Ctrl1} from \"./controllers/M1Ctrl1\";\n\n@Module({\n mount: {\n \"/m1\": [M1Ctrl1]\n },\n imports: [SubModule]\n})\nexport class Module1 {}\n"]}
@@ -0,0 +1,14 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Controller } from "@tsed/di";
3
+ import { M1Service } from "../services/M1Service.js";
4
+ let M1Ctrl1 = class M1Ctrl1 {
5
+ constructor(service) {
6
+ this.service = service;
7
+ }
8
+ };
9
+ M1Ctrl1 = __decorate([
10
+ Controller("/m1"),
11
+ __metadata("design:paramtypes", [M1Service])
12
+ ], M1Ctrl1);
13
+ export { M1Ctrl1 };
14
+ //# sourceMappingURL=M1Ctrl1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"M1Ctrl1.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module1/controllers/M1Ctrl1.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAGhD,IAAa,OAAO,GAApB,MAAa,OAAO;IAClB,YAAmB,OAAkB;QAAlB,YAAO,GAAP,OAAO,CAAW;IAAG,CAAC;CAC1C,CAAA;AAFY,OAAO;IADnB,UAAU,CAAC,KAAK,CAAC;qCAEY,SAAS;GAD1B,OAAO,CAEnB;SAFY,OAAO","sourcesContent":["import {Controller} from \"@tsed/di\";\nimport {M1Service} from \"../services/M1Service\";\n\n@Controller(\"/m1\")\nexport class M1Ctrl1 {\n constructor(public service: M1Service) {}\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Injectable } from "@tsed/di";
3
+ import { SubService } from "../submodule/SubService.js";
4
+ let M1Service = class M1Service {
5
+ constructor(subService) {
6
+ this.subService = subService;
7
+ }
8
+ };
9
+ M1Service = __decorate([
10
+ Injectable(),
11
+ __metadata("design:paramtypes", [SubService])
12
+ ], M1Service);
13
+ export { M1Service };
14
+ //# sourceMappingURL=M1Service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"M1Service.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module1/services/M1Service.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAC;AAGnD,IAAa,SAAS,GAAtB,MAAa,SAAS;IACpB,YAAmB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;CAC9C,CAAA;AAFY,SAAS;IADrB,UAAU,EAAE;qCAEoB,UAAU;GAD9B,SAAS,CAErB;SAFY,SAAS","sourcesContent":["import {Injectable} from \"@tsed/di\";\nimport {SubService} from \"../submodule/SubService\";\n\n@Injectable()\nexport class M1Service {\n constructor(public subService: SubService) {}\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { __decorate } from "tslib";
2
+ import { Module } from "@tsed/di";
3
+ import { SubService } from "./SubService.js";
4
+ let SubModule = class SubModule {
5
+ };
6
+ SubModule = __decorate([
7
+ Module({
8
+ imports: [SubService]
9
+ })
10
+ ], SubModule);
11
+ export { SubModule };
12
+ //# sourceMappingURL=SubModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubModule.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module1/submodule/SubModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAKxC,IAAa,SAAS,GAAtB,MAAa,SAAS;CAAG,CAAA;AAAZ,SAAS;IAHrB,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,UAAU,CAAC;KACtB,CAAC;GACW,SAAS,CAAG;SAAZ,SAAS","sourcesContent":["import {Module} from \"@tsed/di\";\nimport {SubService} from \"./SubService\";\n\n@Module({\n imports: [SubService]\n})\nexport class SubModule {}\n"]}
@@ -0,0 +1,9 @@
1
+ import { __decorate } from "tslib";
2
+ import { Injectable } from "@tsed/di";
3
+ let SubService = class SubService {
4
+ };
5
+ SubService = __decorate([
6
+ Injectable()
7
+ ], SubService);
8
+ export { SubService };
9
+ //# sourceMappingURL=SubService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubService.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module1/submodule/SubService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,IAAa,UAAU,GAAvB,MAAa,UAAU;CAAG,CAAA;AAAb,UAAU;IADtB,UAAU,EAAE;GACA,UAAU,CAAG;SAAb,UAAU","sourcesContent":["import {Injectable} from \"@tsed/di\";\n\n@Injectable()\nexport class SubService {}\n"]}
@@ -0,0 +1,15 @@
1
+ import { __decorate } from "tslib";
2
+ import { Module } from "@tsed/di";
3
+ import { M2Ctrl } from "./controllers/M2Ctrl.js";
4
+ let Module2 = class Module2 {
5
+ };
6
+ Module2 = __decorate([
7
+ Module({
8
+ mount: {
9
+ "/mod2": [M2Ctrl]
10
+ },
11
+ imports: []
12
+ })
13
+ ], Module2);
14
+ export { Module2 };
15
+ //# sourceMappingURL=Module2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Module2.js","sourceRoot":"","sources":["../../../../../src/utils/__mock__/module2/Module2.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAQ5C,IAAa,OAAO,GAApB,MAAa,OAAO;CAAG,CAAA;AAAV,OAAO;IANnB,MAAM,CAAC;QACN,KAAK,EAAE;YACL,OAAO,EAAE,CAAC,MAAM,CAAC;SAClB;QACD,OAAO,EAAE,EAAE;KACZ,CAAC;GACW,OAAO,CAAG;SAAV,OAAO","sourcesContent":["import {Module} from \"@tsed/di\";\nimport {M2Ctrl} from \"./controllers/M2Ctrl\";\n\n@Module({\n mount: {\n \"/mod2\": [M2Ctrl]\n },\n imports: []\n})\nexport class Module2 {}\n"]}
@@ -0,0 +1,9 @@
1
+ import { __decorate } from "tslib";
2
+ import { Controller } from "@tsed/di";
3
+ let M2Ctrl = class M2Ctrl {
4
+ };
5
+ M2Ctrl = __decorate([
6
+ Controller("/m2")
7
+ ], M2Ctrl);
8
+ export { M2Ctrl };
9
+ //# sourceMappingURL=M2Ctrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"M2Ctrl.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module2/controllers/M2Ctrl.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,IAAa,MAAM,GAAnB,MAAa,MAAM;CAAG,CAAA;AAAT,MAAM;IADlB,UAAU,CAAC,KAAK,CAAC;GACL,MAAM,CAAG;SAAT,MAAM","sourcesContent":["import {Controller} from \"@tsed/di\";\n\n@Controller(\"/m2\")\nexport class M2Ctrl {}\n"]}
@@ -0,0 +1,34 @@
1
+ import { PlatformContext } from "../domain/PlatformContext.js";
2
+ import { PlatformRequest } from "../services/PlatformRequest.js";
3
+ import { PlatformResponse } from "../services/PlatformResponse.js";
4
+ import { v4 } from "uuid";
5
+ const defaultReqIdBuilder = (req) => req.get("x-request-id") || v4().replace(/-/gi, "");
6
+ /**
7
+ * Create the TsED context to wrap request, response, injector, etc...
8
+ * @param injector
9
+ * @ignore
10
+ */
11
+ export function createContext(injector) {
12
+ var _a, _b;
13
+ const ResponseKlass = (_a = injector.getProvider(PlatformResponse)) === null || _a === void 0 ? void 0 : _a.useClass;
14
+ const RequestKlass = (_b = injector.getProvider(PlatformRequest)) === null || _b === void 0 ? void 0 : _b.useClass;
15
+ const { reqIdBuilder = defaultReqIdBuilder, ...loggerOptions } = injector.settings.logger || {};
16
+ return async (event) => {
17
+ const ctx = new PlatformContext({
18
+ event,
19
+ id: reqIdBuilder(event.request),
20
+ logger: injector.logger,
21
+ ...loggerOptions,
22
+ injector,
23
+ ResponseKlass,
24
+ RequestKlass
25
+ });
26
+ ctx.response.onEnd(async () => {
27
+ await ctx.emit("$onResponse", ctx);
28
+ await ctx.destroy();
29
+ });
30
+ await ctx.emit("$onRequest", ctx);
31
+ return ctx;
32
+ };
33
+ }
34
+ //# sourceMappingURL=createContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createContext.js","sourceRoot":"","sources":["../../../src/utils/createContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAC,EAAE,EAAC,MAAM,MAAM,CAAC;AAExB,MAAM,mBAAmB,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAE7F;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,QAAyB;;IACrD,MAAM,aAAa,GAAG,MAAA,QAAQ,CAAC,WAAW,CAAC,gBAAgB,CAAC,0CAAE,QAAQ,CAAC;IACvE,MAAM,YAAY,GAAG,MAAA,QAAQ,CAAC,WAAW,CAAC,eAAe,CAAC,0CAAE,QAAQ,CAAC;IACrE,MAAM,EAAC,YAAY,GAAG,mBAAmB,EAAE,GAAG,aAAa,EAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC;IAE9F,OAAO,KAAK,EAAE,KAAoB,EAA4B,EAAE;QAC9D,MAAM,GAAG,GAAG,IAAI,eAAe,CAAC;YAC9B,KAAK;YACL,EAAE,EAAE,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC;YAC/B,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,GAAG,aAAa;YAChB,QAAQ;YACR,aAAa;YACb,YAAY;SACb,CAAC,CAAC;QAEH,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;YAC5B,MAAM,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;YACnC,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC,CAAC,CAAC;QAEH,MAAM,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;QAElC,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {InjectorService} from \"@tsed/di\";\nimport {PlatformContext} from \"../domain/PlatformContext\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\nimport {IncomingEvent} from \"../interfaces/IncomingEvent\";\nimport {v4} from \"uuid\";\n\nconst defaultReqIdBuilder = (req: any) => req.get(\"x-request-id\") || v4().replace(/-/gi, \"\");\n\n/**\n * Create the TsED context to wrap request, response, injector, etc...\n * @param injector\n * @ignore\n */\nexport function createContext(injector: InjectorService) {\n const ResponseKlass = injector.getProvider(PlatformResponse)?.useClass;\n const RequestKlass = injector.getProvider(PlatformRequest)?.useClass;\n const {reqIdBuilder = defaultReqIdBuilder, ...loggerOptions} = injector.settings.logger || {};\n\n return async (event: IncomingEvent): Promise<PlatformContext> => {\n const ctx = new PlatformContext({\n event,\n id: reqIdBuilder(event.request),\n logger: injector.logger,\n ...loggerOptions,\n injector,\n ResponseKlass,\n RequestKlass\n });\n\n ctx.response.onEnd(async () => {\n await ctx.emit(\"$onResponse\", ctx);\n await ctx.destroy();\n });\n\n await ctx.emit(\"$onRequest\", ctx);\n\n return ctx;\n };\n}\n"]}
@@ -0,0 +1,45 @@
1
+ import { EndpointMetadata } from "@tsed/schema";
2
+ import { HandlerMetadata } from "../domain/HandlerMetadata.js";
3
+ import { HandlerType } from "../interfaces/HandlerType.js";
4
+ function isMetadata(input) {
5
+ return input instanceof HandlerMetadata;
6
+ }
7
+ /**
8
+ * @ignore
9
+ */
10
+ export function createHandlerMetadata(injector, obj, routeOptions = {}) {
11
+ if (isMetadata(obj)) {
12
+ return obj;
13
+ }
14
+ let options;
15
+ if (obj instanceof EndpointMetadata) {
16
+ const provider = injector.getProvider(routeOptions.token);
17
+ options = {
18
+ token: provider.token,
19
+ target: provider.useClass,
20
+ scope: provider.scope,
21
+ type: HandlerType.ENDPOINT,
22
+ propertyKey: obj.propertyKey
23
+ };
24
+ }
25
+ else {
26
+ const provider = injector.getProvider(obj);
27
+ if (provider) {
28
+ options = {
29
+ token: provider.token,
30
+ target: provider.useClass,
31
+ scope: provider.scope,
32
+ type: HandlerType.MIDDLEWARE,
33
+ propertyKey: "use"
34
+ };
35
+ }
36
+ else {
37
+ options = {
38
+ target: obj
39
+ };
40
+ }
41
+ }
42
+ options.routeOptions = routeOptions;
43
+ return new HandlerMetadata(options);
44
+ }
45
+ //# sourceMappingURL=createHandlerMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createHandlerMetadata.js","sourceRoot":"","sources":["../../../src/utils/createHandlerMetadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAyB,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AAGtD,SAAS,UAAU,CAAC,KAAU;IAC5B,OAAO,KAAK,YAAY,eAAe,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAyB,EACzB,GAA2B,EAC3B,eAA6C,EAAE;IAE/C,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE;QACnB,OAAO,GAAsB,CAAC;KAC/B;IAED,IAAI,OAA+B,CAAC;IAEpC,IAAI,GAAG,YAAY,gBAAgB,EAAE;QACnC,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,CAAE,CAAC;QAE3D,OAAO,GAAG;YACR,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,MAAM,EAAE,QAAQ,CAAC,QAAQ;YACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,IAAI,EAAE,WAAW,CAAC,QAAQ;YAC1B,WAAW,EAAE,GAAG,CAAC,WAAW;SAC7B,CAAC;KACH;SAAM;QACL,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAE3C,IAAI,QAAQ,EAAE;YACZ,OAAO,GAAG;gBACR,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,MAAM,EAAE,QAAQ,CAAC,QAAQ;gBACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,IAAI,EAAE,WAAW,CAAC,UAAU;gBAC5B,WAAW,EAAE,KAAK;aACnB,CAAC;SACH;aAAM;YACL,OAAO,GAAG;gBACR,MAAM,EAAE,GAAG;aACZ,CAAC;SACH;KACF;IAED,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;IAEpC,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import {InjectorService} from \"@tsed/di\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {HandlerMetadata, HandlerMetadataOptions} from \"../domain/HandlerMetadata\";\nimport {HandlerType} from \"../interfaces/HandlerType\";\nimport {PlatformRouteWithoutHandlers} from \"../interfaces/PlatformRouteOptions\";\n\nfunction isMetadata(input: any) {\n return input instanceof HandlerMetadata;\n}\n\n/**\n * @ignore\n */\nexport function createHandlerMetadata(\n injector: InjectorService,\n obj: any | EndpointMetadata,\n routeOptions: PlatformRouteWithoutHandlers = {}\n): HandlerMetadata {\n if (isMetadata(obj)) {\n return obj as HandlerMetadata;\n }\n\n let options: HandlerMetadataOptions;\n\n if (obj instanceof EndpointMetadata) {\n const provider = injector.getProvider(routeOptions.token)!;\n\n options = {\n token: provider.token,\n target: provider.useClass,\n scope: provider.scope,\n type: HandlerType.ENDPOINT,\n propertyKey: obj.propertyKey\n };\n } else {\n const provider = injector.getProvider(obj);\n\n if (provider) {\n options = {\n token: provider.token,\n target: provider.useClass,\n scope: provider.scope,\n type: HandlerType.MIDDLEWARE,\n propertyKey: \"use\"\n };\n } else {\n options = {\n target: obj\n };\n }\n }\n\n options.routeOptions = routeOptions;\n\n return new HandlerMetadata(options);\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import { ProviderScope } from "@tsed/di";
2
+ import { getHostInfoFromPort } from "@tsed/core";
3
+ import Http from "http";
4
+ import { listenServer } from "./listenServer.js";
5
+ export function createHttpServer(injector, requestListener) {
6
+ const { settings } = injector;
7
+ const httpPort = settings.getRaw("httpPort");
8
+ const httpOptions = settings.getRaw("httpOptions");
9
+ const server = httpPort !== false ? Http.createServer(httpOptions, requestListener) : null;
10
+ injector.addProvider(Http.Server, {
11
+ scope: ProviderScope.SINGLETON,
12
+ useValue: server
13
+ });
14
+ injector.invoke(Http.Server);
15
+ if (server) {
16
+ const hostInfo = getHostInfoFromPort("http", httpPort);
17
+ return async () => {
18
+ const resolvedHostInfo = await listenServer(injector, server, hostInfo);
19
+ settings.setRaw("httpPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
20
+ return server;
21
+ };
22
+ }
23
+ }
24
+ //# sourceMappingURL=createHttpServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createHttpServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAC,MAAM,UAAU,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,gBAAgB,CAAC,QAAyB,EAAE,eAAqC;IAC/F,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAEnD,MAAM,MAAM,GAAG,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3F,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE;QAChC,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE7B,IAAI,MAAM,EAAE;QACV,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEvD,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,MAAqB,EAAE,QAAQ,CAAC,CAAC;YACvF,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,gBAAgB,CAAC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;YACpF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH;AACH,CAAC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Http from \"http\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpServer(injector: InjectorService, requestListener: Http.RequestListener) {\n const {settings} = injector;\n const httpPort = settings.getRaw(\"httpPort\");\n const httpOptions = settings.getRaw(\"httpOptions\");\n\n const server = httpPort !== false ? Http.createServer(httpOptions, requestListener) : null;\n\n injector.addProvider(Http.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(Http.Server);\n\n if (server) {\n const hostInfo = getHostInfoFromPort(\"http\", httpPort);\n\n return async () => {\n const resolvedHostInfo = await listenServer(injector, server as Http.Server, hostInfo);\n settings.setRaw(\"httpPort\", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);\n return server;\n };\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import { ProviderScope } from "@tsed/di";
2
+ import { getHostInfoFromPort } from "@tsed/core";
3
+ import Https from "https";
4
+ import { listenServer } from "./listenServer.js";
5
+ export function createHttpsServer(injector, requestListener) {
6
+ const { settings } = injector;
7
+ const httpsPort = settings.getRaw("httpsPort");
8
+ const httpsOptions = settings.getRaw("httpsOptions");
9
+ const server = httpsPort !== false ? Https.createServer(httpsOptions, requestListener) : null;
10
+ injector.addProvider(Https.Server, {
11
+ scope: ProviderScope.SINGLETON,
12
+ useValue: server
13
+ });
14
+ injector.invoke(Https.Server);
15
+ if (server) {
16
+ const hostInfo = getHostInfoFromPort("https", httpsPort);
17
+ return async () => {
18
+ const resolvedHostInfo = await listenServer(injector, server, hostInfo);
19
+ settings.setRaw("httpsPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
20
+ return server;
21
+ };
22
+ }
23
+ }
24
+ //# sourceMappingURL=createHttpsServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createHttpsServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpsServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAC,MAAM,UAAU,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,iBAAiB,CAAC,QAAyB,EAAE,eAAsC;IACjG,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC/C,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAErD,MAAM,MAAM,GAAG,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE9F,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE;QACjC,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B,IAAI,MAAM,EAAE;QACV,MAAM,QAAQ,GAAG,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAEzD,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,MAAsB,EAAE,QAAQ,CAAC,CAAC;YACxF,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,gBAAgB,CAAC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;YACrF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH;AACH,CAAC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Https from \"https\";\nimport Http from \"http\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpsServer(injector: InjectorService, requestListener?: Http.RequestListener) {\n const {settings} = injector;\n const httpsPort = settings.getRaw(\"httpsPort\");\n const httpsOptions = settings.getRaw(\"httpsOptions\");\n\n const server = httpsPort !== false ? Https.createServer(httpsOptions, requestListener) : null;\n\n injector.addProvider(Https.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(Https.Server);\n\n if (server) {\n const hostInfo = getHostInfoFromPort(\"https\", httpsPort);\n\n return async () => {\n const resolvedHostInfo = await listenServer(injector, server as Https.Server, hostInfo);\n settings.setRaw(\"httpsPort\", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);\n return server;\n };\n }\n}\n"]}
@@ -0,0 +1,42 @@
1
+ import { InjectorService, setLoggerLevel } from "@tsed/di";
2
+ import { $log } from "@tsed/logger";
3
+ import { toMap } from "@tsed/core";
4
+ import { PlatformConfiguration } from "../config/services/PlatformConfiguration.js";
5
+ import { PlatformHandler } from "../services/PlatformHandler.js";
6
+ import { PlatformResponse } from "../services/PlatformResponse.js";
7
+ import { PlatformRouter } from "../services/PlatformRouter.js";
8
+ import { PlatformApplication } from "../services/PlatformApplication.js";
9
+ import { Platform } from "../services/Platform.js";
10
+ import { PlatformRequest } from "../services/PlatformRequest.js";
11
+ import { PlatformAdapter } from "../services/PlatformAdapter.js";
12
+ $log.name = "TSED";
13
+ const DEFAULT_PROVIDERS = [
14
+ { provide: PlatformHandler },
15
+ { provide: PlatformResponse },
16
+ { provide: PlatformRequest },
17
+ { provide: PlatformRouter },
18
+ { provide: PlatformApplication },
19
+ { provide: Platform }
20
+ ];
21
+ export function createInjector({ adapter, settings = {} }) {
22
+ const injector = new InjectorService();
23
+ injector.addProvider(PlatformConfiguration);
24
+ injector.settings = injector.invoke(PlatformConfiguration);
25
+ injector.logger = $log;
26
+ injector.settings.set(settings);
27
+ if (adapter) {
28
+ injector.addProvider(PlatformAdapter, {
29
+ useClass: adapter
30
+ });
31
+ }
32
+ injector.invoke(PlatformAdapter);
33
+ setLoggerLevel(injector);
34
+ const instance = injector.get(PlatformAdapter);
35
+ instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];
36
+ toMap(instance.providers, "provide").forEach((provider, token) => {
37
+ injector.addProvider(token, provider);
38
+ });
39
+ injector.invoke(PlatformApplication);
40
+ return injector;
41
+ }
42
+ //# sourceMappingURL=createInjector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../src/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAgB,cAAc,EAAC,MAAM,UAAU,CAAC;AACvE,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAC,KAAK,EAAO,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,qBAAqB,EAAC,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OA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KAAK,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAErC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {InjectorService, ProviderOpts, setLoggerLevel} from \"@tsed/di\";\nimport {$log} from \"@tsed/logger\";\nimport {toMap, Type} from \"@tsed/core\";\nimport {PlatformConfiguration} from \"../config/services/PlatformConfiguration\";\nimport {PlatformHandler} from \"../services/PlatformHandler\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\nimport {PlatformRouter} from \"../services/PlatformRouter\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformAdapter} from \"../services/PlatformAdapter\";\n\n$log.name = \"TSED\";\n\nconst DEFAULT_PROVIDERS = [\n {provide: PlatformHandler},\n {provide: PlatformResponse},\n {provide: PlatformRequest},\n {provide: PlatformRouter},\n {provide: PlatformApplication},\n {provide: Platform}\n];\n\ninterface CreateInjectorOptions {\n adapter?: Type<PlatformAdapter<any, any>>;\n settings?: Partial<TsED.Configuration>;\n}\n\nexport function createInjector({adapter, settings = {}}: CreateInjectorOptions) {\n const injector = new InjectorService();\n injector.addProvider(PlatformConfiguration);\n\n injector.settings = injector.invoke(PlatformConfiguration);\n injector.logger = $log;\n injector.settings.set(settings);\n\n if (adapter) {\n injector.addProvider(PlatformAdapter, {\n useClass: adapter\n });\n }\n\n injector.invoke(PlatformAdapter);\n\n setLoggerLevel(injector);\n\n const instance = injector.get<PlatformAdapter>(PlatformAdapter)!;\n\n instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];\n\n toMap<any, ProviderOpts>(instance.providers, \"provide\").forEach((provider, token) => {\n injector.addProvider(token, provider);\n });\n\n injector.invoke(PlatformApplication);\n\n return injector;\n}\n"]}
@@ -0,0 +1,42 @@
1
+ import { deepMerge, Env, Store } from "@tsed/core";
2
+ import { ProviderScope, ProviderType } from "@tsed/di";
3
+ export function getConfiguration(configuration = {}, module = null) {
4
+ if (configuration.$$resolved) {
5
+ return configuration;
6
+ }
7
+ const store = module ? Store.from(module).get("configuration") || {} : {};
8
+ const env = configuration.env || store.env || process.env.NODE_ENV || Env.DEV;
9
+ const config = {
10
+ $$resolved: true,
11
+ exclude: ["**/*.spec.ts", "**/*.spec.js"],
12
+ componentsScan: ["${rootDir}/mvc/**/*.ts", "${rootDir}/services/**/*.ts", "${rootDir}/middlewares/**/*.ts"],
13
+ env,
14
+ httpPort: 8080,
15
+ httpsPort: false,
16
+ ...store,
17
+ ...configuration,
18
+ scopes: {
19
+ [ProviderType.CONTROLLER]: ProviderScope.SINGLETON,
20
+ ...store.scopes,
21
+ ...configuration.scopes
22
+ },
23
+ mount: store.mount || configuration.mount
24
+ ? deepMerge(store.mount || {}, configuration.mount || {})
25
+ : {
26
+ "/rest": "${rootDir}/controllers/**/*.ts"
27
+ },
28
+ logger: {
29
+ debug: false,
30
+ level: env === Env.TEST ? "off" : "info",
31
+ logRequest: true,
32
+ ...store.logger,
33
+ ...configuration.logger,
34
+ jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2
35
+ }
36
+ };
37
+ if (!configuration.disableComponentsScan && store.componentsScan && configuration.componentsScan) {
38
+ config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];
39
+ }
40
+ return config;
41
+ }
42
+ //# sourceMappingURL=getConfiguration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getConfiguration.js","sourceRoot":"","sources":["../../../src/utils/getConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,GAAG,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AACvD,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AAErD,MAAM,UAAU,gBAAgB,CAAC,gBAAqB,EAAE,EAAE,SAA2B,IAAI;IACvF,IAAI,aAAa,CAAC,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IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3D;KACF,CAAC;IAEF,IAAI,CAAC,aAAa,CAAC,qBAAqB,IAAI,KAAK,CAAC,cAAc,IAAI,aAAa,CAAC,cAAc,EAAE;QAChG,MAAM,CAAC,cAAc,GAAG,CAAC,GAAG,KAAK,CAAC,cAAc,EAAE,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;KACpF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import {deepMerge, Env, Store, Type} from \"@tsed/core\";\nimport {ProviderScope, ProviderType} from \"@tsed/di\";\n\nexport function getConfiguration(configuration: any = {}, module: Type<any> | null = null) {\n if (configuration.$$resolved) {\n return configuration;\n }\n\n const store = module ? Store.from(module).get(\"configuration\") || {} : {};\n const env = configuration.env || store.env || (process.env.NODE_ENV as Env) || Env.DEV;\n\n const config = {\n $$resolved: true,\n exclude: [\"**/*.spec.ts\", \"**/*.spec.js\"],\n componentsScan: [\"${rootDir}/mvc/**/*.ts\", \"${rootDir}/services/**/*.ts\", \"${rootDir}/middlewares/**/*.ts\"],\n env,\n httpPort: 8080,\n httpsPort: false,\n ...store,\n ...configuration,\n scopes: {\n [ProviderType.CONTROLLER]: ProviderScope.SINGLETON,\n ...store.scopes,\n ...configuration.scopes\n },\n mount:\n store.mount || configuration.mount\n ? deepMerge(store.mount || {}, configuration.mount || {})\n : {\n \"/rest\": \"${rootDir}/controllers/**/*.ts\"\n },\n logger: {\n debug: false,\n level: env === Env.TEST ? \"off\" : \"info\",\n logRequest: true,\n ...store.logger,\n ...configuration.logger,\n jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2\n }\n };\n\n if (!configuration.disableComponentsScan && store.componentsScan && configuration.componentsScan) {\n config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];\n }\n\n return config;\n}\n"]}