@tsed/common 6.88.1 → 6.92.0

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 (543) hide show
  1. package/lib/{PlatformModule.d.ts → cjs/PlatformModule.d.ts} +0 -0
  2. package/lib/cjs/PlatformModule.js +11 -0
  3. package/lib/cjs/PlatformModule.js.map +1 -0
  4. package/lib/{builder → cjs/builder}/PlatformBuilder.d.ts +15 -27
  5. package/lib/cjs/builder/PlatformBuilder.js +275 -0
  6. package/lib/cjs/builder/PlatformBuilder.js.map +1 -0
  7. package/lib/{builder → cjs/builder}/PlatformControllerBuilder.d.ts +0 -0
  8. package/lib/cjs/builder/PlatformControllerBuilder.js +85 -0
  9. package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -0
  10. package/lib/{config → cjs/config}/index.d.ts +0 -0
  11. package/lib/cjs/config/index.js +7 -0
  12. package/lib/cjs/config/index.js.map +1 -0
  13. package/lib/{config → cjs/config}/interfaces/ConverterSettings.d.ts +0 -0
  14. package/lib/cjs/config/interfaces/ConverterSettings.js +3 -0
  15. package/lib/cjs/config/interfaces/ConverterSettings.js.map +1 -0
  16. package/lib/{config → cjs/config}/interfaces/EndpointDirectoriesSettings.d.ts +0 -0
  17. package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js +3 -0
  18. package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js.map +1 -0
  19. package/lib/{config → cjs/config}/interfaces/PlatformLoggerSettings.d.ts +0 -0
  20. package/lib/cjs/config/interfaces/PlatformLoggerSettings.js +3 -0
  21. package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -0
  22. package/lib/{config → cjs/config}/interfaces/PlatformMulterSettings.d.ts +0 -0
  23. package/lib/cjs/config/interfaces/PlatformMulterSettings.js +3 -0
  24. package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -0
  25. package/lib/{config → cjs/config}/interfaces/PlatformStaticsSettings.d.ts +0 -0
  26. package/lib/cjs/config/interfaces/PlatformStaticsSettings.js +3 -0
  27. package/lib/cjs/config/interfaces/PlatformStaticsSettings.js.map +1 -0
  28. package/lib/{config → cjs/config}/interfaces/index.d.ts +10 -1
  29. package/lib/cjs/config/interfaces/index.js +8 -0
  30. package/lib/cjs/config/interfaces/index.js.map +1 -0
  31. package/lib/{config → cjs/config}/services/PlatformConfiguration.d.ts +9 -13
  32. package/lib/cjs/config/services/PlatformConfiguration.js +178 -0
  33. package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -0
  34. package/lib/{constants → cjs/constants}/routerOptions.d.ts +0 -0
  35. package/lib/cjs/constants/routerOptions.js +5 -0
  36. package/lib/cjs/constants/routerOptions.js.map +1 -0
  37. package/lib/{decorators → cjs/decorators}/httpServer.d.ts +1 -0
  38. package/lib/cjs/decorators/httpServer.js +32 -0
  39. package/lib/cjs/decorators/httpServer.js.map +1 -0
  40. package/lib/{decorators → cjs/decorators}/httpsServer.d.ts +1 -0
  41. package/lib/cjs/decorators/httpsServer.js +32 -0
  42. package/lib/cjs/decorators/httpsServer.js.map +1 -0
  43. package/lib/{decorators → cjs/decorators}/index.d.ts +0 -0
  44. package/lib/cjs/decorators/index.js +23 -0
  45. package/lib/cjs/decorators/index.js.map +1 -0
  46. package/lib/{decorators → cjs/decorators}/method/acceptMime.d.ts +0 -0
  47. package/lib/cjs/decorators/method/acceptMime.js +28 -0
  48. package/lib/cjs/decorators/method/acceptMime.js.map +1 -0
  49. package/lib/{decorators → cjs/decorators}/method/endpointFn.d.ts +0 -0
  50. package/lib/cjs/decorators/method/endpointFn.js +15 -0
  51. package/lib/cjs/decorators/method/endpointFn.js.map +1 -0
  52. package/lib/{decorators → cjs/decorators}/method/location.d.ts +0 -0
  53. package/lib/cjs/decorators/method/location.js +6 -0
  54. package/lib/cjs/decorators/method/location.js.map +1 -0
  55. package/lib/{decorators → cjs/decorators}/method/redirect.d.ts +0 -0
  56. package/lib/cjs/decorators/method/redirect.js +6 -0
  57. package/lib/cjs/decorators/method/redirect.js.map +1 -0
  58. package/lib/{decorators → cjs/decorators}/method/route.d.ts +0 -0
  59. package/lib/cjs/decorators/method/route.js +13 -0
  60. package/lib/cjs/decorators/method/route.js.map +1 -0
  61. package/lib/{decorators → cjs/decorators}/method/view.d.ts +0 -0
  62. package/lib/cjs/decorators/method/view.js +34 -0
  63. package/lib/cjs/decorators/method/view.js.map +1 -0
  64. package/lib/{decorators → cjs/decorators}/multer/index.d.ts +0 -0
  65. package/lib/cjs/decorators/multer/index.js +7 -0
  66. package/lib/cjs/decorators/multer/index.js.map +1 -0
  67. package/lib/{decorators → cjs/decorators}/multer/multerFileSize.d.ts +0 -0
  68. package/lib/cjs/decorators/multer/multerFileSize.js +35 -0
  69. package/lib/cjs/decorators/multer/multerFileSize.js.map +1 -0
  70. package/lib/{decorators → cjs/decorators}/multer/multerOptions.d.ts +0 -0
  71. package/lib/cjs/decorators/multer/multerOptions.js +52 -0
  72. package/lib/cjs/decorators/multer/multerOptions.js.map +1 -0
  73. package/lib/{decorators → cjs/decorators}/multer/multipartFile.d.ts +0 -0
  74. package/lib/cjs/decorators/multer/multipartFile.js +78 -0
  75. package/lib/cjs/decorators/multer/multipartFile.js.map +1 -0
  76. package/lib/{decorators → cjs/decorators}/params/endpointInfo.d.ts +0 -0
  77. package/lib/cjs/decorators/params/endpointInfo.js +21 -0
  78. package/lib/cjs/decorators/params/endpointInfo.js.map +1 -0
  79. package/lib/{decorators → cjs/decorators}/params/error.d.ts +0 -0
  80. package/lib/cjs/decorators/params/error.js +20 -0
  81. package/lib/cjs/decorators/params/error.js.map +1 -0
  82. package/lib/{decorators → cjs/decorators}/params/next.d.ts +0 -0
  83. package/lib/cjs/decorators/params/next.js +21 -0
  84. package/lib/cjs/decorators/params/next.js.map +1 -0
  85. package/lib/{decorators → cjs/decorators}/params/request.d.ts +0 -0
  86. package/lib/cjs/decorators/params/request.js +39 -0
  87. package/lib/cjs/decorators/params/request.js.map +1 -0
  88. package/lib/{decorators → cjs/decorators}/params/response.d.ts +0 -0
  89. package/lib/cjs/decorators/params/response.js +33 -0
  90. package/lib/cjs/decorators/params/response.js.map +1 -0
  91. package/lib/{decorators → cjs/decorators}/params/responseData.d.ts +0 -0
  92. package/lib/cjs/decorators/params/responseData.js +21 -0
  93. package/lib/cjs/decorators/params/responseData.js.map +1 -0
  94. package/lib/{domain → cjs/domain}/AnyToPromiseWithCtx.d.ts +0 -0
  95. package/lib/cjs/domain/AnyToPromiseWithCtx.js +35 -0
  96. package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -0
  97. package/lib/{domain → cjs/domain}/ControllerProvider.d.ts +0 -0
  98. package/lib/cjs/domain/ControllerProvider.js +51 -0
  99. package/lib/cjs/domain/ControllerProvider.js.map +1 -0
  100. package/lib/{domain → cjs/domain}/EndpointMetadata.d.ts +0 -0
  101. package/lib/cjs/domain/EndpointMetadata.js +111 -0
  102. package/lib/cjs/domain/EndpointMetadata.js.map +1 -0
  103. package/lib/{domain → cjs/domain}/HandlerMetadata.d.ts +0 -0
  104. package/lib/cjs/domain/HandlerMetadata.js +57 -0
  105. package/lib/cjs/domain/HandlerMetadata.js.map +1 -0
  106. package/lib/{domain → cjs/domain}/PlatformContext.d.ts +0 -0
  107. package/lib/cjs/domain/PlatformContext.js +85 -0
  108. package/lib/cjs/domain/PlatformContext.js.map +1 -0
  109. package/lib/{domain → cjs/domain}/PlatformRouteDetails.d.ts +0 -0
  110. package/lib/cjs/domain/PlatformRouteDetails.js +24 -0
  111. package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -0
  112. package/lib/{domain → cjs/domain}/PropertyMetadata.d.ts +0 -0
  113. package/lib/cjs/domain/PropertyMetadata.js +28 -0
  114. package/lib/cjs/domain/PropertyMetadata.js.map +1 -0
  115. package/lib/{domain → cjs/domain}/index.d.ts +0 -0
  116. package/lib/cjs/domain/index.js +11 -0
  117. package/lib/cjs/domain/index.js.map +1 -0
  118. package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  119. package/lib/cjs/index.js +37 -0
  120. package/lib/cjs/index.js.map +1 -0
  121. package/lib/{interfaces → cjs/interfaces}/AfterInit.d.ts +0 -0
  122. package/lib/cjs/interfaces/AfterInit.js +3 -0
  123. package/lib/cjs/interfaces/AfterInit.js.map +1 -0
  124. package/lib/{interfaces → cjs/interfaces}/AfterListen.d.ts +0 -0
  125. package/lib/cjs/interfaces/AfterListen.js +3 -0
  126. package/lib/cjs/interfaces/AfterListen.js.map +1 -0
  127. package/lib/{interfaces → cjs/interfaces}/AfterRoutesInit.d.ts +0 -0
  128. package/lib/cjs/interfaces/AfterRoutesInit.js +3 -0
  129. package/lib/cjs/interfaces/AfterRoutesInit.js.map +1 -0
  130. package/lib/{interfaces → cjs/interfaces}/BeforeInit.d.ts +0 -0
  131. package/lib/cjs/interfaces/BeforeInit.js +3 -0
  132. package/lib/cjs/interfaces/BeforeInit.js.map +1 -0
  133. package/lib/{interfaces → cjs/interfaces}/BeforeListen.d.ts +0 -0
  134. package/lib/cjs/interfaces/BeforeListen.js +3 -0
  135. package/lib/cjs/interfaces/BeforeListen.js.map +1 -0
  136. package/lib/{interfaces → cjs/interfaces}/BeforeRoutesInit.d.ts +0 -0
  137. package/lib/cjs/interfaces/BeforeRoutesInit.js +3 -0
  138. package/lib/cjs/interfaces/BeforeRoutesInit.js.map +1 -0
  139. package/lib/{interfaces → cjs/interfaces}/HandlerType.d.ts +0 -0
  140. package/lib/cjs/interfaces/HandlerType.js +17 -0
  141. package/lib/cjs/interfaces/HandlerType.js.map +1 -0
  142. package/lib/{interfaces → cjs/interfaces}/IncomingEvent.d.ts +0 -0
  143. package/lib/cjs/interfaces/IncomingEvent.js +3 -0
  144. package/lib/cjs/interfaces/IncomingEvent.js.map +1 -0
  145. package/lib/{interfaces → cjs/interfaces}/OnReady.d.ts +0 -0
  146. package/lib/cjs/interfaces/OnReady.js +3 -0
  147. package/lib/cjs/interfaces/OnReady.js.map +1 -0
  148. package/lib/{interfaces → cjs/interfaces}/OnRequest.d.ts +0 -0
  149. package/lib/cjs/interfaces/OnRequest.js +3 -0
  150. package/lib/cjs/interfaces/OnRequest.js.map +1 -0
  151. package/lib/{interfaces → cjs/interfaces}/OnResponse.d.ts +0 -0
  152. package/lib/cjs/interfaces/OnResponse.js +3 -0
  153. package/lib/cjs/interfaces/OnResponse.js.map +1 -0
  154. package/lib/{interfaces → cjs/interfaces}/OnRoutesInit.d.ts +0 -0
  155. package/lib/cjs/interfaces/OnRoutesInit.js +3 -0
  156. package/lib/cjs/interfaces/OnRoutesInit.js.map +1 -0
  157. package/lib/{interfaces → cjs/interfaces}/PathType.d.ts +0 -0
  158. package/lib/cjs/interfaces/PathType.js +3 -0
  159. package/lib/cjs/interfaces/PathType.js.map +1 -0
  160. package/lib/cjs/interfaces/PlatformAdapter.d.ts +19 -0
  161. package/lib/cjs/interfaces/PlatformAdapter.js +3 -0
  162. package/lib/cjs/interfaces/PlatformAdapter.js.map +1 -0
  163. package/lib/{interfaces → cjs/interfaces}/PlatformRouteOptions.d.ts +0 -0
  164. package/lib/cjs/interfaces/PlatformRouteOptions.js +3 -0
  165. package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -0
  166. package/lib/{interfaces → cjs/interfaces}/ResponseErrorObject.d.ts +0 -0
  167. package/lib/cjs/interfaces/ResponseErrorObject.js +3 -0
  168. package/lib/cjs/interfaces/ResponseErrorObject.js.map +1 -0
  169. package/lib/{interfaces → cjs/interfaces}/Route.d.ts +0 -0
  170. package/lib/cjs/interfaces/Route.js +3 -0
  171. package/lib/cjs/interfaces/Route.js.map +1 -0
  172. package/lib/{interfaces → cjs/interfaces}/index.d.ts +1 -0
  173. package/lib/cjs/interfaces/index.js +21 -0
  174. package/lib/cjs/interfaces/index.js.map +1 -0
  175. package/lib/{middlewares → cjs/middlewares}/AcceptMimesMiddleware.d.ts +0 -0
  176. package/lib/cjs/middlewares/AcceptMimesMiddleware.js +27 -0
  177. package/lib/cjs/middlewares/AcceptMimesMiddleware.js.map +1 -0
  178. package/lib/{middlewares → cjs/middlewares}/GlobalAcceptMimesMiddleware.d.ts +0 -0
  179. package/lib/cjs/middlewares/GlobalAcceptMimesMiddleware.js +26 -0
  180. package/lib/cjs/middlewares/GlobalAcceptMimesMiddleware.js.map +1 -0
  181. package/lib/{middlewares → cjs/middlewares}/PlatformAcceptMimesMiddleware.d.ts +0 -0
  182. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +37 -0
  183. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
  184. package/lib/{middlewares → cjs/middlewares}/PlatformMulterMiddleware.d.ts +0 -0
  185. package/lib/cjs/middlewares/PlatformMulterMiddleware.js +55 -0
  186. package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -0
  187. package/lib/{middlewares/data → cjs/middlewares/__mock__}/FakeCtrl.d.ts +0 -0
  188. package/lib/cjs/middlewares/__mock__/FakeCtrl.js +12 -0
  189. package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +1 -0
  190. package/lib/{middlewares → cjs/middlewares}/bindEndpointMiddleware.d.ts +0 -0
  191. package/lib/cjs/middlewares/bindEndpointMiddleware.js +13 -0
  192. package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +1 -0
  193. package/lib/{middlewares → cjs/middlewares}/index.d.ts +0 -0
  194. package/lib/cjs/middlewares/index.js +9 -0
  195. package/lib/cjs/middlewares/index.js.map +1 -0
  196. package/lib/{services → cjs/services}/FakeRawDriver.d.ts +0 -0
  197. package/lib/cjs/services/FakeRawDriver.js +26 -0
  198. package/lib/cjs/services/FakeRawDriver.js.map +1 -0
  199. package/lib/{services → cjs/services}/Platform.d.ts +0 -0
  200. package/lib/cjs/services/Platform.js +107 -0
  201. package/lib/cjs/services/Platform.js.map +1 -0
  202. package/lib/{services → cjs/services}/PlatformApplication.d.ts +0 -0
  203. package/lib/cjs/services/PlatformApplication.js +34 -0
  204. package/lib/cjs/services/PlatformApplication.js.map +1 -0
  205. package/lib/{services → cjs/services}/PlatformHandler.d.ts +0 -0
  206. package/lib/cjs/services/PlatformHandler.js +235 -0
  207. package/lib/cjs/services/PlatformHandler.js.map +1 -0
  208. package/lib/{services → cjs/services}/PlatformMiddlewaresChain.d.ts +0 -0
  209. package/lib/cjs/services/PlatformMiddlewaresChain.js +34 -0
  210. package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -0
  211. package/lib/{services → cjs/services}/PlatformRequest.d.ts +0 -0
  212. package/lib/cjs/services/PlatformRequest.js +138 -0
  213. package/lib/cjs/services/PlatformRequest.js.map +1 -0
  214. package/lib/{services → cjs/services}/PlatformResponse.d.ts +0 -0
  215. package/lib/cjs/services/PlatformResponse.js +271 -0
  216. package/lib/cjs/services/PlatformResponse.js.map +1 -0
  217. package/lib/{services → cjs/services}/PlatformRouter.d.ts +0 -0
  218. package/lib/cjs/services/PlatformRouter.js +126 -0
  219. package/lib/cjs/services/PlatformRouter.js.map +1 -0
  220. package/lib/{services → cjs/services}/PlatformTest.d.ts +5 -4
  221. package/lib/cjs/services/PlatformTest.js +167 -0
  222. package/lib/cjs/services/PlatformTest.js.map +1 -0
  223. package/lib/{services → cjs/services}/index.d.ts +0 -0
  224. package/lib/cjs/services/index.js +12 -0
  225. package/lib/cjs/services/index.js.map +1 -0
  226. package/lib/{utils → cjs/utils}/createContext.d.ts +0 -0
  227. package/lib/cjs/utils/createContext.js +38 -0
  228. package/lib/cjs/utils/createContext.js.map +1 -0
  229. package/lib/{utils → cjs/utils}/createHandlerMetadata.d.ts +0 -0
  230. package/lib/cjs/utils/createHandlerMetadata.js +49 -0
  231. package/lib/cjs/utils/createHandlerMetadata.js.map +1 -0
  232. package/lib/cjs/utils/createHttpServer.d.ts +4 -0
  233. package/lib/cjs/utils/createHttpServer.js +34 -0
  234. package/lib/cjs/utils/createHttpServer.js.map +1 -0
  235. package/lib/cjs/utils/createHttpsServer.d.ts +4 -0
  236. package/lib/cjs/utils/createHttpsServer.js +34 -0
  237. package/lib/cjs/utils/createHttpsServer.js.map +1 -0
  238. package/lib/{utils → cjs/utils}/createInjector.d.ts +0 -0
  239. package/lib/cjs/utils/createInjector.js +38 -0
  240. package/lib/cjs/utils/createInjector.js.map +1 -0
  241. package/lib/{utils → cjs/utils}/getConfiguration.d.ts +0 -0
  242. package/lib/cjs/utils/getConfiguration.js +42 -0
  243. package/lib/cjs/utils/getConfiguration.js.map +1 -0
  244. package/lib/{utils → cjs/utils}/getStaticsOptions.d.ts +0 -0
  245. package/lib/cjs/utils/getStaticsOptions.js +21 -0
  246. package/lib/cjs/utils/getStaticsOptions.js.map +1 -0
  247. package/lib/{utils → cjs/utils}/index.d.ts +0 -0
  248. package/lib/cjs/utils/index.js +12 -0
  249. package/lib/cjs/utils/index.js.map +1 -0
  250. package/lib/cjs/utils/listenServer.d.ts +7 -0
  251. package/lib/cjs/utils/listenServer.js +21 -0
  252. package/lib/cjs/utils/listenServer.js.map +1 -0
  253. package/lib/{utils → cjs/utils}/loadInjector.d.ts +0 -0
  254. package/lib/cjs/utils/loadInjector.js +14 -0
  255. package/lib/cjs/utils/loadInjector.js.map +1 -0
  256. package/lib/{utils → cjs/utils}/mapReturnedResponse.d.ts +0 -0
  257. package/lib/cjs/utils/mapReturnedResponse.js +15 -0
  258. package/lib/cjs/utils/mapReturnedResponse.js.map +1 -0
  259. package/lib/{utils → cjs/utils}/printRoutes.d.ts +0 -0
  260. package/lib/cjs/utils/printRoutes.js +36 -0
  261. package/lib/cjs/utils/printRoutes.js.map +1 -0
  262. package/lib/{utils → cjs/utils}/setResponseHeaders.d.ts +0 -0
  263. package/lib/cjs/utils/setResponseHeaders.js +35 -0
  264. package/lib/cjs/utils/setResponseHeaders.js.map +1 -0
  265. package/lib/{utils → cjs/utils}/useCtxHandler.d.ts +0 -0
  266. package/lib/cjs/utils/useCtxHandler.js +15 -0
  267. package/lib/cjs/utils/useCtxHandler.js.map +1 -0
  268. package/lib/esm/PlatformModule.js +7 -0
  269. package/lib/esm/PlatformModule.js.map +1 -0
  270. package/lib/esm/builder/PlatformBuilder.js +271 -0
  271. package/lib/esm/builder/PlatformBuilder.js.map +1 -0
  272. package/lib/esm/builder/PlatformControllerBuilder.js +79 -0
  273. package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -0
  274. package/lib/esm/config/index.js +4 -0
  275. package/lib/esm/config/index.js.map +1 -0
  276. package/lib/esm/config/interfaces/ConverterSettings.js +2 -0
  277. package/lib/esm/config/interfaces/ConverterSettings.js.map +1 -0
  278. package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js +2 -0
  279. package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js.map +1 -0
  280. package/lib/esm/config/interfaces/PlatformLoggerSettings.js +2 -0
  281. package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -0
  282. package/lib/esm/config/interfaces/PlatformMulterSettings.js +2 -0
  283. package/lib/esm/config/interfaces/PlatformMulterSettings.js.map +1 -0
  284. package/lib/esm/config/interfaces/PlatformStaticsSettings.js +2 -0
  285. package/lib/esm/config/interfaces/PlatformStaticsSettings.js.map +1 -0
  286. package/lib/esm/config/interfaces/index.js +5 -0
  287. package/lib/esm/config/interfaces/index.js.map +1 -0
  288. package/lib/esm/config/services/PlatformConfiguration.js +175 -0
  289. package/lib/esm/config/services/PlatformConfiguration.js.map +1 -0
  290. package/lib/esm/constants/routerOptions.js +2 -0
  291. package/lib/esm/constants/routerOptions.js.map +1 -0
  292. package/lib/esm/decorators/httpServer.js +28 -0
  293. package/lib/esm/decorators/httpServer.js.map +1 -0
  294. package/lib/esm/decorators/httpsServer.js +28 -0
  295. package/lib/esm/decorators/httpsServer.js.map +1 -0
  296. package/lib/esm/decorators/index.js +20 -0
  297. package/lib/esm/decorators/index.js.map +1 -0
  298. package/lib/esm/decorators/method/acceptMime.js +24 -0
  299. package/lib/esm/decorators/method/acceptMime.js.map +1 -0
  300. package/lib/esm/decorators/method/endpointFn.js +11 -0
  301. package/lib/esm/decorators/method/endpointFn.js.map +1 -0
  302. package/lib/esm/decorators/method/location.js +2 -0
  303. package/lib/esm/decorators/method/location.js.map +1 -0
  304. package/lib/esm/decorators/method/redirect.js +2 -0
  305. package/lib/esm/decorators/method/redirect.js.map +1 -0
  306. package/lib/esm/decorators/method/route.js +2 -0
  307. package/lib/esm/decorators/method/route.js.map +1 -0
  308. package/lib/esm/decorators/method/view.js +30 -0
  309. package/lib/esm/decorators/method/view.js.map +1 -0
  310. package/lib/esm/decorators/multer/index.js +4 -0
  311. package/lib/esm/decorators/multer/index.js.map +1 -0
  312. package/lib/esm/decorators/multer/multerFileSize.js +31 -0
  313. package/lib/esm/decorators/multer/multerFileSize.js.map +1 -0
  314. package/lib/esm/decorators/multer/multerOptions.js +48 -0
  315. package/lib/esm/decorators/multer/multerOptions.js.map +1 -0
  316. package/lib/esm/decorators/multer/multipartFile.js +74 -0
  317. package/lib/esm/decorators/multer/multipartFile.js.map +1 -0
  318. package/lib/esm/decorators/params/endpointInfo.js +17 -0
  319. package/lib/esm/decorators/params/endpointInfo.js.map +1 -0
  320. package/lib/esm/decorators/params/error.js +16 -0
  321. package/lib/esm/decorators/params/error.js.map +1 -0
  322. package/lib/esm/decorators/params/next.js +17 -0
  323. package/lib/esm/decorators/params/next.js.map +1 -0
  324. package/lib/esm/decorators/params/request.js +34 -0
  325. package/lib/esm/decorators/params/request.js.map +1 -0
  326. package/lib/esm/decorators/params/response.js +28 -0
  327. package/lib/esm/decorators/params/response.js.map +1 -0
  328. package/lib/esm/decorators/params/responseData.js +17 -0
  329. package/lib/esm/decorators/params/responseData.js.map +1 -0
  330. package/lib/esm/domain/AnyToPromiseWithCtx.js +31 -0
  331. package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -0
  332. package/lib/esm/domain/ControllerProvider.js +47 -0
  333. package/lib/esm/domain/ControllerProvider.js.map +1 -0
  334. package/lib/esm/domain/EndpointMetadata.js +108 -0
  335. package/lib/esm/domain/EndpointMetadata.js.map +1 -0
  336. package/lib/esm/domain/HandlerMetadata.js +53 -0
  337. package/lib/esm/domain/HandlerMetadata.js.map +1 -0
  338. package/lib/esm/domain/PlatformContext.js +81 -0
  339. package/lib/esm/domain/PlatformContext.js.map +1 -0
  340. package/lib/esm/domain/PlatformRouteDetails.js +20 -0
  341. package/lib/esm/domain/PlatformRouteDetails.js.map +1 -0
  342. package/lib/esm/domain/PropertyMetadata.js +25 -0
  343. package/lib/esm/domain/PropertyMetadata.js.map +1 -0
  344. package/lib/esm/domain/index.js +8 -0
  345. package/lib/esm/domain/index.js.map +1 -0
  346. package/lib/esm/index.js +31 -0
  347. package/lib/esm/index.js.map +1 -0
  348. package/lib/esm/interfaces/AfterInit.js +2 -0
  349. package/lib/esm/interfaces/AfterInit.js.map +1 -0
  350. package/lib/esm/interfaces/AfterListen.js +2 -0
  351. package/lib/esm/interfaces/AfterListen.js.map +1 -0
  352. package/lib/esm/interfaces/AfterRoutesInit.js +2 -0
  353. package/lib/esm/interfaces/AfterRoutesInit.js.map +1 -0
  354. package/lib/esm/interfaces/BeforeInit.js +2 -0
  355. package/lib/esm/interfaces/BeforeInit.js.map +1 -0
  356. package/lib/esm/interfaces/BeforeListen.js +2 -0
  357. package/lib/esm/interfaces/BeforeListen.js.map +1 -0
  358. package/lib/esm/interfaces/BeforeRoutesInit.js +2 -0
  359. package/lib/esm/interfaces/BeforeRoutesInit.js.map +1 -0
  360. package/lib/esm/interfaces/HandlerType.js +14 -0
  361. package/lib/esm/interfaces/HandlerType.js.map +1 -0
  362. package/lib/esm/interfaces/IncomingEvent.js +2 -0
  363. package/lib/esm/interfaces/IncomingEvent.js.map +1 -0
  364. package/lib/esm/interfaces/OnReady.js +2 -0
  365. package/lib/esm/interfaces/OnReady.js.map +1 -0
  366. package/lib/esm/interfaces/OnRequest.js +2 -0
  367. package/lib/esm/interfaces/OnRequest.js.map +1 -0
  368. package/lib/esm/interfaces/OnResponse.js +2 -0
  369. package/lib/esm/interfaces/OnResponse.js.map +1 -0
  370. package/lib/esm/interfaces/OnRoutesInit.js +2 -0
  371. package/lib/esm/interfaces/OnRoutesInit.js.map +1 -0
  372. package/lib/esm/interfaces/PathType.js +2 -0
  373. package/lib/esm/interfaces/PathType.js.map +1 -0
  374. package/lib/esm/interfaces/PlatformAdapter.js +2 -0
  375. package/lib/esm/interfaces/PlatformAdapter.js.map +1 -0
  376. package/lib/esm/interfaces/PlatformRouteOptions.js +2 -0
  377. package/lib/esm/interfaces/PlatformRouteOptions.js.map +1 -0
  378. package/lib/esm/interfaces/ResponseErrorObject.js +2 -0
  379. package/lib/esm/interfaces/ResponseErrorObject.js.map +1 -0
  380. package/lib/esm/interfaces/Route.js +2 -0
  381. package/lib/esm/interfaces/Route.js.map +1 -0
  382. package/lib/esm/interfaces/index.js +18 -0
  383. package/lib/esm/interfaces/index.js.map +1 -0
  384. package/lib/esm/middlewares/AcceptMimesMiddleware.js +24 -0
  385. package/lib/esm/middlewares/AcceptMimesMiddleware.js.map +1 -0
  386. package/lib/esm/middlewares/GlobalAcceptMimesMiddleware.js +23 -0
  387. package/lib/esm/middlewares/GlobalAcceptMimesMiddleware.js.map +1 -0
  388. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +34 -0
  389. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
  390. package/lib/esm/middlewares/PlatformMulterMiddleware.js +52 -0
  391. package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -0
  392. package/lib/esm/middlewares/__mock__/FakeCtrl.js +9 -0
  393. package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +1 -0
  394. package/lib/esm/middlewares/bindEndpointMiddleware.js +9 -0
  395. package/lib/esm/middlewares/bindEndpointMiddleware.js.map +1 -0
  396. package/lib/esm/middlewares/index.js +6 -0
  397. package/lib/esm/middlewares/index.js.map +1 -0
  398. package/lib/esm/services/FakeRawDriver.js +22 -0
  399. package/lib/esm/services/FakeRawDriver.js.map +1 -0
  400. package/lib/esm/services/Platform.js +104 -0
  401. package/lib/esm/services/Platform.js.map +1 -0
  402. package/lib/esm/services/PlatformApplication.js +31 -0
  403. package/lib/esm/services/PlatformApplication.js.map +1 -0
  404. package/lib/esm/services/PlatformHandler.js +232 -0
  405. package/lib/esm/services/PlatformHandler.js.map +1 -0
  406. package/lib/esm/services/PlatformMiddlewaresChain.js +31 -0
  407. package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -0
  408. package/lib/esm/services/PlatformRequest.js +135 -0
  409. package/lib/esm/services/PlatformRequest.js.map +1 -0
  410. package/lib/esm/services/PlatformResponse.js +268 -0
  411. package/lib/esm/services/PlatformResponse.js.map +1 -0
  412. package/lib/esm/services/PlatformRouter.js +123 -0
  413. package/lib/esm/services/PlatformRouter.js.map +1 -0
  414. package/lib/esm/services/PlatformTest.js +163 -0
  415. package/lib/esm/services/PlatformTest.js.map +1 -0
  416. package/lib/esm/services/index.js +9 -0
  417. package/lib/esm/services/index.js.map +1 -0
  418. package/lib/esm/utils/createContext.js +34 -0
  419. package/lib/esm/utils/createContext.js.map +1 -0
  420. package/lib/esm/utils/createHandlerMetadata.js +45 -0
  421. package/lib/esm/utils/createHandlerMetadata.js.map +1 -0
  422. package/lib/esm/utils/createHttpServer.js +29 -0
  423. package/lib/esm/utils/createHttpServer.js.map +1 -0
  424. package/lib/esm/utils/createHttpsServer.js +29 -0
  425. package/lib/esm/utils/createHttpsServer.js.map +1 -0
  426. package/lib/esm/utils/createInjector.js +34 -0
  427. package/lib/esm/utils/createInjector.js.map +1 -0
  428. package/lib/esm/utils/getConfiguration.js +38 -0
  429. package/lib/esm/utils/getConfiguration.js.map +1 -0
  430. package/lib/esm/utils/getStaticsOptions.js +17 -0
  431. package/lib/esm/utils/getStaticsOptions.js.map +1 -0
  432. package/lib/esm/utils/index.js +9 -0
  433. package/lib/esm/utils/index.js.map +1 -0
  434. package/lib/esm/utils/listenServer.js +17 -0
  435. package/lib/esm/utils/listenServer.js.map +1 -0
  436. package/lib/esm/utils/loadInjector.js +10 -0
  437. package/lib/esm/utils/loadInjector.js.map +1 -0
  438. package/lib/esm/utils/mapReturnedResponse.js +11 -0
  439. package/lib/esm/utils/mapReturnedResponse.js.map +1 -0
  440. package/lib/esm/utils/printRoutes.js +32 -0
  441. package/lib/esm/utils/printRoutes.js.map +1 -0
  442. package/lib/esm/utils/setResponseHeaders.js +31 -0
  443. package/lib/esm/utils/setResponseHeaders.js.map +1 -0
  444. package/lib/esm/utils/useCtxHandler.js +11 -0
  445. package/lib/esm/utils/useCtxHandler.js.map +1 -0
  446. package/lib/types/PlatformModule.d.ts +6 -0
  447. package/lib/types/builder/PlatformBuilder.d.ts +104 -0
  448. package/lib/types/builder/PlatformControllerBuilder.d.ts +17 -0
  449. package/lib/types/config/index.d.ts +3 -0
  450. package/lib/types/config/interfaces/ConverterSettings.d.ts +6 -0
  451. package/lib/types/config/interfaces/EndpointDirectoriesSettings.d.ts +3 -0
  452. package/lib/types/config/interfaces/PlatformLoggerSettings.d.ts +44 -0
  453. package/lib/types/config/interfaces/PlatformMulterSettings.d.ts +138 -0
  454. package/lib/types/config/interfaces/PlatformStaticsSettings.d.ts +17 -0
  455. package/lib/types/config/interfaces/index.d.ts +97 -0
  456. package/lib/types/config/services/PlatformConfiguration.d.ts +81 -0
  457. package/lib/types/constants/routerOptions.d.ts +1 -0
  458. package/lib/types/decorators/httpServer.d.ts +28 -0
  459. package/lib/types/decorators/httpsServer.d.ts +28 -0
  460. package/lib/types/decorators/index.d.ts +16 -0
  461. package/lib/types/decorators/method/acceptMime.d.ts +19 -0
  462. package/lib/types/decorators/method/endpointFn.d.ts +9 -0
  463. package/lib/types/decorators/method/location.d.ts +1 -0
  464. package/lib/types/decorators/method/redirect.d.ts +1 -0
  465. package/lib/types/decorators/method/route.d.ts +1 -0
  466. package/lib/types/decorators/method/view.d.ts +25 -0
  467. package/lib/types/decorators/multer/index.d.ts +3 -0
  468. package/lib/types/decorators/multer/multerFileSize.d.ts +27 -0
  469. package/lib/types/decorators/multer/multerOptions.d.ts +41 -0
  470. package/lib/types/decorators/multer/multipartFile.d.ts +47 -0
  471. package/lib/types/decorators/params/endpointInfo.d.ts +13 -0
  472. package/lib/types/decorators/params/error.d.ts +7 -0
  473. package/lib/types/decorators/params/next.d.ts +22 -0
  474. package/lib/types/decorators/params/request.d.ts +46 -0
  475. package/lib/types/decorators/params/response.d.ts +40 -0
  476. package/lib/types/decorators/params/responseData.d.ts +9 -0
  477. package/lib/types/domain/AnyToPromiseWithCtx.d.ts +18 -0
  478. package/lib/types/domain/ControllerProvider.d.ts +24 -0
  479. package/lib/types/domain/EndpointMetadata.d.ts +76 -0
  480. package/lib/types/domain/HandlerMetadata.d.ts +32 -0
  481. package/lib/types/domain/PlatformContext.d.ts +65 -0
  482. package/lib/types/domain/PlatformRouteDetails.d.ts +23 -0
  483. package/lib/types/domain/PropertyMetadata.d.ts +17 -0
  484. package/lib/types/domain/index.d.ts +7 -0
  485. package/lib/types/index.d.ts +22 -0
  486. package/lib/types/interfaces/AfterInit.d.ts +3 -0
  487. package/lib/types/interfaces/AfterListen.d.ts +3 -0
  488. package/lib/types/interfaces/AfterRoutesInit.d.ts +3 -0
  489. package/lib/types/interfaces/BeforeInit.d.ts +3 -0
  490. package/lib/types/interfaces/BeforeListen.d.ts +3 -0
  491. package/lib/types/interfaces/BeforeRoutesInit.d.ts +3 -0
  492. package/lib/types/interfaces/HandlerType.d.ts +12 -0
  493. package/lib/types/interfaces/IncomingEvent.d.ts +6 -0
  494. package/lib/types/interfaces/OnReady.d.ts +3 -0
  495. package/lib/types/interfaces/OnRequest.d.ts +4 -0
  496. package/lib/types/interfaces/OnResponse.d.ts +4 -0
  497. package/lib/types/interfaces/OnRoutesInit.d.ts +3 -0
  498. package/lib/types/interfaces/PathType.d.ts +1 -0
  499. package/lib/types/interfaces/PlatformAdapter.d.ts +19 -0
  500. package/lib/types/interfaces/PlatformRouteOptions.d.ts +16 -0
  501. package/lib/types/interfaces/ResponseErrorObject.d.ts +8 -0
  502. package/lib/types/interfaces/Route.d.ts +10 -0
  503. package/lib/types/interfaces/index.d.ts +17 -0
  504. package/lib/types/middlewares/AcceptMimesMiddleware.d.ts +10 -0
  505. package/lib/types/middlewares/GlobalAcceptMimesMiddleware.d.ts +9 -0
  506. package/lib/types/middlewares/PlatformAcceptMimesMiddleware.d.ts +10 -0
  507. package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +19 -0
  508. package/lib/types/middlewares/__mock__/FakeCtrl.d.ts +2 -0
  509. package/lib/types/middlewares/bindEndpointMiddleware.d.ts +5 -0
  510. package/lib/types/middlewares/index.d.ts +5 -0
  511. package/lib/types/services/FakeRawDriver.d.ts +15 -0
  512. package/lib/types/services/Platform.d.ts +37 -0
  513. package/lib/types/services/PlatformApplication.d.ts +21 -0
  514. package/lib/types/services/PlatformHandler.d.ts +80 -0
  515. package/lib/types/services/PlatformMiddlewaresChain.d.ts +6 -0
  516. package/lib/types/services/PlatformRequest.d.ts +112 -0
  517. package/lib/types/services/PlatformResponse.d.ts +161 -0
  518. package/lib/types/services/PlatformRouter.d.ts +48 -0
  519. package/lib/types/services/PlatformTest.d.ts +58 -0
  520. package/lib/types/services/index.d.ts +8 -0
  521. package/lib/types/utils/createContext.d.ts +9 -0
  522. package/lib/types/utils/createHandlerMetadata.d.ts +8 -0
  523. package/lib/types/utils/createHttpServer.d.ts +4 -0
  524. package/lib/types/utils/createHttpsServer.d.ts +4 -0
  525. package/lib/types/utils/createInjector.d.ts +7 -0
  526. package/lib/types/utils/getConfiguration.d.ts +2 -0
  527. package/lib/types/utils/getStaticsOptions.d.ts +5 -0
  528. package/lib/types/utils/index.d.ts +8 -0
  529. package/lib/types/utils/listenServer.d.ts +7 -0
  530. package/lib/types/utils/loadInjector.d.ts +6 -0
  531. package/lib/types/utils/mapReturnedResponse.d.ts +4 -0
  532. package/lib/types/utils/printRoutes.d.ts +2 -0
  533. package/lib/types/utils/setResponseHeaders.d.ts +5 -0
  534. package/lib/types/utils/useCtxHandler.d.ts +13 -0
  535. package/package.json +26 -23
  536. package/tsconfig.compile.esm.json +23 -0
  537. package/lib/index.js +0 -3634
  538. package/lib/index.js.map +0 -1
  539. package/lib/index.modern.js +0 -3448
  540. package/lib/index.modern.js.map +0 -1
  541. package/lib/utils/createHttpServer.d.ts +0 -3
  542. package/lib/utils/createHttpsServer.d.ts +0 -3
  543. package/lib/utils/listenServer.d.ts +0 -10
