@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,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlatformModule = void 0;
4
+ /**
5
+ * @ignore
6
+ * @deprecated Will be removed in v7
7
+ */
8
+ class PlatformModule {
9
+ }
10
+ exports.PlatformModule = PlatformModule;
11
+ //# sourceMappingURL=PlatformModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformModule.js","sourceRoot":"","sources":["../../src/PlatformModule.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,MAAa,cAAc;CAAG;AAA9B,wCAA8B","sourcesContent":["/**\n * @ignore\n * @deprecated Will be removed in v7\n */\nexport class PlatformModule {}\n"]}
@@ -4,35 +4,17 @@ import { InjectorService, IProvider } from "@tsed/di";
4
4
  import { Platform } from "../services/Platform";
5
5
  import { PlatformApplication } from "../services/PlatformApplication";
6
6
  import { IncomingMessage, ServerResponse } from "http";
7
- /**
8
- * @ignore
9
- */
10
- export interface PlatformType<T = any> extends Type<T> {
11
- providers: IProvider[];
12
- }
13
- /**
14
- * @ignore
15
- */
16
- export interface PlatformBootstrap {
17
- create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder;
18
- bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder>;
19
- }
20
- export interface PlatformBuilderOptions {
21
- name: string;
22
- providers: IProvider[];
23
- settings: any;
24
- module: Type<any>;
25
- }
7
+ import { PlatformAdapter, PlatformBuilderSettings } from "../interfaces/PlatformAdapter";
26
8
  /**
27
9
  * @platform
28
10
  */
29
- export declare abstract class PlatformBuilder<App = TsED.Application, Router = TsED.Router> {
11
+ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Router> {
30
12
  #private;
31
- static currentPlatform: Type<PlatformBuilder<any, any>> & PlatformBootstrap;
13
+ static adapter: Type<PlatformAdapter>;
32
14
  readonly name: string;
33
15
  protected startedAt: Date;
34
16
  protected current: Date;
35
- constructor({ name, providers, settings, module }: PlatformBuilderOptions);
17
+ protected constructor(adapter: Type<PlatformAdapter<App, Router>> | undefined, module: Type, settings: Partial<TsED.Configuration>);
36
18
  get injector(): InjectorService;
37
19
  get rootModule(): any;
38
20
  get app(): PlatformApplication<App, Router>;
@@ -61,7 +43,14 @@ export declare abstract class PlatformBuilder<App = TsED.Application, Router = T
61
43
  get settings(): TsED.Configuration & import("@tsed/di").DIConfiguration;
62
44
  get logger(): import("@tsed/di").DILogger;
63
45
  get disableBootstrapLog(): boolean | undefined;
64
- static build<T extends PlatformBuilder<any, any>>(platformBuildClass: PlatformType<T>, module: Type<any>, settings?: Partial<TsED.Configuration>): T;
46
+ static create<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>): PlatformBuilder<App, Router>;
47
+ static build<App = TsED.Application, Router = TsED.Router>(module: Type<any>, { adapter, ...settings }: PlatformBuilderSettings<App, Router>): PlatformBuilder<App, Router>;
48
+ /**
49
+ * Bootstrap a server application
50
+ * @param module
51
+ * @param settings
52
+ */
53
+ static bootstrap<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>): Promise<PlatformBuilder<App, Router>>;
65
54
  callback(): (req: IncomingMessage, res: ServerResponse) => void;
66
55
  callback(req: IncomingMessage, res: ServerResponse): void;
67
56
  log(...data: any[]): any;
@@ -93,13 +82,14 @@ export declare abstract class PlatformBuilder<App = TsED.Application, Router = T
93
82
  addControllers(endpoint: string, controllers: any | string | (any | string)[]): void;
94
83
  runLifecycle(): Promise<this>;
95
84
  loadInjector(): Promise<void>;
96
- listen(): Promise<void>;
85
+ listen(network?: boolean): Promise<void>;
97
86
  stop(): Promise<void>;
98
87
  ready(): Promise<void>;
99
88
  callHook(hook: string, ...args: any[]): Promise<void>;
100
89
  loadStatics(hook: string): Promise<void>;
101
90
  useProvider(token: Type<any>, settings?: Partial<IProvider>): this;
102
91
  bootstrap(): Promise<this>;
92
+ protected loadRoutes(): Promise<void>;
103
93
  protected diff(): string;
104
94
  protected importProviders(): Promise<void>;
105
95
  /**
@@ -108,9 +98,7 @@ export declare abstract class PlatformBuilder<App = TsED.Application, Router = T
108
98
  * @protected
109
99
  */