@@ -0,0 +1,7 @@
1
+ /// <reference types="node" />
2
+ import type Http from "http";
3
+ import type Https from "https";
4
+ import type Http2 from "http2";
5
+ import { InjectorService } from "@tsed/di";
6
+ import { getHostInfoFromPort } from "@tsed/core";
7
+ export declare function listenServer(injector: InjectorService, server: Http.Server | Https.Server | Http2.Http2Server, hostInfo: ReturnType<typeof getHostInfoFromPort>): Promise<ReturnType<typeof getHostInfoFromPort>>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listenServer = void 0;
4
+ function listenServer(injector, server, hostInfo) {
5
+ const { protocol, address, port } = hostInfo;
6
+ const url = `${protocol}://${address}:${port}`;
7
+ injector.logger.debug(`Start server on ${url}`);
8
+ const promise = new Promise((resolve, reject) => {
9
+ server.on("listening", resolve);
10
+ server.on("error", reject);
11
+ }).then(() => {
12
+ const port = server.address().port;
13
+ const info = { ...hostInfo, port };
14
+ injector.logger.info(`Listen server on ${info.toString()}`);
15
+ return info;
16
+ });
17
+ server.listen(port, address);
18
+ return promise;
19
+ }
20
+ exports.listenServer = listenServer;
21
+ //# sourceMappingURL=listenServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listenServer.js","sourceRoot":"","sources":["../../../src/utils/listenServer.ts"],"names":[],"mappings":";;;AAMA,SAAgB,YAAY,CAC1B,QAAyB,EACzB,MAAsD,EACtD,QAAgD;IAEhD,MAAM,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAC,GAAG,QAAQ,CAAC;IAC3C,MAAM,GAAG,GAAG,GAAG,QAAQ,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;IAC/C,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC;IAEhD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9C,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAChC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QACX,MAAM,IAAI,GAAI,MAAM,CAAC,OAAO,EAAU,CAAC,IAAI,CAAC;QAC5C,MAAM,IAAI,GAAG,EAAC,GAAG,QAAQ,EAAE,IAAI,EAAC,CAAC;QAEjC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAc,CAAC,CAAC;IAEpC,OAAO,OAAO,CAAC;AACjB,CAAC;AAxBD,oCAwBC","sourcesContent":["import type Http from \"http\";\nimport type Https from \"https\";\nimport type Http2 from \"http2\";\nimport {InjectorService} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\n\nexport function listenServer(\n injector: InjectorService,\n server: Http.Server | Https.Server | Http2.Http2Server,\n hostInfo: ReturnType<typeof getHostInfoFromPort>\n): Promise<ReturnType<typeof getHostInfoFromPort>> {\n const {protocol, address, port} = hostInfo;\n const url = `${protocol}://${address}:${port}`;\n injector.logger.debug(`Start server on ${url}`);\n\n const promise = new Promise((resolve, reject) => {\n server.on(\"listening\", resolve);\n server.on(\"error\", reject);\n }).then(() => {\n const port = (server.address() as any).port;\n const info = {...hostInfo, port};\n\n injector.logger.info(`Listen server on ${info.toString()}`);\n\n return info;\n });\n\n server.listen(port, address as any);\n\n return promise;\n}\n"]}
File without changes
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadInjector = void 0;
4
+ const di_1 = require("@tsed/di");
5
+ /**
6
+ * @ignore
7
+ * @deprecated User injector.load(container, module) instead
8
+ */
9
+ async function loadInjector(injector, container = (0, di_1.createContainer)()) {
10
+ injector.bootstrap(container);
11
+ return injector.load(container);
12
+ }
13
+ exports.loadInjector = loadInjector;
14
+ //# sourceMappingURL=loadInjector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadInjector.js","sourceRoot":"","sources":["../../../src/utils/loadInjector.ts"],"names":[],"mappings":";;;AAAA,iCAAsF;AAEtF;;;GAGG;AACI,KAAK,UAAU,YAAY,CAAC,QAAyB,EAAE,YAAuB,IAAA,oBAAe,GAAE;IACpG,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC9B,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAHD,oCAGC","sourcesContent":["import {Container, createContainer, InjectorService, LocalsContainer} from \"@tsed/di\";\n\n/**\n * @ignore\n * @deprecated User injector.load(container, module) instead\n */\nexport async function loadInjector(injector: InjectorService, container: Container = createContainer()): Promise<LocalsContainer<any>> {\n injector.bootstrap(container);\n return injector.load(container);\n}\n"]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapReturnedResponse = void 0;
4
+ /**
5
+ * @ignore
6
+ */
7
+ function mapReturnedResponse({ use, collection, ...options }) {
8
+ return {
9
+ ...options,
10
+ type: options.type || use,
11
+ collectionType: options.collectionType || collection
12
+ };
13
+ }
14
+ exports.mapReturnedResponse = mapReturnedResponse;
15
+ //# sourceMappingURL=mapReturnedResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapReturnedResponse.js","sourceRoot":"","sources":["../../../src/utils/mapReturnedResponse.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,mBAAmB,CAAC,EAAC,GAAG,EAAE,UAAU,EAAE,GAAG,OAAO,EAAM;IACpE,OAAO;QACL,GAAG,OAAO;QACV,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,GAAG;QACzB,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,UAAU;KACrD,CAAC;AACJ,CAAC;AAND,kDAMC","sourcesContent":["/**\n * @ignore\n */\nexport function mapReturnedResponse({use, collection, ...options}: any): any {\n return {\n ...options,\n type: options.type || use,\n collectionType: options.collectionType || collection\n };\n}\n"]}
File without changes
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.printRoutes = void 0;
4
+ const logger_1 = require("@tsed/logger");
5
+ function printRoutes(routes) {
6
+ const mapColor = {
7
+ GET: "green",
8
+ POST: "yellow",
9
+ PUT: "blue",
10
+ DELETE: "red",
11
+ PATCH: "magenta",
12
+ ALL: "cyan"
13
+ };
14
+ const list = routes.map((route) => {
15
+ const obj = route.toJSON();
16
+ const method = obj.method.toUpperCase();
17
+ obj.method = {
18
+ length: method.length,
19
+ toString: () => {
20
+ return (0, logger_1.colorize)(method, mapColor[method]);
21
+ }
22
+ };
23
+ return obj;
24
+ });
25
+ const str = logger_1.$log.drawTable(list, {
26
+ padding: 1,
27
+ header: {
28
+ method: "Method",
29
+ url: "Endpoint",
30
+ name: "Class method"
31
+ }
32
+ });
33
+ return "\n" + str.trim();
34
+ }
35
+ exports.printRoutes = printRoutes;
36
+ //# sourceMappingURL=printRoutes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"printRoutes.js","sourceRoot":"","sources":["../../../src/utils/printRoutes.ts"],"names":[],"mappings":";;;AAAA,yCAA4C;AAG5C,SAAgB,WAAW,CAAC,MAA8B;IACxD,MAAM,QAAQ,GAA4B;QACxC,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,MAAM;QACX,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,MAAM;KACZ,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAChC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAExC,GAAG,CAAC,MAAM,GAAG;YACX,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,GAAG,EAAE;gBACb,OAAO,IAAA,iBAAQ,EAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YAC5C,CAAC;SACK,CAAC;QAET,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,aAAI,CAAC,SAAS,CAAC,IAAI,EAAE;QAC/B,OAAO,EAAE,CAAC;QACV,MAAM,EAAE;YACN,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,UAAU;YACf,IAAI,EAAE,cAAc;SACrB;KACF,CAAC,CAAC;IAEH,OAAO,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC;AAlCD,kCAkCC","sourcesContent":["import {$log, colorize} from \"@tsed/logger\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\n\nexport function printRoutes(routes: PlatformRouteDetails[]) {\n const mapColor: {[key: string]: string} = {\n GET: \"green\",\n POST: \"yellow\",\n PUT: \"blue\",\n DELETE: \"red\",\n PATCH: \"magenta\",\n ALL: \"cyan\"\n };\n\n const list = routes.map((route) => {\n const obj = route.toJSON();\n const method = obj.method.toUpperCase();\n\n obj.method = {\n length: method.length,\n toString: () => {\n return colorize(method, mapColor[method]);\n }\n } as any;\n\n return obj;\n });\n\n const str = $log.drawTable(list, {\n padding: 1,\n header: {\n method: \"Method\",\n url: \"Endpoint\",\n name: \"Class method\"\n }\n });\n\n return \"\\n\" + str.trim();\n}\n"]}
File without changes
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setResponseHeaders = void 0;
4
+ function mergeHeaders(specHeaders, headers) {
5
+ return Object.entries(specHeaders).reduce((headers, [key, item]) => {
6
+ key = key.toLowerCase();
7
+ return {
8
+ ...headers,
9
+ [key]: headers[key] === undefined ? String(item.example) : headers[key]
10
+ };
11
+ }, headers);
12
+ }
13
+ /**
14
+ * @ignore
15
+ */
16
+ function setResponseHeaders(ctx) {
17
+ const { response, endpoint } = ctx;
18
+ const { operation } = endpoint;
19
+ if (response.isDone()) {
20
+ return;
21
+ }
22
+ if (!response.hasStatus()) {
23
+ // apply status only if the isn't already modified
24
+ response.status(operation.getStatus());
25
+ }
26
+ const statusCode = response.statusCode;
27
+ const headers = operation.getHeadersOf(response.statusCode);
28
+ const mergedHeaders = mergeHeaders(headers, response.getHeaders());
29
+ response.setHeaders(mergedHeaders);
30
+ if (operation.isRedirection(statusCode)) {
31
+ response.redirect(statusCode, String(mergedHeaders["location"]));
32
+ }
33
+ }
34
+ exports.setResponseHeaders = setResponseHeaders;
35
+ //# sourceMappingURL=setResponseHeaders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setResponseHeaders.js","sourceRoot":"","sources":["../../../src/utils/setResponseHeaders.ts"],"names":[],"mappings":";;;AAIA,SAAS,YAAY,CAAC,WAA2D,EAAE,OAAoC;IACrH,OAAO,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;QACjE,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACxB,OAAO;YACL,GAAG,OAAO;YACV,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;SACxE,CAAC;IACJ,CAAC,EAAE,OAAO,CAAC,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,GAAoB;IACrD,MAAM,EAAC,QAAQ,EAAE,QAAQ,EAAC,GAAG,GAAG,CAAC;IACjC,MAAM,EAAC,SAAS,EAAC,GAAG,QAAQ,CAAC;IAE7B,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE;QACrB,OAAO;KACR;IAED,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;QACzB,kDAAkD;QAClD,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;KACxC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;IACvC,MAAM,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAEnE,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAEnC,IAAI,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE;QACvC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;KAClE;AACH,CAAC;AAtBD,gDAsBC","sourcesContent":["import {JsonHeader} from \"@tsed/schema\";\nimport {PlatformContext} from \"../domain/PlatformContext\";\nimport {HeaderValue} from \"../services/PlatformResponse\";\n\nfunction mergeHeaders(specHeaders: Record<string, JsonHeader & {example: string}>, headers: Record<string, HeaderValue>) {\n return Object.entries(specHeaders).reduce((headers, [key, item]) => {\n key = key.toLowerCase();\n return {\n ...headers,\n [key]: headers[key] === undefined ? String(item.example) : headers[key]\n };\n }, headers);\n}\n\n/**\n * @ignore\n */\nexport function setResponseHeaders(ctx: PlatformContext) {\n const {response, endpoint} = ctx;\n const {operation} = endpoint;\n\n if (response.isDone()) {\n return;\n }\n\n if (!response.hasStatus()) {\n // apply status only if the isn't already modified\n response.status(operation.getStatus());\n }\n\n const statusCode = response.statusCode;\n const headers = operation.getHeadersOf(response.statusCode);\n const mergedHeaders = mergeHeaders(headers, response.getHeaders());\n\n response.setHeaders(mergedHeaders);\n\n if (operation.isRedirection(statusCode)) {\n response.redirect(statusCode, String(mergedHeaders[\"location\"]));\n }\n}\n"]}
File without changes
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCtxHandler = void 0;
4
+ const HandlerType_1 = require("../interfaces/HandlerType");
5
+ /**
6
+ * Create Ts.ED context handler
7
+ * @param fn
8
+ * @ignore
9
+ */
10
+ function useCtxHandler(fn) {
11
+ fn.type = HandlerType_1.HandlerType.CTX_FN;
12
+ return fn;
13
+ }
14
+ exports.useCtxHandler = useCtxHandler;
15
+ //# sourceMappingURL=useCtxHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCtxHandler.js","sourceRoot":"","sources":["../../../src/utils/useCtxHandler.ts"],"names":[],"mappings":";;;AACA,2DAAsD;AAItD;;;;GAIG;AACH,SAAgB,aAAa,CAAC,EAA6C;IACzE,EAAE,CAAC,IAAI,GAAG,yBAAW,CAAC,MAAM,CAAC;IAE7B,OAAO,EAAE,CAAC;AACZ,CAAC;AAJD,sCAIC","sourcesContent":["import {PlatformContext} from \"../domain/PlatformContext\";\nimport {HandlerType} from \"../interfaces/HandlerType\";\n\nexport type PlatformCtxHandler = ($ctx: PlatformContext) => any | Promise<any>;\n\n/**\n * Create Ts.ED context handler\n * @param fn\n * @ignore\n */\nexport function useCtxHandler(fn: PlatformCtxHandler & {type?: HandlerType}) {\n fn.type = HandlerType.CTX_FN;\n\n return fn;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @ignore
3
+ * @deprecated Will be removed in v7
4
+ */
5
+ export class PlatformModule {
6
+ }
7
+ //# sourceMappingURL=PlatformModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformModule.js","sourceRoot":"","sources":["../../src/PlatformModule.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,cAAc;CAAG","sourcesContent":["/**\n * @ignore\n * @deprecated Will be removed in v7\n */\nexport class PlatformModule {}\n"]}
@@ -0,0 +1,271 @@
1
+ var _PlatformBuilder_injector, _PlatformBuilder_rootModule, _PlatformBuilder_promise, _PlatformBuilder_adapter, _PlatformBuilder_servers;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
+ import { nameOf } from "@tsed/core";
4
+ import { colors, createContainer, ProviderScope, setLoggerLevel } from "@tsed/di";
5
+ import { importProviders } from "@tsed/components-scan";
6
+ import { getMiddlewaresForHook } from "@tsed/platform-middlewares";
7
+ import { GlobalAcceptMimesMiddleware } from "../middlewares";
8
+ import { Platform } from "../services/Platform";
9
+ import { PlatformApplication } from "../services/PlatformApplication";
10
+ import { createHttpServer, createHttpsServer, createInjector, printRoutes } from "../utils";
11
+ import { getStaticsOptions } from "../utils/getStaticsOptions";
12
+ import { getConfiguration } from "../utils/getConfiguration";
13
+ /**
14
+ * @platform
15
+ */
16
+ export class PlatformBuilder {
17
+ constructor(adapter, module, settings) {
18
+ this.name = "";
19
+ this.startedAt = new Date();
20
+ this.current = new Date();
21
+ _PlatformBuilder_injector.set(this, void 0);
22
+ _PlatformBuilder_rootModule.set(this, void 0);
23
+ _PlatformBuilder_promise.set(this, void 0);
24
+ _PlatformBuilder_adapter.set(this, void 0);
25
+ _PlatformBuilder_servers.set(this, void 0);
26
+ __classPrivateFieldSet(this, _PlatformBuilder_rootModule, module, "f");
27
+ const adapterKlass = adapter || PlatformBuilder.adapter;
28
+ const name = nameOf(adapterKlass).replace("Platform", "").toLowerCase();
29
+ const configuration = getConfiguration(settings, module);
30
+ configuration.PLATFORM_NAME = name;
31
+ this.name = name;
32
+ __classPrivateFieldSet(this, _PlatformBuilder_adapter, new adapterKlass(this), "f");
33
+ __classPrivateFieldSet(this, _PlatformBuilder_injector, createInjector({
34
+ settings: configuration,
35
+ providers: __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").providers
36
+ }), "f");
37
+ this.createHttpServers();
38
+ __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").onInit && __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").onInit();
39
+ this.log("Injector created...");
40
+ }
41
+ get injector() {
42
+ return __classPrivateFieldGet(this, _PlatformBuilder_injector, "f");
43
+ }
44
+ get rootModule() {
45
+ return __classPrivateFieldGet(this, _PlatformBuilder_injector, "f").get(__classPrivateFieldGet(this, _PlatformBuilder_rootModule, "f"));
46
+ }
47
+ get app() {
48
+ return this.injector.get(PlatformApplication);
49
+ }
50
+ get platform() {
51
+ return this.injector.get(Platform);
52
+ }
53
+ /**
54
+ * Return the settings configured by the decorator @@Configuration@@.
55
+ *
56
+ * ```typescript
57
+ * @Configuration({
58
+ * rootDir: Path.resolve(__dirname),
59
+ * port: 8000,
60
+ * httpsPort: 8080,
61
+ * mount: {
62
+ * "/rest": "${rootDir}/controllers/**\/*.js"
63
+ * }
64
+ * })
65
+ * export class Server {
66
+ * $onInit(){
67
+ * console.log(this.settings); // {rootDir, port, httpsPort,...}
68
+ * }
69
+ * }
70
+ * ```
71
+ *
72
+ * @returns {PlatformConfiguration}
73
+ */
74
+ get settings() {
75
+ return this.injector.settings;
76
+ }
77
+ get logger() {
78
+ return this.injector.logger;
79
+ }
80
+ get disableBootstrapLog() {
81
+ var _a;
82
+ return (_a = this.settings.logger) === null || _a === void 0 ? void 0 : _a.disableBootstrapLog;
83
+ }
84
+ static create(module, settings) {
85
+ return this.build(module, {
86
+ httpsPort: false,
87
+ httpPort: false,
88
+ ...settings,
89
+ disableComponentsScan: true
90
+ });
91
+ }
92
+ static build(module, { adapter, ...settings }) {
93
+ return new PlatformBuilder(adapter, module, settings);
94
+ }
95
+ /**
96
+ * Bootstrap a server application
97
+ * @param module
98
+ * @param settings
99
+ */
100
+ static async bootstrap(module, settings) {
101
+ return this.build(module, settings).bootstrap();
102
+ }
103
+ callback(req, res) {
104
+ if (req && res) {
105
+ return this.app.callback()(req, res);
106
+ }
107
+ return this.app.callback();
108
+ }
109
+ log(...data) {
110
+ return !this.disableBootstrapLog && this.logger.info(...data, this.diff());
111
+ }
112
+ /**
113
+ * Add classes to the components list
114
+ * @param classes
115
+ */
116
+ addComponents(classes) {
117
+ this.settings.componentsScan = this.settings.componentsScan.concat(classes);
118
+ return this;
119
+ }
120
+ /**
121
+ * Add classes decorated by @@Controller@@ to components container.
122
+ *
123
+ * ### Example
124
+ *
125
+ * ```typescript
126
+ * @Controller('/ctrl')
127
+ * class MyController{
128
+ * }
129
+ *
130
+ * platform.addControllers('/rest', [MyController])
131
+ * ```
132
+ *
133
+ * ::: tip
134
+ * If the MyController class isn't decorated, the class will be ignored.
135
+ * :::
136
+ *
137
+ * @param {string} endpoint
138
+ * @param {any[]} controllers
139
+ */
140
+ addControllers(endpoint, controllers) {
141
+ this.settings.mount[endpoint] = (this.settings.mount[endpoint] || []).concat(controllers);
142
+ }
143
+ async runLifecycle() {
144
+ setLoggerLevel(this.injector);
145
+ await this.importProviders();
146
+ await this.loadInjector();
147
+ __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").useContext && __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").useContext();
148
+ __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").useRouter && __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").useRouter();
149
+ await this.loadRoutes();
150
+ await this.logRoutes();
151
+ return this;
152
+ }
153
+ async loadInjector() {
154
+ const { injector } = this;
155
+ this.log("Build providers");
156
+ const container = createContainer();
157
+ container.addProvider(__classPrivateFieldGet(this, _PlatformBuilder_rootModule, "f"), {
158
+ type: "server:module",
159
+ scope: ProviderScope.SINGLETON
160
+ });
161
+ await injector.load(container);
162
+ this.log("Settings and injector loaded...");
163
+ await this.callHook("$afterInit");
164
+ }
165
+ async listen(network = true) {
166
+ if (!__classPrivateFieldGet(this, _PlatformBuilder_promise, "f")) {
167
+ await this.bootstrap();
168
+ }
169
+ await this.callHook("$beforeListen");
170
+ if (network) {
171
+ await this.listenServers();
172
+ }
173
+ await this.callHook("$afterListen");
174
+ await this.ready();
175
+ }
176
+ async stop() {
177
+ await this.callHook("$onDestroy");
178
+ return this.injector.destroy();
179
+ }
180
+ async ready() {
181
+ const { startedAt } = this;
182
+ await this.callHook("$onReady");
183
+ await this.injector.emit("$onServerReady");
184
+ this.log(`Started in ${new Date().getTime() - startedAt.getTime()} ms`);
185
+ }
186
+ async callHook(hook, ...args) {
187
+ const { injector } = this;
188
+ if (!this.disableBootstrapLog) {
189
+ injector.logger.debug(`\x1B[1mCall hook ${hook}\x1B[22m`);
190
+ }
191
+ // Load middlewares for the given hook
192
+ this.loadMiddlewaresFor(hook);
193
+ // call hooks added by providers
194
+ await injector.emit(hook, ...args);
195
+ }
196
+ async loadStatics(hook) {
197
+ const statics = this.settings.get("statics");
198
+ getStaticsOptions(statics).forEach(({ path, options }) => {
199
+ if (options.hook === hook) {
200
+ this.platform.app.statics(path, options);
201
+ }
202
+ });
203
+ }
204
+ useProvider(token, settings) {
205
+ this.injector.addProvider(token, settings);
206
+ return this;
207
+ }
208
+ async bootstrap() {
209
+ __classPrivateFieldSet(this, _PlatformBuilder_promise, __classPrivateFieldGet(this, _PlatformBuilder_promise, "f") || this.runLifecycle(), "f");
210
+ return __classPrivateFieldGet(this, _PlatformBuilder_promise, "f");
211
+ }
212
+ async loadRoutes() {
213
+ var _a, _b;
214
+ __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").beforeLoadRoutes && (await __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").beforeLoadRoutes());
215
+ // istanbul ignore next
216
+ if (((_a = this.settings.logger) === null || _a === void 0 ? void 0 : _a.level) !== "off") {
217
+ const { PlatformLogMiddleware } = await import("@tsed/platform-log-middleware");
218
+ this.app.use(PlatformLogMiddleware);
219
+ }
220
+ if ((_b = this.settings.acceptMimes) === null || _b === void 0 ? void 0 : _b.length) {
221
+ this.app.use(GlobalAcceptMimesMiddleware);
222
+ }
223
+ this.log("Load routes");
224
+ await this.loadStatics("$beforeRoutesInit");
225
+ await this.callHook("$beforeRoutesInit");
226
+ const routes = this.injector.settings.get("routes");
227
+ this.platform.addRoutes(routes);
228
+ await this.callHook("$onRoutesInit");
229
+ await this.loadStatics("$afterRoutesInit");
230
+ await this.callHook("$afterRoutesInit");
231
+ __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").afterLoadRoutes && (await __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").afterLoadRoutes());
232
+ }
233
+ diff() {
234
+ const ms = colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);
235
+ this.current = new Date();
236
+ return ms;
237
+ }
238
+ async importProviders() {
239
+ this.injector.logger.debug("Scan components");
240
+ const providers = await importProviders(this.injector.settings, ["imports", "mount", "componentsScan"]);
241
+ const routes = providers.filter((provider) => !!provider.route).map(({ route, token }) => ({ route, token }));
242
+ this.settings.set("routes", routes);
243
+ this.log("Providers loaded...");
244
+ }
245
+ /**
246
+ * Load middlewares from configuration for the given hook
247
+ * @param hook
248
+ * @protected
249
+ */
250
+ loadMiddlewaresFor(hook) {
251
+ return getMiddlewaresForHook(hook, this.settings, "$beforeRoutesInit").forEach(({ use }) => {
252
+ this.app.use(use);
253
+ });
254
+ }
255
+ createHttpServers() {
256
+ __classPrivateFieldSet(this, _PlatformBuilder_servers, [createHttpServer(__classPrivateFieldGet(this, _PlatformBuilder_injector, "f"), this.callback()), createHttpsServer(__classPrivateFieldGet(this, _PlatformBuilder_injector, "f"), this.callback())].filter(Boolean), "f");
257
+ }
258
+ async listenServers() {
259
+ await Promise.all(__classPrivateFieldGet(this, _PlatformBuilder_servers, "f").map((cb) => cb && cb()));
260
+ }
261
+ async logRoutes() {
262
+ var _a;
263
+ const { logger, platform } = this;
264
+ this.log("Routes mounted...");
265
+ if (!((_a = this.settings.logger) === null || _a === void 0 ? void 0 : _a.disableRoutesSummary) && !this.disableBootstrapLog) {
266
+ logger.info(printRoutes(await this.injector.alterAsync("$logRoutes", platform.getRoutes())));
267
+ }
268
+ }
269
+ }
270
+ _PlatformBuilder_injector = new WeakMap(), _PlatformBuilder_rootModule = new WeakMap(), _PlatformBuilder_promise = new WeakMap(), _PlatformBuilder_adapter = new WeakMap(), _PlatformBuilder_servers = new WeakMap();
271
+ //# sourceMappingURL=PlatformBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformBuilder.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,MAAM,EAAO,MAAM,YAAY,CAAC;AACxC,OAAO,EAAC,MAAM,EAAE,eAAe,EAA8B,aAAa,EAAE,cAAc,EAAC,MAAM,UAAU,CAAC;AAC5G,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAC,qBAAqB,EAAC,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAC,2BAA2B,EAAC,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAC,MAAM,UAAU,CAAC;AAE1F,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAI3D;;GAEG;AACH,MAAM,OAAO,eAAe;IAa1B,YAAsB,OAAuD,EAAE,MAAY,EAAE,QAAqC;QAVzH,SAAI,GAAW,EAAE,CAAC;QACjB,cAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,YAAO,GAAG,IAAI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AAC,GAAG,IAAI,CAAC;QAEhC,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAE9B,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,MAAM,0CAAE,oBAAoB,CAAA,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;YAC5E,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;SAC9F;IACH,CAAC;CACF","sourcesContent":["import {nameOf, Type} from \"@tsed/core\";\nimport {colors, createContainer, InjectorService, IProvider, ProviderScope, setLoggerLevel} from \"@tsed/di\";\nimport {importProviders} from \"@tsed/components-scan\";\nimport {getMiddlewaresForHook} from \"@tsed/platform-middlewares\";\nimport {GlobalAcceptMimesMiddleware} from \"../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 if (this.settings.acceptMimes?.length) {\n this.app.use(GlobalAcceptMimesMiddleware);\n }\n\n this.log(\"Load routes\");\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"]}
@@ -0,0 +1,79 @@
1
+ import { GlobalProviders, ProviderType } from "@tsed/di";
2
+ import { getOperationsRoutes, OperationMethods } from "@tsed/schema";
3
+ import { ControllerProvider } from "../domain/ControllerProvider";
4
+ import { PlatformRouter } from "../services/PlatformRouter";
5
+ import { PlatformMiddlewaresChain } from "../services/PlatformMiddlewaresChain";
6
+ GlobalProviders.createRegistry(ProviderType.CONTROLLER, ControllerProvider, {
7
+ onInvoke(provider, locals, { injector }) {
8
+ const router = createRouter(injector, provider);
9
+ locals.set(PlatformRouter, router);
10
+ }
11
+ });
12
+ /**
13
+ * @ignore
14
+ */
15
+ function formatMethod(method) {
16
+ return (method === OperationMethods.CUSTOM ? "use" : method || "use").toLowerCase();
17
+ }
18
+ /**
19
+ * @ignore
20
+ */
21
+ export function getRouter(injector, provider) {
22
+ return injector.get(provider.tokenRouter);
23
+ }
24
+ /**
25
+ * @ignore
26
+ */
27
+ export function createRouter(injector, provider) {
28
+ const token = provider.tokenRouter;
29
+ if (injector.has(token)) {
30
+ return getRouter(injector, provider);
31
+ }
32
+ const router = PlatformRouter.create(injector, provider.routerOptions);
33
+ return injector
34
+ .add(token, {
35
+ useValue: router
36
+ })
37
+ .invoke(token);
38
+ }
39
+ /**
40
+ * @ignore
41
+ * @param injector
42
+ * @param provider
43
+ */
44
+ export function buildRouter(injector, provider) {
45
+ const { middlewares: { useBefore }, children } = provider;
46
+ // Controller lifecycle
47
+ const router = createRouter(injector, provider);
48
+ if (!router.isBuilt) {
49
+ router.isBuilt = true;
50
+ const platformMiddlewaresChain = injector.get(PlatformMiddlewaresChain);
51
+ useBefore // Controller before-middleware
52
+ .filter((o) => typeof o === "function")
53
+ .forEach((middleware) => {
54
+ router.use(middleware);
55
+ });
56
+ // build all endpoints and his middlewares
57
+ getOperationsRoutes(provider.token).forEach((operationRoute) => {
58
+ const handlers = platformMiddlewaresChain === null || platformMiddlewaresChain === void 0 ? void 0 : platformMiddlewaresChain.get(provider, operationRoute);
59
+ router.addRoute({
60
+ handlers,
61
+ token: operationRoute.token,
62
+ method: formatMethod(operationRoute.method),
63
+ path: operationRoute.path,
64
+ isFinal: operationRoute.isFinal
65
+ });
66
+ });
67
+ // build children controllers
68
+ children.forEach((child) => {
69
+ const childProvider = injector.getProvider(child);
70
+ /* istanbul ignore next */
71
+ if (!childProvider) {
72
+ throw new Error("Controller component not found in the ControllerRegistry");
73
+ }
74
+ router.use(childProvider.path, buildRouter(injector, childProvider));
75
+ });
76
+ }
77
+ return router;
78
+ }
79
+ //# sourceMappingURL=PlatformControllerBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformControllerBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformControllerBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAmB,YAAY,EAAC,MAAM,UAAU,CAAC;AACxE,OAAO,EAAC,mBAAmB,EAAE,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACnE,OAAO,EAAC,kBAAkB,EAAC,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,C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,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","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"]}
@@ -0,0 +1,4 @@
1
+ export * from "./interfaces";
2
+ export * from "./services/PlatformConfiguration";
3
+ export * from "./services/PlatformConfiguration";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC","sourcesContent":["export * from \"./interfaces\";\nexport * from \"./services/PlatformConfiguration\";\nexport * from \"./services/PlatformConfiguration\";\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ConverterSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConverterSettings.js","sourceRoot":"","sources":["../../../../src/config/interfaces/ConverterSettings.ts"],"names":[],"mappings":"","sourcesContent":["export interface ConverterSettings {\n /**\n * Converter additional property policy. (see [Converters](/docs/converters.md))\n */\n additionalProperties?: \"error\" | \"accept\" | \"ignore\";\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=EndpointDirectoriesSettings.js.map