110
100
  protected loadMiddlewaresFor(hook: string): void;
111
- protected useRouter(): this;
112
- protected useContext(): this;
101
+ protected createHttpServers(): void;
113
102
  protected listenServers(): Promise<void>;
114
103
  protected logRoutes(): Promise<void>;
115
- protected loadRoutes(): Promise<void>;
116
104
  }
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ var _PlatformBuilder_injector, _PlatformBuilder_rootModule, _PlatformBuilder_promise, _PlatformBuilder_adapter, _PlatformBuilder_servers;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.PlatformBuilder = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const core_1 = require("@tsed/core");
7
+ const di_1 = require("@tsed/di");
8
+ const components_scan_1 = require("@tsed/components-scan");
9
+ const platform_middlewares_1 = require("@tsed/platform-middlewares");
10
+ const middlewares_1 = require("../middlewares");
11
+ const Platform_1 = require("../services/Platform");
12
+ const PlatformApplication_1 = require("../services/PlatformApplication");
13
+ const utils_1 = require("../utils");
14
+ const getStaticsOptions_1 = require("../utils/getStaticsOptions");
15
+ const getConfiguration_1 = require("../utils/getConfiguration");
16
+ /**
17
+ * @platform
18
+ */
19
+ class PlatformBuilder {
20
+ constructor(adapter, module, settings) {
21
+ this.name = "";
22
+ this.startedAt = new Date();
23
+ this.current = new Date();
24
+ _PlatformBuilder_injector.set(this, void 0);
25
+ _PlatformBuilder_rootModule.set(this, void 0);
26
+ _PlatformBuilder_promise.set(this, void 0);
27
+ _PlatformBuilder_adapter.set(this, void 0);
28
+ _PlatformBuilder_servers.set(this, void 0);
29
+ (0, tslib_1.__classPrivateFieldSet)(this, _PlatformBuilder_rootModule, module, "f");
30
+ const adapterKlass = adapter || PlatformBuilder.adapter;
31
+ const name = (0, core_1.nameOf)(adapterKlass).replace("Platform", "").toLowerCase();
32
+ const configuration = (0, getConfiguration_1.getConfiguration)(settings, module);
33
+ configuration.PLATFORM_NAME = name;
34
+ this.name = name;
35
+ (0, tslib_1.__classPrivateFieldSet)(this, _PlatformBuilder_adapter, new adapterKlass(this), "f");
36
+ (0, tslib_1.__classPrivateFieldSet)(this, _PlatformBuilder_injector, (0, utils_1.createInjector)({
37
+ settings: configuration,
38
+ providers: (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").providers
39
+ }), "f");
40
+ this.createHttpServers();
41
+ (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").onInit && (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").onInit();
42
+ this.log("Injector created...");
43
+ }
44
+ get injector() {
45
+ return (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_injector, "f");
46
+ }
47
+ get rootModule() {
48
+ return (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_injector, "f").get((0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_rootModule, "f"));
49
+ }
50
+ get app() {
51
+ return this.injector.get(PlatformApplication_1.PlatformApplication);
52
+ }
53
+ get platform() {
54
+ return this.injector.get(Platform_1.Platform);
55
+ }
56
+ /**
57
+ * Return the settings configured by the decorator @@Configuration@@.
58
+ *
59
+ * ```typescript
60
+ * @Configuration({
61
+ * rootDir: Path.resolve(__dirname),
62
+ * port: 8000,
63
+ * httpsPort: 8080,
64
+ * mount: {
65
+ * "/rest": "${rootDir}/controllers/**\/*.js"
66
+ * }
67
+ * })
68
+ * export class Server {
69
+ * $onInit(){
70
+ * console.log(this.settings); // {rootDir, port, httpsPort,...}
71
+ * }
72
+ * }
73
+ * ```
74
+ *
75
+ * @returns {PlatformConfiguration}
76
+ */
77
+ get settings() {
78
+ return this.injector.settings;
79
+ }
80
+ get logger() {
81
+ return this.injector.logger;
82
+ }
83
+ get disableBootstrapLog() {
84
+ var _a;
85
+ return (_a = this.settings.logger) === null || _a === void 0 ? void 0 : _a.disableBootstrapLog;
86
+ }
87
+ static create(module, settings) {
88
+ return this.build(module, {
89
+ httpsPort: false,
90
+ httpPort: false,
91
+ ...settings,
92
+ disableComponentsScan: true
93
+ });
94
+ }
95
+ static build(module, { adapter, ...settings }) {
96
+ return new PlatformBuilder(adapter, module, settings);
97
+ }
98
+ /**
99
+ * Bootstrap a server application
100
+ * @param module
101
+ * @param settings
102
+ */
103
+ static async bootstrap(module, settings) {
104
+ return this.build(module, settings).bootstrap();
105
+ }
106
+ callback(req, res) {
107
+ if (req && res) {
108
+ return this.app.callback()(req, res);
109
+ }
110
+ return this.app.callback();
111
+ }
112
+ log(...data) {
113
+ return !this.disableBootstrapLog && this.logger.info(...data, this.diff());
114
+ }
115
+ /**
116
+ * Add classes to the components list
117
+ * @param classes
118
+ */
119
+ addComponents(classes) {
120
+ this.settings.componentsScan = this.settings.componentsScan.concat(classes);
121
+ return this;
122
+ }
123
+ /**
124
+ * Add classes decorated by @@Controller@@ to components container.
125
+ *
126
+ * ### Example
127
+ *
128
+ * ```typescript
129
+ * @Controller('/ctrl')
130
+ * class MyController{
131
+ * }
132
+ *
133
+ * platform.addControllers('/rest', [MyController])
134
+ * ```
135
+ *
136
+ * ::: tip
137
+ * If the MyController class isn't decorated, the class will be ignored.
138
+ * :::
139
+ *
140
+ * @param {string} endpoint
141
+ * @param {any[]} controllers
142
+ */
143
+ addControllers(endpoint, controllers) {
144
+ this.settings.mount[endpoint] = (this.settings.mount[endpoint] || []).concat(controllers);
145
+ }
146
+ async runLifecycle() {
147
+ (0, di_1.setLoggerLevel)(this.injector);
148
+ await this.importProviders();
149
+ await this.loadInjector();
150
+ (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").useContext && (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").useContext();
151
+ (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").useRouter && (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").useRouter();
152
+ await this.loadRoutes();
153
+ await this.logRoutes();
154
+ return this;
155
+ }
156
+ async loadInjector() {
157
+ const { injector } = this;
158
+ this.log("Build providers");
159
+ const container = (0, di_1.createContainer)();
160
+ container.addProvider((0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_rootModule, "f"), {
161
+ type: "server:module",
162
+ scope: di_1.ProviderScope.SINGLETON
163
+ });
164
+ await injector.load(container);
165
+ this.log("Settings and injector loaded...");
166
+ await this.callHook("$afterInit");
167
+ }
168
+ async listen(network = true) {
169
+ if (!(0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_promise, "f")) {
170
+ await this.bootstrap();
171
+ }
172
+ await this.callHook("$beforeListen");
173
+ if (network) {
174
+ await this.listenServers();
175
+ }
176
+ await this.callHook("$afterListen");
177
+ await this.ready();
178
+ }
179
+ async stop() {
180
+ await this.callHook("$onDestroy");
181
+ return this.injector.destroy();
182
+ }
183
+ async ready() {
184
+ const { startedAt } = this;
185
+ await this.callHook("$onReady");
186
+ await this.injector.emit("$onServerReady");
187
+ this.log(`Started in ${new Date().getTime() - startedAt.getTime()} ms`);
188
+ }
189
+ async callHook(hook, ...args) {
190
+ const { injector } = this;
191
+ if (!this.disableBootstrapLog) {
192
+ injector.logger.debug(`\x1B[1mCall hook ${hook}\x1B[22m`);
193
+ }
194
+ // Load middlewares for the given hook
195
+ this.loadMiddlewaresFor(hook);
196
+ // call hooks added by providers
197
+ await injector.emit(hook, ...args);
198
+ }
199
+ async loadStatics(hook) {
200
+ const statics = this.settings.get("statics");
201
+ (0, getStaticsOptions_1.getStaticsOptions)(statics).forEach(({ path, options }) => {
202
+ if (options.hook === hook) {
203
+ this.platform.app.statics(path, options);
204
+ }
205
+ });
206
+ }
207
+ useProvider(token, settings) {
208
+ this.injector.addProvider(token, settings);
209
+ return this;
210
+ }
211
+ async bootstrap() {
212
+ (0, tslib_1.__classPrivateFieldSet)(this, _PlatformBuilder_promise, (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_promise, "f") || this.runLifecycle(), "f");
213
+ return (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_promise, "f");
214
+ }
215
+ async loadRoutes() {
216
+ var _a, _b;
217
+ (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").beforeLoadRoutes && (await (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").beforeLoadRoutes());
218
+ // istanbul ignore next
219
+ if (((_a = this.settings.logger) === null || _a === void 0 ? void 0 : _a.level) !== "off") {
220
+ const { PlatformLogMiddleware } = await Promise.resolve().then(() => (0, tslib_1.__importStar)(require("@tsed/platform-log-middleware")));
221
+ this.app.use(PlatformLogMiddleware);
222
+ }
223
+ if ((_b = this.settings.acceptMimes) === null || _b === void 0 ? void 0 : _b.length) {
224
+ this.app.use(middlewares_1.GlobalAcceptMimesMiddleware);
225
+ }
226
+ this.log("Load routes");
227
+ await this.loadStatics("$beforeRoutesInit");
228
+ await this.callHook("$beforeRoutesInit");
229
+ const routes = this.injector.settings.get("routes");
230
+ this.platform.addRoutes(routes);
231
+ await this.callHook("$onRoutesInit");
232
+ await this.loadStatics("$afterRoutesInit");
233
+ await this.callHook("$afterRoutesInit");
234
+ (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").afterLoadRoutes && (await (0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_adapter, "f").afterLoadRoutes());
235
+ }
236
+ diff() {
237
+ const ms = di_1.colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);
238
+ this.current = new Date();
239
+ return ms;
240
+ }
241
+ async importProviders() {
242
+ this.injector.logger.debug("Scan components");
243
+ const providers = await (0, components_scan_1.importProviders)(this.injector.settings, ["imports", "mount", "componentsScan"]);
244
+ const routes = providers.filter((provider) => !!provider.route).map(({ route, token }) => ({ route, token }));
245
+ this.settings.set("routes", routes);
246
+ this.log("Providers loaded...");
247
+ }
248
+ /**
249
+ * Load middlewares from configuration for the given hook
250
+ * @param hook
251
+ * @protected
252
+ */
253
+ loadMiddlewaresFor(hook) {
254
+ return (0, platform_middlewares_1.getMiddlewaresForHook)(hook, this.settings, "$beforeRoutesInit").forEach(({ use }) => {
255
+ this.app.use(use);
256
+ });
257
+ }
258
+ createHttpServers() {
259
+ (0, tslib_1.__classPrivateFieldSet)(this, _PlatformBuilder_servers, [(0, utils_1.createHttpServer)((0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_injector, "f"), this.callback()), (0, utils_1.createHttpsServer)((0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_injector, "f"), this.callback())].filter(Boolean), "f");
260
+ }
261
+ async listenServers() {
262
+ await Promise.all((0, tslib_1.__classPrivateFieldGet)(this, _PlatformBuilder_servers, "f").map((cb) => cb && cb()));
263
+ }
264
+ async logRoutes() {
265
+ var _a;
266
+ const { logger, platform } = this;
267
+ this.log("Routes mounted...");
268
+ if (!((_a = this.settings.logger) === null || _a === void 0 ? void 0 : _a.disableRoutesSummary) && !this.disableBootstrapLog) {
269
+ logger.info((0, utils_1.printRoutes)(await this.injector.alterAsync("$logRoutes", platform.getRoutes())));
270
+ }
271
+ }
272
+ }
273
+ exports.PlatformBuilder = PlatformBuilder;
274
+ _PlatformBuilder_injector = new WeakMap(), _PlatformBuilder_rootModule = new WeakMap(), _PlatformBuilder_promise = new WeakMap(), _PlatformBuilder_adapter = new WeakMap(), _PlatformBuilder_servers = new WeakMap();
275
+ //# sourceMappingURL=PlatformBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformBuilder.ts"],"names":[],"mappings":";;;;;AA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,yBAAiB,EAAC,oCAAA,IAAI,iCAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAC5H,OAAO,CACC,MAAA,CAAC;IACb,CAAC;IAES,KAAK,CAAC,aAAa;QAC3B,MAAM,OAAO,CAAC,GAAG,CAAC,oCAAA,IAAI,gCAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;IAES,KAAK,CAAC,SAAS;;QACvB,MAAM,EAAC,MAAM,EAAE,QAAQ,EAAC,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,IAAA,mBAAW,EAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;SAC9F;IACH,CAAC;CACF;AA7UD,0CA6UC","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,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildRouter = exports.createRouter = exports.getRouter = void 0;
4
+ const di_1 = require("@tsed/di");
5
+ const schema_1 = require("@tsed/schema");
6
+ const ControllerProvider_1 = require("../domain/ControllerProvider");
7
+ const PlatformRouter_1 = require("../services/PlatformRouter");
8
+ const PlatformMiddlewaresChain_1 = require("../services/PlatformMiddlewaresChain");
9
+ di_1.GlobalProviders.createRegistry(di_1.ProviderType.CONTROLLER, ControllerProvider_1.ControllerProvider, {
10
+ onInvoke(provider, locals, { injector }) {
11
+ const router = createRouter(injector, provider);
12
+ locals.set(PlatformRouter_1.PlatformRouter, router);
13
+ }
14
+ });
15
+ /**
16
+ * @ignore
17
+ */
18
+ function formatMethod(method) {
19
+ return (method === schema_1.OperationMethods.CUSTOM ? "use" : method || "use").toLowerCase();
20
+ }
21
+ /**
22
+ * @ignore
23
+ */
24
+ function getRouter(injector, provider) {
25
+ return injector.get(provider.tokenRouter);
26
+ }
27
+ exports.getRouter = getRouter;
28
+ /**
29
+ * @ignore
30
+ */
31
+ function createRouter(injector, provider) {
32
+ const token = provider.tokenRouter;
33
+ if (injector.has(token)) {
34
+ return getRouter(injector, provider);
35
+ }
36
+ const router = PlatformRouter_1.PlatformRouter.create(injector, provider.routerOptions);
37
+ return injector
38
+ .add(token, {
39
+ useValue: router
40
+ })
41
+ .invoke(token);
42
+ }
43
+ exports.createRouter = createRouter;
44
+ /**
45
+ * @ignore
46
+ * @param injector
47
+ * @param provider
48
+ */
49
+ function buildRouter(injector, provider) {
50
+ const { middlewares: { useBefore }, children } = provider;
51
+ // Controller lifecycle
52
+ const router = createRouter(injector, provider);
53
+ if (!router.isBuilt) {
54
+ router.isBuilt = true;
55
+ const platformMiddlewaresChain = injector.get(PlatformMiddlewaresChain_1.PlatformMiddlewaresChain);
56
+ useBefore // Controller before-middleware
57
+ .filter((o) => typeof o === "function")
58
+ .forEach((middleware) => {
59
+ router.use(middleware);
60
+ });
61
+ // build all endpoints and his middlewares
62
+ (0, schema_1.getOperationsRoutes)(provider.token).forEach((operationRoute) => {
63
+ const handlers = platformMiddlewaresChain === null || platformMiddlewaresChain === void 0 ? void 0 : platformMiddlewaresChain.get(provider, operationRoute);
64
+ router.addRoute({
65
+ handlers,
66
+ token: operationRoute.token,
67
+ method: formatMethod(operationRoute.method),
68
+ path: operationRoute.path,
69
+ isFinal: operationRoute.isFinal
70
+ });
71
+ });
72
+ // build children controllers
73
+ children.forEach((child) => {
74
+ const childProvider = injector.getProvider(child);
75
+ /* istanbul ignore next */
76
+ if (!childProvider) {
77
+ throw new Error("Controller component not found in the ControllerRegistry");
78
+ }
79
+ router.use(childProvider.path, buildRouter(injector, childProvider));
80
+ });
81
+ }
82
+ return router;
83
+ }
84
+ exports.buildRouter = buildRouter;
85
+ //# sourceMappingURL=PlatformControllerBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformControllerBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformControllerBuilder.ts"],"names":[],"mappings":";;;AACA,iCAAwE;AACxE,yCAAmE;AACnE,qEAAgE;AAChE,+DAA0D;AAE1D,mFAA8E;AAE9E,oBAAe,CAAC,cAAc,CAAC,iBAAY,CAAC,UAAU,EAAE,uCAAkB,EAAE;IAC1E,QAAQ,CAAC,QAA4B,EAAE,MAAW,EAAE,EAAC,QAAQ,EAAC;QAC5D,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,+BAAc,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;CACF,CAAC,CAAC;AAEH;;GAEG;AACH,SAAS,YAAY,CAAC,MAA0B;IAC9C,OAAO,CAAC,MAAM,KAAK,yBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACtF,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,QAAyB,EAAE,QAA4B;IAC/E,OAAO,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAE,CAAC;AAC7C,CAAC;AAFD,8BAEC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,QAAyB,EAAE,QAA4B;IAClF,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC;IAEnC,IAAI,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,KAAK,EAAE,cAAc,CAAC,KAAK;gBAC3B,MAAM,EAAE,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC;gBAC3C,IAAI,EAAE,cAAc,CAAC,IAAI;gBACzB,OAAO,EAAE,cAAc,CAAC,OAAO;aAChC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,6BAA6B;QAC7B,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAgB,EAAE,EAAE;YACpC,MAAM,aAAa,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAuB,CAAC;YAExE,0BAA0B;YAC1B,IAAI,CAAC,aAAa,EAAE;gBAClB,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;aAC7E;YAED,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA/CD,kCA+CC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {GlobalProviders, InjectorService, ProviderType} from \"@tsed/di\";\nimport {getOperationsRoutes, OperationMethods} from \"@tsed/schema\";\nimport {ControllerProvider} from \"../domain/ControllerProvider\";\nimport {PlatformRouter} from \"../services/PlatformRouter\";\nimport {EndpointMetadata} from \"../domain/EndpointMetadata\";\nimport {PlatformMiddlewaresChain} from \"../services/PlatformMiddlewaresChain\";\n\nGlobalProviders.createRegistry(ProviderType.CONTROLLER, ControllerProvider, {\n onInvoke(provider: ControllerProvider, locals: any, {injector}) {\n const router = createRouter(injector, provider);\n locals.set(PlatformRouter, router);\n }\n});\n\n/**\n * @ignore\n */\nfunction formatMethod(method: string | undefined) {\n return (method === OperationMethods.CUSTOM ? \"use\" : method || \"use\").toLowerCase();\n}\n\n/**\n * @ignore\n */\nexport function getRouter(injector: InjectorService, provider: ControllerProvider) {\n return injector.get(provider.tokenRouter)!;\n}\n\n/**\n * @ignore\n */\nexport function createRouter(injector: InjectorService, provider: ControllerProvider): PlatformRouter {\n const token = provider.tokenRouter;\n\n if (injector.has(token)) {\n return getRouter(injector, provider);\n }\n\n const router = PlatformRouter.create(injector, provider.routerOptions);\n\n return injector\n .add(token, {\n useValue: router\n })\n .invoke<PlatformRouter>(token);\n}\n\n/**\n * @ignore\n * @param injector\n * @param provider\n */\nexport function buildRouter(injector: InjectorService, provider: ControllerProvider) {\n const {\n middlewares: {useBefore},\n children\n } = provider;\n\n // Controller lifecycle\n const router = createRouter(injector, provider);\n\n if (!router.isBuilt) {\n router.isBuilt = true;\n\n const platformMiddlewaresChain = injector.get<PlatformMiddlewaresChain>(PlatformMiddlewaresChain);\n\n useBefore // Controller before-middleware\n .filter((o) => typeof o === \"function\")\n .forEach((middleware: any) => {\n router.use(middleware);\n });\n\n // build all endpoints and his middlewares\n getOperationsRoutes<EndpointMetadata>(provider.token).forEach((operationRoute) => {\n const handlers = platformMiddlewaresChain?.get(provider, operationRoute);\n\n router.addRoute({\n handlers,\n token: operationRoute.token,\n method: formatMethod(operationRoute.method),\n path: operationRoute.path,\n isFinal: operationRoute.isFinal\n });\n });\n\n // build children controllers\n children.forEach((child: Type<any>) => {\n const childProvider = injector.getProvider(child) as ControllerProvider;\n\n /* istanbul ignore next */\n if (!childProvider) {\n throw new Error(\"Controller component not found in the ControllerRegistry\");\n }\n\n router.use(childProvider.path, buildRouter(injector, childProvider));\n });\n }\n\n return router;\n}\n"]}
File without changes
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./interfaces"), exports);
5
+ (0, tslib_1.__exportStar)(require("./services/PlatformConfiguration"), exports);
6
+ (0, tslib_1.__exportStar)(require("./services/PlatformConfiguration"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":";;;AAAA,4DAA6B;AAC7B,gFAAiD;AACjD,gFAAiD","sourcesContent":["export * from \"./interfaces\";\nexport * from \"./services/PlatformConfiguration\";\nexport * from \"./services/PlatformConfiguration\";\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# 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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=EndpointDirectoriesSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EndpointDirectoriesSettings.js","sourceRoot":"","sources":["../../../../src/config/interfaces/EndpointDirectoriesSettings.ts"],"names":[],"mappings":"","sourcesContent":["export interface EndpointDirectoriesSettings {\n [endpoint: string]: any | string | (any | string)[];\n}\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=PlatformLoggerSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformLoggerSettings.js","sourceRoot":"","sources":["../../../../src/config/interfaces/PlatformLoggerSettings.ts"],"names":[],"mappings":"","sourcesContent":["export interface PlatformLoggerSettings {\n /**\n * Enable debug mode. By default debug is false.\n */\n debug?: boolean;\n /**\n * Enable info mode. By default debug is false.\n */\n level?: \"debug\" | \"info\" | \"warn\" | \"error\" | \"off\";\n /**\n * Enable log performance tracker and disable log server.\n */\n perf?: boolean;\n /**\n * List of regexp to ignore log.\n */\n ignoreUrlPatterns?: string[];\n /**\n * The number of space characters to use as white space in JSON output. Default is 2 (0 in production).\n */\n jsonIndentation?: number;\n /**\n * A function called for each incoming request to create a request id.\n * @returns {number}\n */\n reqIdBuilder?: (req: TsED.Request) => string;\n /**\n * Disable routes table displayed in the logger. By default debug is `false`.\n */\n disableRoutesSummary?: boolean;\n /**\n * Disable bootstrap log displayed in the logger. By default debug is `false`.\n */\n disableBootstrapLog?: boolean;\n /**\n * Specify log format. Example: `%[%d{[yyyy-MM-dd hh:mm:ss,SSS}] %p%] %m`. See [@tsed/logger configuration](https://tsedio.github.io/logger/).\n */\n format?: string;\n /**\n * Specify the log stack size for the context.logger. When the stack.length is reach, the logger is flushed during the request.\n * Default size is set to 30.\n */\n maxStackSize?: number;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=PlatformMulterSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformMulterSettings.js","sourceRoot":"","sources":["../../../../src/config/interfaces/PlatformMulterSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {Request} from \"express\";\nimport {FileFilterCallback} from \"multer\";\nimport {Readable} from \"stream\";\n\ndeclare global {\n namespace TsED {\n export interface MulterFile {\n /** Name of the form field associated with this file. */\n fieldname: string;\n /** Name of the file on the uploader's computer. */\n originalname: string;\n /** Value of the `Content-Type` header for this file. */\n mimetype: string;\n /** Size of the file in bytes. */\n size: number;\n /**\n * A readable stream of this file. Only available to the `_handleFile`\n * callback for custom `StorageEngine`s.\n */\n stream: Readable;\n /** `DiskStorage` only: Directory to which this file has been uploaded. */\n destination: string;\n /** `DiskStorage` only: Name of this file within `destination`. */\n filename: string;\n /** `DiskStorage` only: Full path to the uploaded file. */\n path: string;\n /** `MemoryStorage` only: A Buffer containing the entire file. */\n buffer: Buffer;\n }\n\n export interface MulterStorageEngine {}\n\n export interface MulterOptions {\n /**\n * A `StorageEngine` responsible for processing files uploaded via Multer.\n * Takes precedence over `dest`.\n */\n storage?: MulterStorageEngine;\n /**\n * The destination directory for uploaded files. If `storage` is not set\n * and `dest` is, Multer will create a `DiskStorage` instance configured\n * to store files at `dest` with random filenames.\n *\n * Ignored if `storage` is set.\n */\n dest?: string;\n /**\n * An object specifying various limits on incoming data. This object is\n * passed to Busboy directly, and the details of properties can be found\n * at https://github.com/mscdex/busboy#busboy-methods.\n */\n limits?: {\n /** Maximum size of each form field name in bytes. (Default: 100) */\n fieldNameSize?: number;\n /** Maximum size of each form field value in bytes. (Default: 1048576) */\n fieldSize?: number;\n /** Maximum number of non-file form fields. (Default: Infinity) */\n fields?: number;\n /** Maximum size of each file in bytes. (Default: Infinity) */\n fileSize?: number;\n /** Maximum number of file fields. (Default: Infinity) */\n files?: number;\n /** Maximum number of parts (non-file fields + files). (Default: Infinity) */\n parts?: number;\n /** Maximum number of headers. (Default: 2000) */\n headerPairs?: number;\n };\n /** Preserve the full path of the original filename rather than the basename. (Default: false) */\n preservePath?: boolean;\n /**\n * Optional function to control which files are uploaded. This is called\n * for every file that is processed.\n *\n * @param req The Express `Request` object.\n * @param file Object containing information about the processed file.\n * @param callback a function to control which files should be uploaded and which should be skipped.\n */\n fileFilter?(req: Request, file: MulterFile, callback: FileFilterCallback): void;\n }\n\n export interface MulterField {\n name: string;\n maxCount?: number;\n }\n\n export type MulterHandler = (req: any, res: any) => Promise<any>;\n\n export interface Multer {\n /**\n * Returns middleware that processes a single file associated with the\n * given form field.\n *\n * The `Request` object will be populated with a `file` object containing\n * information about the processed file.\n *\n * @param fieldName Name of the multipart form field to process.\n */\n single(fieldName: string): MulterHandler;\n\n /**\n * Returns middleware that processes multiple files sharing the same field\n * name.\n *\n * The `Request` object will be populated with a `files` array containing\n * an information object for each processed file.\n *\n * @param fieldName Shared name of the multipart form fields to process.\n * @param maxCount Optional. Maximum number of files to process. (default: Infinity)\n * @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if more than `maxCount` files are associated with `fieldName`\n */\n array(fieldName: string, maxCount?: number): MulterHandler;\n\n /**\n * Returns middleware that processes multiple files associated with the\n * given form fields.\n *\n * The `Request` object will be populated with a `files` object which\n * maps each field name to an array of the associated file information\n * objects.\n *\n * @param fields Array of `Field` objects describing multipart form fields to process.\n * @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if more than `maxCount` files are associated with `fieldName` for any field.\n */\n fields(fields: MulterField[]): MulterHandler;\n\n /**\n * Returns middleware that processes all files contained in the multipart\n * request.\n *\n * The `Request` object will be populated with a `files` array containing\n * an information object for each processed file.\n */\n any(): MulterHandler;\n\n /**\n * Returns middleware that accepts only non-file multipart form fields.\n *\n * @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if any file is encountered.\n */\n none(): MulterHandler;\n }\n }\n}\n\nexport type PlatformMulter = TsED.Multer;\nexport type PlatformMulterSettings = TsED.MulterOptions;\nexport type PlatformMulterFile = TsED.MulterFile;\nexport type PlatformMulterField = TsED.MulterField;\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=PlatformStaticsSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformStaticsSettings.js","sourceRoot":"","sources":["../../../../src/config/interfaces/PlatformStaticsSettings.ts"],"names":[],"mappings":"","sourcesContent":["declare global {\n namespace TsED {\n // @ts-ignore\n export interface StaticsOptions {\n root: string;\n hook?: \"$beforeRoutesInit\" | \"$afterRoutesInit\";\n\n [key: string]: any;\n }\n }\n}\n\nexport interface PlatformStaticsOptions extends TsED.StaticsOptions {\n root: string;\n\n [key: string]: any;\n}\n\nexport type PathOrStaticsOptions = string | PlatformStaticsOptions;\n\nexport interface PlatformStaticsSettings {\n [endpoint: string]: PathOrStaticsOptions | PathOrStaticsOptions[];\n}\n"]}
@@ -1,11 +1,12 @@
1
1
  /// <reference types="node" />
2
2
  import { Env } from "@tsed/core";
3
- import Https from "https";
4
3
  import { ConverterSettings } from "./ConverterSettings";
5
4
  import { EndpointDirectoriesSettings } from "./EndpointDirectoriesSettings";
6
5
  import { PlatformLoggerSettings } from "./PlatformLoggerSettings";
7
6
  import { PlatformMulterSettings } from "./PlatformMulterSettings";
8
7
  import { PlatformStaticsSettings } from "./PlatformStaticsSettings";
8
+ import type Http from "http";
9
+ import type Https from "https";
9
10
  declare global {
10
11
  namespace TsED {
11
12
  interface LoggerConfiguration extends Partial<PlatformLoggerSettings> {
@@ -27,6 +28,14 @@ declare global {
27
28
  * Port number for the [HTTP.Server](https://nodejs.org/api/http.html#http_class_http_server).
28
29
  */
29
30
  httpPort: string | number | boolean;
31
+ /**
32
+ * [Https.ServerOptions](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener)):
33
+ * - `key` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | &lt;Object[]&gt;: The private key of the server in PEM format. To support multiple keys using different algorithms an array can be provided either as a plain array of key strings or an array of objects in the format `{pem: key, passphrase: passphrase}`. This option is required for ciphers that make use of private keys.
34
+ * - `passphrase` &lt;string&gt; A string containing the passphrase for the private key or pfx.
35
+ * - `cert` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | [&lt;Buffer[]&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer): A string, Buffer, array of strings, or array of Buffers containing the certificate key of the server in PEM format. (Required)
36
+ * - `ca` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | [&lt;Buffer[]&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer): A string, Buffer, array of strings, or array of Buffers of trusted certificates in PEM format. If this is omitted several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections.
37
+ */
38
+ httpOptions: Http.ServerOptions;
30
39
  /**
31
40
  * Port number for the [HTTPs.Server](https://nodejs.org/api/https.html#https_class_https_server).
32
41
  */