@tsed/common 6.88.0 → 6.91.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 (540) 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 +13 -26
  5. package/lib/cjs/builder/PlatformBuilder.js +268 -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 +0 -0
  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 +0 -0
  32. package/lib/cjs/config/services/PlatformConfiguration.js +195 -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 +0 -0
  38. package/lib/cjs/decorators/httpServer.js +31 -0
  39. package/lib/cjs/decorators/httpServer.js.map +1 -0
  40. package/lib/{decorators → cjs/decorators}/httpsServer.d.ts +0 -0
  41. package/lib/cjs/decorators/httpsServer.js +31 -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 +174 -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/{utils → cjs/utils}/createHttpServer.d.ts +0 -0
  233. package/lib/cjs/utils/createHttpServer.js +35 -0
  234. package/lib/cjs/utils/createHttpServer.js.map +1 -0
  235. package/lib/{utils → cjs/utils}/createHttpsServer.d.ts +0 -0
  236. package/lib/cjs/utils/createHttpsServer.js +36 -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 +42 -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/{utils → cjs/utils}/listenServer.d.ts +0 -0
  251. package/lib/cjs/utils/listenServer.js +17 -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 +264 -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 +192 -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 +27 -0
  293. package/lib/esm/decorators/httpServer.js.map +1 -0
  294. package/lib/esm/decorators/httpsServer.js +27 -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 +170 -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 +30 -0
  425. package/lib/esm/utils/createHttpsServer.js.map +1 -0
  426. package/lib/esm/utils/createInjector.js +38 -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 +13 -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 +103 -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 +88 -0
  456. package/lib/types/config/services/PlatformConfiguration.d.ts +85 -0
  457. package/lib/types/constants/routerOptions.d.ts +1 -0
  458. package/lib/types/decorators/httpServer.d.ts +27 -0
  459. package/lib/types/decorators/httpsServer.d.ts +27 -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 +3 -0
  524. package/lib/types/utils/createHttpsServer.d.ts +3 -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 +10 -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
@@ -1,3448 +0,0 @@
1
- import { $log, colorize } from '@tsed/logger';
2
- export { $log, Logger } from '@tsed/logger';
3
- import '@tsed/logger-file';
4
- import { DIConfiguration, Injectable, ProviderScope, Inject, InjectorService, Constant, Provider, ProviderType, GlobalProviders, Scope, DIContext, registerProvider, Configuration, setLoggerLevel, createContainer, colors, DITest } from '@tsed/di';
5
- export * from '@tsed/di';
6
- import { ParamTypes, PlatformParams, Context, UseParam, mapParamsOptions } from '@tsed/platform-params';
7
- export * from '@tsed/platform-params';
8
- export * from '@tsed/platform-exceptions';
9
- import { PlatformResponseFilter } from '@tsed/platform-response-filter';
10
- export * from '@tsed/platform-response-filter';
11
- export * from '@tsed/platform-cache';
12
- import { Middleware, getMiddlewaresForHook } from '@tsed/platform-middlewares';
13
- export * from '@tsed/platform-middlewares';
14
- import { importProviders } from '@tsed/components-scan';
15
- export * from '@tsed/components-scan';
16
- export * from '@tsed/platform-log-middleware';
17
- import { __decorate, __metadata, __param } from 'tslib';
18
- import { AnyToPromise, AnyToPromiseStatus, nameOf, Store, descriptorOf, prototypeOf, deepMerge, isFunction, DecoratorTypes, isStream, uniq, isBoolean, isNumber, isString, toMap, getValue, Env, StoreMerge, Metadata, useDecorators, useMethodDecorators, StoreSet, isClass } from '@tsed/core';
19
- import { Exception, NotAcceptable } from '@tsed/exceptions';
20
- import { JsonParameterStore, JsonMethodStore, JsonEntityStore, JsonEntityComponent, getOperationsRoutes, OperationMethods, JsonOperationRoute, JsonPropertyStore, getProperties, concatPath, Returns, Consumes, Produces, JsonEntityFn } from '@tsed/schema';
21
- export { All, Delete, Get, Head, Location, Options, Patch, Post, Put, Redirect } from '@tsed/schema';
22
- import { promisify } from 'util';
23
- import Https from 'https';
24
- import Http, { ServerResponse, IncomingMessage } from 'http';
25
-
26
- function _extends() {
27
- _extends = Object.assign || function (target) {
28
- for (var i = 1; i < arguments.length; i++) {
29
- var source = arguments[i];
30
-
31
- for (var key in source) {
32
- if (Object.prototype.hasOwnProperty.call(source, key)) {
33
- target[key] = source[key];
34
- }
35
- }
36
- }
37
-
38
- return target;
39
- };
40
-
41
- return _extends.apply(this, arguments);
42
- }
43
-
44
- function _objectWithoutPropertiesLoose(source, excluded) {
45
- if (source == null) return {};
46
- var target = {};
47
- var sourceKeys = Object.keys(source);
48
- var key, i;
49
-
50
- for (i = 0; i < sourceKeys.length; i++) {
51
- key = sourceKeys[i];
52
- if (excluded.indexOf(key) >= 0) continue;
53
- target[key] = source[key];
54
- }
55
-
56
- return target;
57
- }
58
-
59
- var id = 0;
60
-
61
- function _classPrivateFieldLooseKey(name) {
62
- return "__private_" + id++ + "_" + name;
63
- }
64
-
65
- function _classPrivateFieldLooseBase(receiver, privateKey) {
66
- if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
67
- throw new TypeError("attempted to use private field on non-instance");
68
- }
69
-
70
- return receiver;
71
- }
72
-
73
- var PlatformConfiguration_1;
74
- const rootDir = process.cwd();
75
- /**
76
- * `PlatformConfiguration` contains all information about your Server configuration.
77
- */
78
-
79
- let PlatformConfiguration = PlatformConfiguration_1 = class PlatformConfiguration extends DIConfiguration {
80
- constructor() {
81
- super({
82
- rootDir
83
- });
84
- }
85
-
86
- get version() {
87
- return this.getRaw("version");
88
- }
89
-
90
- set version(v) {
91
- this.setRaw("version", v);
92
- }
93
-
94
- get rootDir() {
95
- return this.getRaw("rootDir");
96
- }
97
-
98
- set rootDir(value) {
99
- this.setRaw("rootDir", value);
100
- }
101
-
102
- get port() {
103
- return this.httpPort;
104
- }
105
-
106
- set port(value) {
107
- this.httpPort = value;
108
- }
109
-
110
- get httpsOptions() {
111
- return this.getRaw("httpsOptions");
112
- }
113
-
114
- set httpsOptions(value) {
115
- this.setRaw("httpsOptions", value);
116
- }
117
-
118
- get httpPort() {
119
- return this.getRaw("httpPort");
120
- }
121
-
122
- set httpPort(value) {
123
- this.setRaw("httpPort", value);
124
- }
125
-
126
- get httpsPort() {
127
- return this.getRaw("httpsPort");
128
- }
129
-
130
- set httpsPort(value) {
131
- this.setRaw("httpsPort", value);
132
- }
133
-
134
- get env() {
135
- return this.getRaw("env");
136
- }
137
-
138
- set env(value) {
139
- this.setRaw("env", value);
140
- }
141
-
142
- get mount() {
143
- return this.get("mount");
144
- }
145
-
146
- set mount(value) {
147
- this.setRaw("mount", value);
148
- }
149
-
150
- get componentsScan() {
151
- return this.resolve(this.getRaw("componentsScan"));
152
- }
153
-
154
- set componentsScan(value) {
155
- this.setRaw("componentsScan", value);
156
- }
157
-
158
- get statics() {
159
- return this.getRaw("statics") || this.getRaw("serveStatic") || {};
160
- }
161
-
162
- set statics(value) {
163
- this.setRaw("statics", value);
164
- }
165
-
166
- get acceptMimes() {
167
- return this.getRaw("acceptMimes");
168
- }
169
-
170
- set acceptMimes(value) {
171
- this.setRaw("acceptMimes", value || []);
172
- }
173
-
174
- get debug() {
175
- return this.logger.level === "debug";
176
- }
177
-
178
- set debug(debug) {
179
- this.logger = _extends({}, this.logger, {
180
- level: debug ? "debug" : "info"
181
- });
182
- }
183
-
184
- get converter() {
185
- return this.get("converter") || {};
186
- }
187
-
188
- set converter(options) {
189
- this.setRaw("converter", options);
190
- }
191
-
192
- get logger() {
193
- return this.get("logger");
194
- }
195
-
196
- set logger(value) {
197
- const logger = _extends({}, this.logger, value);
198
-
199
- logger.debug = logger.level === "debug";
200
- this.setRaw("logger", logger);
201
- this.setRaw("debug", logger.debug);
202
-
203
- if (logger.format) {
204
- $log.appenders.set("stdout", {
205
- type: "stdout",
206
- levels: ["info", "debug"],
207
- layout: {
208
- type: "pattern",
209
- pattern: logger.format
210
- }
211
- });
212
- $log.appenders.set("stderr", {
213
- levels: ["trace", "fatal", "error", "warn"],
214
- type: "stderr",
215
- layout: {
216
- type: "pattern",
217
- pattern: logger.format
218
- }
219
- });
220
- }
221
- }
222
-
223
- get exclude() {
224
- return this.get("exclude");
225
- }
226
-
227
- set exclude(exclude) {
228
- this.setRaw("exclude", exclude);
229
- }
230
- /**
231
- *
232
- * @param addressPort
233
- * @returns {{address: string, port: number}}
234
- */
235
-
236
-
237
- static buildAddressAndPort(addressPort) {
238
- let address = "0.0.0.0";
239
- let port = addressPort;
240
-
241
- if (typeof addressPort === "string" && addressPort.indexOf(":") > -1) {
242
- [address, port] = addressPort.split(":");
243
- port = +port;
244
- }
245
-
246
- return {
247
- address,
248
- port: port
249
- };
250
- }
251
- /**
252
- *
253
- * @returns {string|number}
254
- */
255
-
256
-
257
- getHttpPort() {
258
- return PlatformConfiguration_1.buildAddressAndPort(this.getRaw("httpPort"));
259
- }
260
- /**
261
- *
262
- * @param settings
263
- */
264
-
265
-
266
- setHttpPort(settings) {
267
- this.setRaw("httpPort", `${settings.address}:${settings.port}`);
268
- }
269
- /**
270
- *
271
- * @returns {string|number}
272
- */
273
-
274
-
275
- getHttpsPort() {
276
- return PlatformConfiguration_1.buildAddressAndPort(this.getRaw("httpsPort"));
277
- }
278
- /**
279
- *
280
- * @param settings
281
- */
282
-
283
-
284
- setHttpsPort(settings) {
285
- this.setRaw("httpsPort", `${settings.address}:${settings.port}`);
286
- }
287
-
288
- getBestHost() {
289
- const {
290
- httpsPort,
291
- httpPort
292
- } = this;
293
-
294
- if (httpsPort) {
295
- const host = this.getHttpsPort();
296
- return _extends({
297
- protocol: "https"
298
- }, host);
299
- }
300
-
301
- if (httpPort) {
302
- const host = this.getHttpPort();
303
- return _extends({
304
- protocol: "http"
305
- }, host);
306
- }
307
- }
308
-
309
- };
310
- PlatformConfiguration = PlatformConfiguration_1 = __decorate([Injectable({
311
- scope: ProviderScope.SINGLETON,
312
- global: true
313
- }), __metadata("design:paramtypes", [])], PlatformConfiguration);
314
-
315
- /**
316
- * @ignore
317
- */
318
- function bindEndpointMiddleware(endpoint) {
319
- return ctx => {
320
- ctx.endpoint = endpoint;
321
- };
322
- }
323
-
324
- /**
325
- * @ignore
326
- */
327
- const createFakeRawDriver = () => {
328
- // istanbul ignore next
329
- function FakeRawDriver() {} // istanbul ignore next
330
-
331
-
332
- function use() {
333
- return this;
334
- }
335
-
336
- FakeRawDriver.use = use;
337
- FakeRawDriver.all = use;
338
- FakeRawDriver.get = use;
339
- FakeRawDriver.patch = use;
340
- FakeRawDriver.post = use;
341
- FakeRawDriver.put = use;
342
- FakeRawDriver.head = use;
343
- FakeRawDriver.delete = use;
344
- FakeRawDriver.options = use;
345
- return FakeRawDriver;
346
- };
347
-
348
- class AnyToPromiseWithCtx extends AnyToPromise {
349
- constructor({
350
- $ctx,
351
- err
352
- }) {
353
- super();
354
- this.$ctx = $ctx;
355
- this.err = err;
356
- }
357
-
358
- isDone() {
359
- const {
360
- $ctx
361
- } = this;
362
-
363
- if (!($ctx != null && $ctx.isDone())) {
364
- if ($ctx != null && $ctx.request.isAborted() || $ctx != null && $ctx.response.isDone()) {
365
- this.destroy();
366
-
367
- if (this.status === AnyToPromiseStatus.PENDING) {
368
- this.status = AnyToPromiseStatus.RESOLVED;
369
- }
370
- }
371
- }
372
-
373
- return super.isDone();
374
- }
375
-
376
- async call(cb) {
377
- return super.call(() => cb(this));
378
- }
379
-
380
- destroy() {
381
- // @ts-ignore
382
- delete this.$ctx;
383
- }
384
-
385
- isCanceledResponse(process) {
386
- return process === this.$ctx.getResponse();
387
- }
388
-
389
- }
390
-
391
- /**
392
- * @ignore
393
- */
394
- var HandlerType;
395
-
396
- (function (HandlerType) {
397
- HandlerType["CUSTOM"] = "custom";
398
- HandlerType["ENDPOINT"] = "endpoint";
399
- HandlerType["MIDDLEWARE"] = "middleware";
400
- HandlerType["ERR_MIDDLEWARE"] = "err:middleware";
401
- HandlerType["CTX_FN"] = "context";
402
- HandlerType["RAW_FN"] = "raw:middleware";
403
- HandlerType["RAW_ERR_FN"] = "raw:err:middleware";
404
- })(HandlerType || (HandlerType = {}));
405
-
406
- class HandlerMetadata {
407
- constructor(options) {
408
- this.injectable = false;
409
- this.type = HandlerType.RAW_FN;
410
- this.hasNextFunction = false;
411
- const {
412
- target,
413
- token,
414
- propertyKey,
415
- type,
416
- scope,
417
- routeOptions
418
- } = options;
419
- this.type = type || target.type || HandlerType.RAW_FN;
420
- this.scope = scope || ProviderScope.SINGLETON;
421
- this.routeOptions = routeOptions || {};
422
- const handler = propertyKey ? target.prototype[propertyKey] : target;
423
-
424
- if (propertyKey) {
425
- this.target = target;
426
- this.token = token;
427
- this.propertyKey = propertyKey;
428
- this.hasNextFunction = this.hasParamType(ParamTypes.NEXT_FN);
429
-
430
- if (this.hasParamType(ParamTypes.ERR)) {
431
- this.type = HandlerType.ERR_MIDDLEWARE;
432
- }
433
-
434
- this.injectable = JsonParameterStore.getParams(target, propertyKey).length > 0;
435
- } else {
436
- this.handler = handler;
437
- }
438
-
439
- if (!this.injectable) {
440
- if (handler.length === 4) {
441
- this.type = HandlerType.RAW_ERR_FN;
442
- }
443
-
444
- this.hasNextFunction = handler.length >= 3;
445
- }
446
- }
447
-
448
- get hasErrorParam() {
449
- return this.type === HandlerType.ERR_MIDDLEWARE || this.type === HandlerType.RAW_ERR_FN;
450
- }
451
-
452
- getParams() {
453
- return JsonParameterStore.getParams(this.target, this.propertyKey) || [];
454
- }
455
-
456
- hasParamType(paramType) {
457
- return this.getParams().findIndex(p => p.paramType === paramType) > -1;
458
- }
459
-
460
- isFinal() {
461
- var _this$routeOptions;
462
-
463
- return ((_this$routeOptions = this.routeOptions) == null ? void 0 : _this$routeOptions.isFinal) || false;
464
- }
465
-
466
- toString() {
467
- return [this.target && nameOf(this.target), this.propertyKey].filter(Boolean).join(".");
468
- }
469
-
470
- }
471
-
472
- /**
473
- * EndpointMetadata contains metadata about a controller and his method.
474
- * Each annotation (@Get, @Body...) attached to a method are stored in a endpoint.
475
- * EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.
476
- *
477
- * Example :
478
- *
479
- * @Controller("/my-path")
480
- * provide MyClass {
481
- *
482
- * @Get("/")
483
- * @Authenticated()
484
- * public myMethod(){}
485
- * }
486
- *
487
- */
488
-
489
- let EndpointMetadata = class EndpointMetadata extends JsonMethodStore {
490
- constructor(options) {
491
- super(_extends({
492
- store: Store.fromMethod(options.target, options.propertyKey),
493
- descriptor: descriptorOf(options.target, options.propertyKey)
494
- }, options));
495
- this.beforeMiddlewares = [];
496
- this.middlewares = [];
497
- this.afterMiddlewares = [];
498
- const {
499
- beforeMiddlewares = [],
500
- middlewares = [],
501
- afterMiddlewares = []
502
- } = options;
503
- this.after(afterMiddlewares);
504
- this.before(beforeMiddlewares);
505
- this.use(middlewares);
506
- }
507
-
508
- get targetName() {
509
- return nameOf(this.token);
510
- }
511
-
512
- get params() {
513
- return this.parameters;
514
- }
515
-
516
- get view() {
517
- return this.store.get("view");
518
- }
519
-
520
- set view(view) {
521
- this.store.set("view", view);
522
- }
523
-
524
- get acceptMimes() {
525
- return this.store.get("acceptMimes", []);
526
- }
527
-
528
- set acceptMimes(mimes) {
529
- this.store.set("acceptMimes", mimes);
530
- }
531
- /**
532
- * Get an endpoint.
533
- * @param target
534
- * @param propertyKey
535
- * @param descriptor
536
- */
537
-
538
-
539
- static get(target, propertyKey, descriptor) {
540
- descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);
541
- return JsonEntityStore.from(prototypeOf(target), propertyKey, descriptor);
542
- }
543
-
544
- addOperationPath(method, path, options = {}) {
545
- return this.operation.addOperationPath(method, path, options);
546
- }
547
- /**
548
- * Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.
549
- *
550
- * @param key
551
- * @returns {any}
552
- */
553
-
554
-
555
- get(key) {
556
- const ctrlValue = Store.from(this.target).get(key);
557
- return deepMerge(ctrlValue, this.store.get(key));
558
- }
559
- /**
560
- * Append middlewares to the beforeMiddlewares list.
561
- * @param args
562
- * @returns {EndpointMetadata}
563
- */
564
-
565
-
566
- before(args) {
567
- this.beforeMiddlewares = this.beforeMiddlewares.concat(args).filter(isFunction);
568
- return this;
569
- }
570
- /**
571
- * Append middlewares to the afterMiddlewares list.
572
- * @param args
573
- * @returns {EndpointMetadata}
574
- */
575
-
576
-
577
- after(args) {
578
- this.afterMiddlewares = this.afterMiddlewares.concat(args).filter(isFunction);
579
- return this;
580
- }
581
- /**
582
- * Store all arguments collected via Annotation.
583
- * @param args
584
- */
585
-
586
-
587
- use(args) {
588
- this.middlewares = this.middlewares.concat(args).filter(isFunction);
589
- return this;
590
- }
591
-
592
- };
593
- EndpointMetadata = __decorate([JsonEntityComponent(DecoratorTypes.METHOD), __metadata("design:paramtypes", [Object])], EndpointMetadata);
594
-
595
- function isMetadata(input) {
596
- return input instanceof HandlerMetadata;
597
- }
598
- /**
599
- * @ignore
600
- */
601
-
602
-
603
- function createHandlerMetadata(injector, obj, routeOptions = {}) {
604
- if (isMetadata(obj)) {
605
- return obj;
606
- }
607
-
608
- let options;
609
-
610
- if (obj instanceof EndpointMetadata) {
611
- const provider = injector.getProvider(routeOptions.token);
612
- options = {
613
- token: provider.token,
614
- target: provider.useClass,
615
- scope: provider.scope,
616
- type: HandlerType.ENDPOINT,
617
- propertyKey: obj.propertyKey
618
- };
619
- } else {
620
- const provider = injector.getProvider(obj);
621
-
622
- if (provider) {
623
- options = {
624
- token: provider.token,
625
- target: provider.useClass,
626
- scope: provider.scope,
627
- type: HandlerType.MIDDLEWARE,
628
- propertyKey: "use"
629
- };
630
- } else {
631
- options = {
632
- target: obj
633
- };
634
- }
635
- }
636
-
637
- options.routeOptions = routeOptions;
638
- return new HandlerMetadata(options);
639
- }
640
-
641
- function mergeHeaders(specHeaders, headers) {
642
- return Object.entries(specHeaders).reduce((headers, [key, item]) => {
643
- key = key.toLowerCase();
644
- return _extends({}, headers, {
645
- [key]: headers[key] === undefined ? String(item.example) : headers[key]
646
- });
647
- }, headers);
648
- }
649
- /**
650
- * @ignore
651
- */
652
-
653
-
654
- function setResponseHeaders(ctx) {
655
- const {
656
- response,
657
- endpoint
658
- } = ctx;
659
- const {
660
- operation
661
- } = endpoint;
662
-
663
- if (response.isDone()) {
664
- return;
665
- }
666
-
667
- if (!response.hasStatus()) {
668
- // apply status only if the isn't already modified
669
- response.status(operation.getStatus());
670
- }
671
-
672
- const statusCode = response.statusCode;
673
- const headers = operation.getHeadersOf(response.statusCode);
674
- const mergedHeaders = mergeHeaders(headers, response.getHeaders());
675
- response.setHeaders(mergedHeaders);
676
-
677
- if (operation.isRedirection(statusCode)) {
678
- response.redirect(statusCode, String(mergedHeaders["location"]));
679
- }
680
- }
681
-
682
- /**
683
- * Platform Handler abstraction layer. Wrap original class method to a pure platform handler (Express, Koa, etc...).
684
- * @platform
685
- */
686
-
687
- let PlatformHandler = class PlatformHandler {
688
- constructor(injector, params) {
689
- this.injector = injector;
690
- this.params = params;
691
- }
692
- /**
693
- * Create a native middleware based on the given metadata and return an instance of AnyToPromiseWithCtx
694
- * @param input
695
- * @param options
696
- */
697
-
698
-
699
- createHandler(input, options = {}) {
700
- return this.createRawHandler(createHandlerMetadata(this.injector, input, options));
701
- }
702
- /**
703
- * Create injectable handler from the given provider
704
- * @param provider
705
- * @param propertyKey
706
- */
707
-
708
-
709
- createCustomHandler(provider, propertyKey) {
710
- const handler = this.compileHandler(new HandlerMetadata({
711
- token: provider.provide,
712
- target: provider.useClass,
713
- type: HandlerType.CUSTOM,
714
- scope: provider.scope,
715
- propertyKey
716
- }));
717
- return async function ($ctx, next) {
718
- return handler({
719
- $ctx,
720
- next
721
- });
722
- };
723
- }
724
- /**
725
- * Send the response to the consumer.
726
- * @param data
727
- * @param ctx
728
- * @protected
729
- */
730
-
731
-
732
- async flush(data, ctx) {
733
- const {
734
- response
735
- } = ctx;
736
-
737
- if (!response.isDone()) {
738
- data = await this.responseFilter.serialize(data, ctx);
739
- data = await this.responseFilter.transform(data, ctx);
740
- response.body(data);
741
- }
742
- }
743
-
744
- compileHandler(metadata) {
745
- var _this = this;
746
-
747
- if (metadata.type === HandlerType.CTX_FN) {
748
- return async function (scope) {
749
- // @ts-ignore
750
- return _this.onCtxRequest(_extends({}, scope, {
751
- handler: () => metadata.handler(scope.$ctx),
752
- metadata
753
- }));
754
- };
755
- }
756
-
757
- const promise = this.params.compileHandler({
758
- token: metadata.token,
759
- propertyKey: metadata.propertyKey,
760
- getCustomArgs: metadata.injectable ? undefined : this.getDefaultArgs(metadata)
761
- });
762
- return async function (scope) {
763
- const handler = await promise; // @ts-ignore
764
-
765
- return _this.onRequest(_extends({}, scope, {
766
- handler,
767
- metadata
768
- }));
769
- };
770
- }
771
-
772
- async onCtxRequest(requestOptions) {
773
- await requestOptions.handler(requestOptions);
774
- return this.next(requestOptions);
775
- }
776
- /**
777
- * Call handler when a request his handle
778
- * @param requestOptions
779
- */
780
-
781
-
782
- async onRequest(requestOptions) {
783
- var _this2 = this;
784
-
785
- const {
786
- $ctx,
787
- metadata,
788
- err,
789
- handler
790
- } = requestOptions; // istanbul ignore next
791
-
792
- if (!$ctx) {
793
- $log.error({
794
- name: "HEADERS_SENT",
795
- message: `An endpoint is called but the response is already send to the client. The call comes from the handler: ${metadata.toString()}`
796
- });
797
- return;
798
- }
799
-
800
- const resolver = new AnyToPromiseWithCtx({
801
- $ctx,
802
- err
803
- });
804
- return this.injector.runInContext($ctx, async function () {
805
- try {
806
- const {
807
- state,
808
- data,
809
- status,
810
- headers
811
- } = await resolver.call(handler);
812
-
813
- if (state === AnyToPromiseStatus.RESOLVED) {
814
- if (status) {
815
- $ctx.response.status(status);
816
- }
817
-
818
- if (headers) {
819
- $ctx.response.setHeaders(headers);
820
- }
821
-
822
- if (data !== undefined) {
823
- $ctx.data = data;
824
- } // Can be canceled by the handler itself
825
-
826
-
827
- return await _this2.onSuccess($ctx.data, requestOptions);
828
- }
829
- } catch (er) {
830
- return _this2.onError(er, requestOptions);
831
- }
832
- });
833
- }
834
-
835
- async onError(er, requestOptions) {
836
- var _$ctx$response;
837
-
838
- const {
839
- next,
840
- $ctx,
841
- metadata
842
- } = requestOptions;
843
- $ctx.data = er;
844
-
845
- if (!next) {
846
- throw er;
847
- } // istanbul ignore next
848
-
849
-
850
- if (!($ctx != null && (_$ctx$response = $ctx.response) != null && _$ctx$response.isHeadersSent) || $ctx.response.isHeadersSent()) {
851
- $log.warn({
852
- name: "HEADERS_SENT",
853
- message: `An error was caught after the headers were sent to the client. The error comes from the handler: ${metadata.toString()}`,
854
- stack: er.stack,
855
- origin: er,
856
- request_id: $ctx.id
857
- });
858
- return;
859
- }
860
-
861
- return next && next(er);
862
- }
863
- /**
864
- * Manage success scenario
865
- * @param data
866
- * @param requestOptions
867
- * @protected
868
- */
869
-
870
-
871
- async onSuccess(data, requestOptions) {
872
- const {
873
- metadata,
874
- $ctx,
875
- next
876
- } = requestOptions; // TODO see this control is necessary
877
- // istanbul ignore next
878
-
879
- if ($ctx.request.isAborted() || $ctx.response.isDone()) {
880
- return;
881
- } // set headers each times that an endpoint is called
882
-
883
-
884
- if (metadata.type === HandlerType.ENDPOINT) {
885
- this.setHeaders($ctx);
886
- } // call returned middleware
887
-
888
-
889
- if (isFunction(data) && !isStream(data)) {
890
- return this.callReturnedMiddleware(data, $ctx, next);
891
- }
892
-
893
- if (metadata.isFinal()) {
894
- return this.flush(data, $ctx);
895
- }
896
-
897
- return this.next(requestOptions);
898
- }
899
- /**
900
- * Call the returned middleware by the handler.
901
- * @param middleware
902
- * @param ctx
903
- * @param next
904
- * @protected
905
- */
906
-
907
-
908
- callReturnedMiddleware(middleware, ctx, next) {
909
- return middleware(ctx.getRequest(), ctx.getResponse(), next);
910
- }
911
- /**
912
- * create Raw handler
913
- * @param metadata
914
- */
915
-
916
-
917
- createRawHandler(metadata) {
918
- if ([HandlerType.RAW_ERR_FN, HandlerType.RAW_FN].includes(metadata.type)) {
919
- return metadata.handler;
920
- }
921
-
922
- const handler = this.compileHandler(metadata);
923
- return async function (request, response, next) {
924
- return handler({
925
- next,
926
- $ctx: request.$ctx
927
- });
928
- };
929
- }
930
- /**
931
- * Set response headers
932
- * @param ctx
933
- * @protected
934
- */
935
-
936
-
937
- setHeaders(ctx) {
938
- return setResponseHeaders(ctx);
939
- }
940
-
941
- next(requestOptions) {
942
- const {
943
- $ctx,
944
- next
945
- } = requestOptions;
946
- return !$ctx.response.isDone() && next && next();
947
- }
948
-
949
- getDefaultArgs(metadata) {
950
- return async function (scope) {
951
- return [metadata.hasErrorParam && scope.err, scope.$ctx.request.request, scope.$ctx.response.response, metadata.hasNextFunction && scope.next].filter(Boolean);
952
- };
953
- }
954
-
955
- };
956
-
957
- __decorate([Inject(), __metadata("design:type", PlatformResponseFilter)], PlatformHandler.prototype, "responseFilter", void 0);
958
-
959
- PlatformHandler = __decorate([Injectable({
960
- scope: ProviderScope.SINGLETON
961
- }), __metadata("design:paramtypes", [InjectorService, PlatformParams])], PlatformHandler);
962
-
963
- const _excluded$3 = ["method", "path", "handlers"];
964
- var PlatformRouter_1;
965
- /**
966
- * @ignore
967
- */
968
-
969
- const PLATFORM_ROUTER_OPTIONS = Symbol.for("PlatformRouterOptions");
970
- /**
971
- * Platform Router abstraction layer.
972
- * @platform
973
- */
974
-
975
- let PlatformRouter = PlatformRouter_1 = class PlatformRouter {
976
- constructor(platformHandler) {
977
- this.platformHandler = platformHandler;
978
- this.isBuilt = false;
979
- this.rawRouter = this.raw = PlatformRouter_1.createRawRouter();
980
- }
981
- /**
982
- * Create a new instance of PlatformRouter
983
- * @param injector
984
- * @param routerOptions
985
- */
986
-
987
-
988
- static create(injector, routerOptions = {}) {
989
- const locals = new Map();
990
- locals.set(PLATFORM_ROUTER_OPTIONS, routerOptions);
991
- return injector.invoke(PlatformRouter_1, locals);
992
- }
993
-
994
- static createRawRouter() {
995
- return createFakeRawDriver();
996
- }
997
-
998
- callback() {
999
- return this.raw;
1000
- }
1001
-
1002
- getRouter() {
1003
- return this.rawRouter;
1004
- }
1005
-
1006
- use(...handlers) {
1007
- // @ts-ignore
1008
- this.getRouter().use(...this.mapHandlers(handlers));
1009
- return this;
1010
- }
1011
-
1012
- addRoute(options) {
1013
- const {
1014
- method,
1015
- path,
1016
- handlers
1017
- } = options,
1018
- opts = _objectWithoutPropertiesLoose(options, _excluded$3); // @ts-ignore
1019
-
1020
-
1021
- this.getRouter()[method](path, ...this.mapHandlers(handlers, _extends({
1022
- method,
1023
- path
1024
- }, opts)));
1025
- return this;
1026
- }
1027
-
1028
- all(path, ...handlers) {
1029
- return this.addRoute({
1030
- method: "all",
1031
- path,
1032
- handlers,
1033
- isFinal: true
1034
- });
1035
- }
1036
-
1037
- get(path, ...handlers) {
1038
- return this.addRoute({
1039
- method: "get",
1040
- path,
1041
- handlers,
1042
- isFinal: true
1043
- });
1044
- }
1045
-
1046
- post(path, ...handlers) {
1047
- return this.addRoute({
1048
- method: "post",
1049
- path,
1050
- handlers,
1051
- isFinal: true
1052
- });
1053
- }
1054
-
1055
- put(path, ...handlers) {
1056
- return this.addRoute({
1057
- method: "put",
1058
- path,
1059
- handlers,
1060
- isFinal: true
1061
- });
1062
- }
1063
-
1064
- delete(path, ...handlers) {
1065
- return this.addRoute({
1066
- method: "delete",
1067
- path,
1068
- handlers,
1069
- isFinal: true
1070
- });
1071
- }
1072
-
1073
- patch(path, ...handlers) {
1074
- return this.addRoute({
1075
- method: "patch",
1076
- path,
1077
- handlers,
1078
- isFinal: true
1079
- });
1080
- }
1081
-
1082
- head(path, ...handlers) {
1083
- return this.addRoute({
1084
- method: "head",
1085
- path,
1086
- handlers,
1087
- isFinal: true
1088
- });
1089
- }
1090
-
1091
- options(path, ...handlers) {
1092
- return this.addRoute({
1093
- method: "options",
1094
- path,
1095
- handlers,
1096
- isFinal: true
1097
- });
1098
- }
1099
-
1100
- statics(path, options) {
1101
- return this;
1102
- }
1103
-
1104
- multer(options) {
1105
- const m = require("multer")(options);
1106
-
1107
- const makePromise = (multer, name) => {
1108
- // istanbul ignore next
1109
- if (!multer[name]) return;
1110
- const fn = multer[name];
1111
-
1112
- multer[name] = function apply(...args) {
1113
- const middleware = Reflect.apply(fn, this, args);
1114
- return (req, res) => promisify(middleware)(req, res);
1115
- };
1116
- };
1117
-
1118
- makePromise(m, "any");
1119
- makePromise(m, "array");
1120
- makePromise(m, "fields");
1121
- makePromise(m, "none");
1122
- makePromise(m, "single");
1123
- return m;
1124
- }
1125
-
1126
- mapHandlers(handlers, options = {}) {
1127
- return handlers.reduce((list, handler, index) => {
1128
- if (typeof handler === "string") {
1129
- return list.concat(handler);
1130
- }
1131
-
1132
- if (handler instanceof PlatformRouter_1) {
1133
- return list.concat(handler.callback());
1134
- }
1135
-
1136
- return list.concat(this.platformHandler.createHandler(handler, _extends({}, options, {
1137
- isFinal: options.isFinal ? index === handlers.length - 1 : false
1138
- })));
1139
- }, []);
1140
- }
1141
-
1142
- };
1143
-
1144
- __decorate([Inject(), __metadata("design:type", InjectorService)], PlatformRouter.prototype, "injector", void 0);
1145
-
1146
- PlatformRouter = PlatformRouter_1 = __decorate([Injectable({
1147
- scope: ProviderScope.INSTANCE
1148
- }), __metadata("design:paramtypes", [PlatformHandler])], PlatformRouter);
1149
-
1150
- var PlatformApplication_1;
1151
- /**
1152
- * `PlatformApplication` is used to provide all routes collected by annotation `@Controller`.
1153
- *
1154
- * @platform
1155
- */
1156
-
1157
- let PlatformApplication = PlatformApplication_1 = class PlatformApplication extends PlatformRouter {
1158
- constructor(platformHandler) {
1159
- super(platformHandler);
1160
- this.rawApp = this.raw = PlatformApplication_1.createRawApp();
1161
- }
1162
-
1163
- static createRawApp() {
1164
- return createFakeRawDriver();
1165
- }
1166
-
1167
- getApp() {
1168
- return this.raw;
1169
- }
1170
-
1171
- };
1172
- PlatformApplication = PlatformApplication_1 = __decorate([Injectable({
1173
- scope: ProviderScope.SINGLETON
1174
- }), __metadata("design:paramtypes", [PlatformHandler])], PlatformApplication);
1175
-
1176
- var PlatformMulterMiddleware_1;
1177
- /**
1178
- * @middleware
1179
- */
1180
-
1181
- let PlatformMulterMiddleware = PlatformMulterMiddleware_1 = class PlatformMulterMiddleware {
1182
- async use(ctx) {
1183
- try {
1184
- const {
1185
- fields,
1186
- options = {}
1187
- } = ctx.endpoint.get(PlatformMulterMiddleware_1);
1188
-
1189
- const settings = _extends({}, this.settings, options);
1190
- /* istanbul ignore next */
1191
-
1192
-
1193
- if (settings.storage) {
1194
- delete settings.dest;
1195
- }
1196
-
1197
- const middleware = this.app.multer(settings).fields(this.getFields({
1198
- fields
1199
- }));
1200
- return await middleware(ctx.getRequest(), ctx.getResponse());
1201
- } catch (er) {
1202
- throw er.code ? new Exception(er.code, `${er.message} ${er.field || ""}`.trim()) : er;
1203
- }
1204
- }
1205
-
1206
- getFields(conf) {
1207
- return conf.fields.map(({
1208
- name,
1209
- maxCount
1210
- }) => ({
1211
- name,
1212
- maxCount
1213
- }));
1214
- }
1215
-
1216
- };
1217
-
1218
- __decorate([Constant("multer", {}), __metadata("design:type", Object)], PlatformMulterMiddleware.prototype, "settings", void 0);
1219
-
1220
- __decorate([Inject(), __metadata("design:type", PlatformApplication)], PlatformMulterMiddleware.prototype, "app", void 0);
1221
-
1222
- __decorate([__param(0, Context()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise)], PlatformMulterMiddleware.prototype, "use", null);
1223
-
1224
- PlatformMulterMiddleware = PlatformMulterMiddleware_1 = __decorate([Middleware()], PlatformMulterMiddleware);
1225
-
1226
- /**
1227
- * @deprecated Since 2020-11-30. Use PlatformAcceptMimesMiddleware.
1228
- * @ignore
1229
- */
1230
-
1231
- let GlobalAcceptMimesMiddleware = class GlobalAcceptMimesMiddleware {
1232
- use(ctx) {
1233
- return;
1234
- }
1235
-
1236
- };
1237
-
1238
- __decorate([__param(0, Context()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0)], GlobalAcceptMimesMiddleware.prototype, "use", null);
1239
-
1240
- GlobalAcceptMimesMiddleware = __decorate([Middleware()], GlobalAcceptMimesMiddleware);
1241
-
1242
- /**
1243
- * @middleware
1244
- * @platform
1245
- */
1246
-
1247
- let PlatformAcceptMimesMiddleware = class PlatformAcceptMimesMiddleware {
1248
- use(ctx) {
1249
- const {
1250
- endpoint,
1251
- request
1252
- } = ctx;
1253
- const mimes = uniq(((endpoint == null ? void 0 : endpoint.get("acceptMimes")) || []).concat(this.acceptMimes));
1254
-
1255
- if (mimes.length && !request.accepts(mimes)) {
1256
- throw new NotAcceptable(mimes.join(", "));
1257
- }
1258
- }
1259
-
1260
- };
1261
-
1262
- __decorate([Constant("acceptMimes", []), __metadata("design:type", Array)], PlatformAcceptMimesMiddleware.prototype, "acceptMimes", void 0);
1263
-
1264
- __decorate([__param(0, Context()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0)], PlatformAcceptMimesMiddleware.prototype, "use", null);
1265
-
1266
- PlatformAcceptMimesMiddleware = __decorate([Middleware()], PlatformAcceptMimesMiddleware);
1267
-
1268
- /**
1269
- * @middleware
1270
- * @deprecated Since 2020-11-30. Use PlatformAcceptMimesMiddleware.
1271
- * @ignore
1272
- */
1273
-
1274
- let AcceptMimesMiddleware = class AcceptMimesMiddleware {
1275
- use(ctx) {
1276
- return;
1277
- }
1278
-
1279
- };
1280
-
1281
- __decorate([__param(0, Context()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0)], AcceptMimesMiddleware.prototype, "use", null);
1282
-
1283
- AcceptMimesMiddleware = __decorate([Middleware()], AcceptMimesMiddleware);
1284
-
1285
- const ROUTER_OPTIONS = Symbol.for("ROUTER_OPTIONS");
1286
-
1287
- let AUTO_INC = 0;
1288
- class ControllerProvider extends Provider {
1289
- constructor(provide, options = {}) {
1290
- super(provide, options);
1291
- this.type = ProviderType.CONTROLLER;
1292
- this.tokenRouter = `${this.name}_ROUTER_${AUTO_INC++}`;
1293
- }
1294
- /**
1295
- *
1296
- */
1297
-
1298
-
1299
- get routerOptions() {
1300
- return this.store.get(ROUTER_OPTIONS) || {};
1301
- }
1302
- /**
1303
- *
1304
- * @param value
1305
- */
1306
-
1307
-
1308
- set routerOptions(value) {
1309
- this.store.set(ROUTER_OPTIONS, value);
1310
- }
1311
- /**
1312
- *
1313
- * @returns {any[]}
1314
- */
1315
-
1316
-
1317
- get middlewares() {
1318
- return Object.assign({
1319
- use: [],
1320
- useAfter: [],
1321
- useBefore: []
1322
- }, this.store.get("middlewares", {}));
1323
- }
1324
- /**
1325
- *
1326
- * @param middlewares
1327
- */
1328
-
1329
-
1330
- set middlewares(middlewares) {
1331
- const mdlwrs = this.middlewares;
1332
-
1333
- const concat = (key, a, b) => a[key] = a[key].concat(b[key]);
1334
-
1335
- Object.keys(middlewares).forEach(key => {
1336
- concat(key, mdlwrs, middlewares);
1337
- });
1338
- this.store.set("middlewares", mdlwrs);
1339
- }
1340
-
1341
- }
1342
-
1343
- /**
1344
- * Create Ts.ED context handler
1345
- * @param fn
1346
- * @ignore
1347
- */
1348
-
1349
- function useCtxHandler(fn) {
1350
- fn.type = HandlerType.CTX_FN;
1351
- return fn;
1352
- }
1353
-
1354
- let PlatformMiddlewaresChain = class PlatformMiddlewaresChain {
1355
- get(provider, operationRoute) {
1356
- const {
1357
- endpoint
1358
- } = operationRoute;
1359
- const {
1360
- beforeMiddlewares,
1361
- middlewares: mldwrs,
1362
- afterMiddlewares
1363
- } = endpoint;
1364
- const {
1365
- middlewares: {
1366
- use,
1367
- useAfter
1368
- }
1369
- } = provider;
1370
- const hasFiles = [...operationRoute.endpoint.children.values()].find(item => item.paramType === ParamTypes.FILES);
1371
- return [].concat(useCtxHandler(bindEndpointMiddleware(endpoint))).concat(PlatformAcceptMimesMiddleware).concat(hasFiles && PlatformMulterMiddleware).concat(beforeMiddlewares) // Endpoint before-middlewares
1372
- .concat(use) // Controller use-middlewares
1373
- .concat(mldwrs) // Endpoint middlewares
1374
- .concat(endpoint) // Endpoint metadata
1375
- .concat(afterMiddlewares) // Endpoint after-middlewares
1376
- .concat(useAfter) // Controller after middlewares (equivalent to afterEach)
1377
- .filter(item => !!item);
1378
- }
1379
-
1380
- };
1381
- PlatformMiddlewaresChain = __decorate([Injectable()], PlatformMiddlewaresChain);
1382
-
1383
- GlobalProviders.createRegistry(ProviderType.CONTROLLER, ControllerProvider, {
1384
- onInvoke(provider, locals, {
1385
- injector
1386
- }) {
1387
- const router = createRouter(injector, provider);
1388
- locals.set(PlatformRouter, router);
1389
- }
1390
-
1391
- });
1392
- /**
1393
- * @ignore
1394
- */
1395
-
1396
- function formatMethod(method) {
1397
- return (method === OperationMethods.CUSTOM ? "use" : method || "use").toLowerCase();
1398
- }
1399
- /**
1400
- * @ignore
1401
- */
1402
-
1403
-
1404
- function getRouter(injector, provider) {
1405
- return injector.get(provider.tokenRouter);
1406
- }
1407
- /**
1408
- * @ignore
1409
- */
1410
-
1411
- function createRouter(injector, provider) {
1412
- const token = provider.tokenRouter;
1413
-
1414
- if (injector.has(token)) {
1415
- return getRouter(injector, provider);
1416
- }
1417
-
1418
- const router = PlatformRouter.create(injector, provider.routerOptions);
1419
- return injector.add(token, {
1420
- useValue: router
1421
- }).invoke(token);
1422
- }
1423
- /**
1424
- * @ignore
1425
- * @param injector
1426
- * @param provider
1427
- */
1428
-
1429
- function buildRouter(injector, provider) {
1430
- const {
1431
- middlewares: {
1432
- useBefore
1433
- },
1434
- children
1435
- } = provider; // Controller lifecycle
1436
-
1437
- const router = createRouter(injector, provider);
1438
-
1439
- if (!router.isBuilt) {
1440
- router.isBuilt = true;
1441
- const platformMiddlewaresChain = injector.get(PlatformMiddlewaresChain);
1442
- useBefore // Controller before-middleware
1443
- .filter(o => typeof o === "function").forEach(middleware => {
1444
- router.use(middleware);
1445
- }); // build all endpoints and his middlewares
1446
-
1447
- getOperationsRoutes(provider.token).forEach(operationRoute => {
1448
- const handlers = platformMiddlewaresChain == null ? void 0 : platformMiddlewaresChain.get(provider, operationRoute);
1449
- router.addRoute({
1450
- handlers,
1451
- token: operationRoute.token,
1452
- method: formatMethod(operationRoute.method),
1453
- path: operationRoute.path,
1454
- isFinal: operationRoute.isFinal
1455
- });
1456
- }); // build children controllers
1457
-
1458
- children.forEach(child => {
1459
- const childProvider = injector.getProvider(child);
1460
- /* istanbul ignore next */
1461
-
1462
- if (!childProvider) {
1463
- throw new Error("Controller component not found in the ControllerRegistry");
1464
- }
1465
-
1466
- router.use(childProvider.path, buildRouter(injector, childProvider));
1467
- });
1468
- }
1469
-
1470
- return router;
1471
- }
1472
-
1473
- /**
1474
- * Platform Request abstraction layer.
1475
- * @platform
1476
- */
1477
-
1478
- let PlatformRequest = class PlatformRequest {
1479
- constructor({
1480
- request
1481
- }, $ctx) {
1482
- this.$ctx = $ctx;
1483
- this.raw = request;
1484
- }
1485
-
1486
- get secure() {
1487
- return this.raw.secure;
1488
- }
1489
-
1490
- get host() {
1491
- return this.get("host");
1492
- }
1493
-
1494
- get protocol() {
1495
- return this.raw.protocol;
1496
- }
1497
- /**
1498
- * Get the url of the request.
1499
- *
1500
- * Is equivalent of `express.response.originalUrl || express.response.url`.
1501
- */
1502
-
1503
-
1504
- get url() {
1505
- return this.raw.originalUrl || this.raw.url;
1506
- }
1507
-
1508
- get headers() {
1509
- return this.raw.headers;
1510
- }
1511
-
1512
- get method() {
1513
- return this.raw.method;
1514
- }
1515
- /**
1516
- * Contains key-value pairs of data submitted in the request body. By default, it is `undefined`, and is populated when you use
1517
- * `body-parsing` middleware such as `express.json()` or `express.urlencoded()`.
1518
- */
1519
-
1520
-
1521
- get body() {
1522
- return this.raw.body;
1523
- }
1524
-
1525
- get rawBody() {
1526
- return this.raw.rawBody || this.raw.body;
1527
- }
1528
- /**
1529
- * When using `cookie-parser` middleware, this property is an object that contains cookies sent by the request.
1530
- * If the request contains no cookies, it defaults to `{}`.
1531
- */
1532
-
1533
-
1534
- get cookies() {
1535
- return this.raw.cookies;
1536
- }
1537
- /**
1538
- * This property is an object containing properties mapped to the named route `parameters`.
1539
- * For example, if you have the route `/user/:name`, then the `name` property is available as `req.params.name`.
1540
- * This object defaults to `{}`.
1541
- */
1542
-
1543
-
1544
- get params() {
1545
- return this.raw.params;
1546
- }
1547
- /**
1548
- * This property is an object containing a property for each query string parameter in the route.
1549
- * When query parser is set to disabled, it is an empty object `{}`, otherwise it is the result of the configured query parser.
1550
- */
1551
-
1552
-
1553
- get query() {
1554
- return this.raw.query;
1555
- }
1556
- /**
1557
- * This property is an object containing a property for each session attributes set by any code.
1558
- * It require to install a middleware like express-session to work.
1559
- */
1560
-
1561
-
1562
- get session() {
1563
- return this.raw.session;
1564
- }
1565
-
1566
- get files() {
1567
- return this.raw.files;
1568
- }
1569
- /**
1570
- * Return the original request framework instance
1571
- */
1572
-
1573
-
1574
- get request() {
1575
- return this.getRequest();
1576
- }
1577
- /**
1578
- * Return the original request node.js instance
1579
- */
1580
-
1581
-
1582
- get req() {
1583
- return this.getReq();
1584
- }
1585
- /**
1586
- * Returns the HTTP request header specified by field. The match is case-insensitive.
1587
- *
1588
- * ```typescript
1589
- * request.get('Content-Type') // => "text/plain"
1590
- * ```
1591
- *
1592
- * @param name
1593
- */
1594
-
1595
-
1596
- get(name) {
1597
- return this.raw.get(name);
1598
- }
1599
-
1600
- accepts(mime) {
1601
- // @ts-ignore
1602
- return this.raw.accepts(mime);
1603
- }
1604
-
1605
- isAborted() {
1606
- return this.raw.aborted;
1607
- }
1608
-
1609
- destroy() {
1610
- // @ts-ignore
1611
- delete this.raw; // @ts-ignore
1612
-
1613
- delete this.response; // @ts-ignore
1614
-
1615
- delete this.$ctx;
1616
- }
1617
- /**
1618
- * Return the Framework response object (express, koa, etc...)
1619
- */
1620
-
1621
-
1622
- getRequest() {
1623
- return this.raw;
1624
- }
1625
- /**
1626
- * Return the Node.js response object
1627
- */
1628
-
1629
-
1630
- getReq() {
1631
- return this.raw;
1632
- }
1633
-
1634
- };
1635
- PlatformRequest = __decorate([Injectable(), Scope(ProviderScope.INSTANCE), __metadata("design:paramtypes", [Object, Function])], PlatformRequest);
1636
-
1637
- var PlatformResponse_1;
1638
-
1639
- const onFinished = require("on-finished");
1640
- /**
1641
- * Platform Response abstraction layer.
1642
- * @platform
1643
- */
1644
-
1645
-
1646
- let PlatformResponse = PlatformResponse_1 = class PlatformResponse {
1647
- constructor({
1648
- response
1649
- }, $ctx) {
1650
- this.$ctx = $ctx;
1651
- this.raw = response;
1652
- }
1653
- /**
1654
- * Get the current statusCode
1655
- */
1656
-
1657
-
1658
- get statusCode() {
1659
- return this.raw.statusCode;
1660
- }
1661
- /**
1662
- * An object that contains response local variables scoped to the request, and therefore available only to the view(s) rendered during that request / response cycle (if any). Otherwise, this property is identical to app.locals.
1663
- *
1664
- * This property is useful for exposing request-level information such as the request path name, authenticated user, user settings, and so on.
1665
- */
1666
-
1667
-
1668
- get locals() {
1669
- return this.raw.locals;
1670
- }
1671
- /**
1672
- * Return the original response framework instance
1673
- */
1674
-
1675
-
1676
- get response() {
1677
- return this.getResponse();
1678
- }
1679
- /**
1680
- * Return the original response node.js instance
1681
- */
1682
-
1683
-
1684
- get res() {
1685
- return this.getRes();
1686
- }
1687
-
1688
- static onFinished(res, cb) {
1689
- onFinished(res, cb);
1690
- }
1691
- /**
1692
- * Returns the HTTP response header specified by field. The match is case-insensitive.
1693
- *
1694
- * ```typescript
1695
- * response.get('Content-Type') // => "text/plain"
1696
- * ```
1697
- *
1698
- * @param name
1699
- */
1700
-
1701
-
1702
- get(name) {
1703
- return this.raw.get(name);
1704
- }
1705
-
1706
- getHeaders() {
1707
- return this.raw.getHeaders();
1708
- }
1709
- /**
1710
- * Return the Framework response object (express, koa, etc...)
1711
- */
1712
-
1713
-
1714
- getResponse() {
1715
- return this.raw;
1716
- }
1717
- /**
1718
- * Return the Node.js response object
1719
- */
1720
-
1721
-
1722
- getRes() {
1723
- return this.raw;
1724
- }
1725
-
1726
- hasStatus() {
1727
- return this.statusCode !== 200;
1728
- }
1729
- /**
1730
- * Sets the HTTP status for the response.
1731
- *
1732
- * @param status
1733
- */
1734
-
1735
-
1736
- status(status) {
1737
- this.raw.status(status);
1738
- return this;
1739
- }
1740
- /**
1741
- * Set header `field` to `val`, or pass
1742
- * an object of header fields.
1743
- *
1744
- * Examples:
1745
- * ```typescript
1746
- * response.setHeaders({ Accept: 'text/plain', 'X-API-Key': 'tobi' });
1747
- * ```
1748
- *
1749
- * Aliased as `res.header()`.
1750
- */
1751
-
1752
-
1753
- setHeaders(headers) {
1754
- // apply headers
1755
- Object.entries(headers).forEach(([key, item]) => {
1756
- this.setHeader(key, item);
1757
- });
1758
- return this;
1759
- }
1760
-
1761
- setHeader(key, item) {
1762
- if (key.toLowerCase() === "location") {
1763
- return this.location(String(item));
1764
- }
1765
-
1766
- this.raw.set(key, item);
1767
- return this;
1768
- }
1769
- /**
1770
- * Set `Content-Type` response header with `type` through `mime.lookup()`
1771
- * when it does not contain "/", or set the Content-Type to `type` otherwise.
1772
- *
1773
- * Examples:
1774
- *
1775
- * res.type('.html');
1776
- * res.type('html');
1777
- * res.type('json');
1778
- * res.type('application/json');
1779
- * res.type('png');
1780
- */
1781
-
1782
-
1783
- contentType(contentType) {
1784
- this.raw.contentType(contentType);
1785
- return this;
1786
- }
1787
-
1788
- contentLength(length) {
1789
- this.setHeader("Content-Length", length);
1790
- return this;
1791
- }
1792
-
1793
- getContentLength() {
1794
- if (this.get("Content-Length")) {
1795
- return parseInt(this.get("Content-Length"), 10) || 0;
1796
- }
1797
- }
1798
-
1799
- getContentType() {
1800
- return (this.get("Content-Type") || "").split(";")[0];
1801
- }
1802
- /**
1803
- * Sets the HTTP response Content-Disposition header field to “attachment”.
1804
- * If a filename is given, then it sets the Content-Type based on the extension name via res.type(), and sets the Content-Disposition “filename=” parameter.
1805
- *
1806
- * ```typescript
1807
- * res.attachment()
1808
- * // Content-Disposition: attachment
1809
- *
1810
- * res.attachment('path/to/logo.png')
1811
- * // Content-Disposition: attachment; filename="logo.png"
1812
- * // Content-Type: image/png
1813
- * ```
1814
- *
1815
- * @param filename
1816
- */
1817
-
1818
-
1819
- attachment(filename) {
1820
- this.raw.attachment(filename);
1821
- return this;
1822
- }
1823
- /**
1824
- * Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an [HTTP status code](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
1825
- * If not specified, status defaults to `302 Found`.
1826
- *
1827
- * @param status
1828
- * @param url
1829
- */
1830
-
1831
-
1832
- redirect(status, url) {
1833
- this.raw.redirect(status, url);
1834
- return this;
1835
- }
1836
- /**
1837
- * Sets the response Location HTTP header to the specified path parameter.
1838
- *
1839
- * @param location
1840
- */
1841
-
1842
-
1843
- location(location) {
1844
- this.raw.location(location);
1845
- return this;
1846
- }
1847
- /**
1848
- * Stream the given data.
1849
- *
1850
- * @param data
1851
- */
1852
-
1853
-
1854
- stream(data) {
1855
- data.pipe(this.raw);
1856
- return this;
1857
- }
1858
- /**
1859
- * Renders a view and sends the rendered HTML string to the client.
1860
- *
1861
- * @param path
1862
- * @param options
1863
- */
1864
-
1865
-
1866
- async render(path, options = {}) {
1867
- const {
1868
- PlatformViews
1869
- } = await import('@tsed/platform-views');
1870
- const platformViews = await this.$ctx.injector.lazyInvoke(PlatformViews);
1871
- return platformViews.render(path, _extends({}, this.locals, options));
1872
- }
1873
- /**
1874
- * Send any data to your consumer.
1875
- *
1876
- * This method accept a ReadableStream, a plain object, boolean, string, number, null and undefined data.
1877
- * It choose the better way to send the data.
1878
- *
1879
- * @param data
1880
- */
1881
-
1882
-
1883
- body(data) {
1884
- this.data = data;
1885
-
1886
- if (data === undefined) {
1887
- this.raw.send();
1888
- return this;
1889
- }
1890
-
1891
- if (isStream(data)) {
1892
- this.stream(data);
1893
- return this;
1894
- }
1895
-
1896
- if (Buffer.isBuffer(data)) {
1897
- if (!this.getContentType()) {
1898
- this.contentType("application/octet-stream");
1899
- }
1900
-
1901
- this.contentLength(data.length);
1902
- this.raw.send(data);
1903
- return this;
1904
- }
1905
-
1906
- if (isBoolean(data) || isNumber(data) || isString(data) || data === null) {
1907
- this.raw.send(data);
1908
- return this;
1909
- }
1910
-
1911
- this.raw.json(data);
1912
- return this;
1913
- }
1914
-
1915
- getBody() {
1916
- return this.data;
1917
- }
1918
- /**
1919
- * Add a listener to handler the end of the request/response.
1920
- * @param cb
1921
- */
1922
-
1923
-
1924
- onEnd(cb) {
1925
- PlatformResponse_1.onFinished(this.getRes(), cb);
1926
- return this;
1927
- }
1928
-
1929
- isDone() {
1930
- if (!this.raw) {
1931
- return true;
1932
- }
1933
-
1934
- const res = this.getRes();
1935
- return Boolean(this.isHeadersSent() || res.writableEnded || res.writableFinished);
1936
- }
1937
-
1938
- destroy() {
1939
- // @ts-ignore
1940
- delete this.raw;
1941
- delete this.data; // @ts-ignore
1942
-
1943
- delete this.request; // @ts-ignore
1944
-
1945
- delete this.$ctx;
1946
- }
1947
-
1948
- isHeadersSent() {
1949
- return this.getRes().headersSent;
1950
- }
1951
-
1952
- };
1953
- PlatformResponse = PlatformResponse_1 = __decorate([Injectable(), Scope(ProviderScope.INSTANCE), __metadata("design:paramtypes", [Object, Function])], PlatformResponse);
1954
-
1955
- const _excluded$2 = ["event", "endpoint", "ignoreUrlPatterns", "ResponseKlass", "RequestKlass"];
1956
- class PlatformContext extends DIContext {
1957
- constructor(_ref) {
1958
- let {
1959
- event,
1960
- endpoint,
1961
- ignoreUrlPatterns = [],
1962
- ResponseKlass = PlatformResponse,
1963
- RequestKlass = PlatformRequest
1964
- } = _ref,
1965
- options = _objectWithoutPropertiesLoose(_ref, _excluded$2);
1966
-
1967
- super(_extends({}, options, {
1968
- ignoreLog: () => {
1969
- return this.ignoreUrlPatterns.find(reg => !!this.url.match(reg));
1970
- }
1971
- }));
1972
- this.ignoreUrlPatterns = [];
1973
- endpoint && (this.endpoint = endpoint);
1974
- this.ignoreUrlPatterns = ignoreUrlPatterns.map(pattern => typeof pattern === "string" ? new RegExp(pattern, "gi") : pattern);
1975
- this.response = new ResponseKlass(event, this);
1976
- this.request = new RequestKlass(event, this);
1977
- this.response.request = this.request;
1978
- this.request.response = this.response;
1979
- this.request.request.$ctx = this;
1980
- this.request.request.id = this.id;
1981
- this.logger.url = this.url;
1982
- this.container.set(PlatformResponse, this.response);
1983
- this.container.set(PlatformRequest, this.request);
1984
- this.container.set(PlatformContext, this);
1985
- this.response.setHeader("x-request-id", this.id);
1986
- }
1987
-
1988
- get url() {
1989
- return this.request.url;
1990
- }
1991
-
1992
- get app() {
1993
- return this.injector.get(PlatformApplication);
1994
- }
1995
-
1996
- async destroy() {
1997
- var _this$request, _this$request$request;
1998
-
1999
- await super.destroy();
2000
- (_this$request = this.request) == null ? true : (_this$request$request = _this$request.request) == null ? true : delete _this$request$request.$ctx;
2001
- this.response.destroy();
2002
- this.request.destroy(); // @ts-ignore
2003
-
2004
- delete this.endpoint; // @ts-ignore
2005
-
2006
- delete this.response; // @ts-ignore
2007
-
2008
- delete this.request;
2009
- }
2010
-
2011
- isDone() {
2012
- return !this.request || !this.response;
2013
- }
2014
- /**
2015
- * Return the framework request instance (Express, Koa, etc...)
2016
- */
2017
-
2018
-
2019
- getRequest() {
2020
- return this.request.getRequest();
2021
- }
2022
- /**
2023
- * Return the framework response instance (Express, Koa, etc...)
2024
- */
2025
-
2026
-
2027
- getResponse() {
2028
- return this.response.getResponse();
2029
- }
2030
- /**
2031
- * Get Node.js request
2032
- */
2033
-
2034
-
2035
- getReq() {
2036
- return this.request.getReq();
2037
- }
2038
- /**
2039
- * Get Node.js response
2040
- */
2041
-
2042
-
2043
- getRes() {
2044
- return this.response.getRes();
2045
- }
2046
- /**
2047
- * Return the original application instance.
2048
- */
2049
-
2050
-
2051
- getApp() {
2052
- return this.app.getApp();
2053
- }
2054
-
2055
- }
2056
-
2057
- class PlatformRouteDetails extends JsonOperationRoute {
2058
- constructor(options = {}) {
2059
- super(options);
2060
- this.rawBody = !!this.endpoint.parameters.find(param => param.paramType === ParamTypes.RAW_BODY);
2061
- }
2062
-
2063
- toJSON() {
2064
- return {
2065
- method: this.method,
2066
- name: this.name,
2067
- url: this.url,
2068
- className: this.className,
2069
- methodClassName: this.methodClassName,
2070
- parameters: this.parameters,
2071
- rawBody: this.rawBody
2072
- };
2073
- }
2074
-
2075
- }
2076
-
2077
- /**
2078
- * @deprecated Since 2020-11-11. Use getProperties from @tsed/schema
2079
- */
2080
-
2081
- let PropertyMetadata = class PropertyMetadata extends JsonPropertyStore {
2082
- /**
2083
- * @deprecated Since 2020-11-11. Use getProperties from @tsed/schema
2084
- */
2085
- static get(target, propertyKey) {
2086
- return JsonEntityStore.from(prototypeOf(target), propertyKey);
2087
- }
2088
- /**
2089
- * @deprecated Since 2020-11-11. Use getProperties from @tsed/schema
2090
- */
2091
-
2092
-
2093
- static getProperties(target, options = {}) {
2094
- return getProperties(target, options);
2095
- }
2096
-
2097
- };
2098
- PropertyMetadata = __decorate([JsonEntityComponent(DecoratorTypes.PROP)], PropertyMetadata);
2099
-
2100
- /**
2101
- * `Platform` is used to provide all routes collected by annotation `@Controller`.
2102
- *
2103
- * @platform
2104
- */
2105
-
2106
- let Platform = class Platform {
2107
- constructor(injector, platformApplication) {
2108
- this.injector = injector;
2109
- this.platformApplication = platformApplication;
2110
- this._routes = [];
2111
- this._controllers = [];
2112
- this.createRouters();
2113
- }
2114
-
2115
- get app() {
2116
- return this.platformApplication;
2117
- }
2118
-
2119
- get routes() {
2120
- return this._routes;
2121
- }
2122
-
2123
- addRoutes(routes) {
2124
- routes.forEach(routeSettings => {
2125
- this.addRoute(routeSettings.route, routeSettings.token);
2126
- });
2127
- }
2128
-
2129
- addRoute(basePath, token) {
2130
- const {
2131
- injector
2132
- } = this;
2133
- const provider = injector.getProvider(token);
2134
-
2135
- if (!provider || provider.hasParent()) {
2136
- return;
2137
- }
2138
-
2139
- const ctrlPath = concatPath(basePath, JsonEntityStore.from(provider.token).path);
2140
-
2141
- this._controllers.push({
2142
- route: ctrlPath,
2143
- provider
2144
- });
2145
-
2146
- this.app.use(ctrlPath, ...[].concat(getRouter(injector, provider).callback()));
2147
- this._routes = getOperationsRoutes(provider.token, {
2148
- withChildren: true,
2149
- basePath
2150
- }).reduce((routes, operationRoute) => {
2151
- if (injector.hasProvider(token)) {
2152
- const provider = injector.getProvider(operationRoute.token);
2153
- const route = new PlatformRouteDetails(_extends({}, operationRoute, {
2154
- provider
2155
- }));
2156
- return routes.concat(route);
2157
- }
2158
-
2159
- return routes;
2160
- }, this._routes);
2161
- return this;
2162
- }
2163
- /**
2164
- * Get all routes built by TsExpressDecorators and mounted on Express application.
2165
- * @returns {PlatformRouteDetails[]}
2166
- */
2167
-
2168
-
2169
- getRoutes() {
2170
- return this._routes;
2171
- }
2172
-
2173
- getMountedControllers() {
2174
- return this._controllers;
2175
- }
2176
-
2177
- $onInit() {
2178
- this.buildControllers();
2179
- }
2180
- /**
2181
- * Create routers from the collected controllers.
2182
- * @private
2183
- */
2184
-
2185
-
2186
- createRouters() {
2187
- const {
2188
- injector
2189
- } = this;
2190
- injector.getProviders(ProviderType.CONTROLLER).map(provider => {
2191
- createRouter(injector, provider);
2192
- });
2193
- }
2194
- /**
2195
- * Create controllers from DI
2196
- * @private
2197
- */
2198
-
2199
-
2200
- buildControllers() {
2201
- const {
2202
- injector
2203
- } = this;
2204
- injector.getProviders(ProviderType.CONTROLLER).map(provider => {
2205
- if (!provider.hasParent()) {
2206
- return buildRouter(injector, provider);
2207
- }
2208
- });
2209
- }
2210
-
2211
- };
2212
- Platform = __decorate([Injectable({
2213
- scope: ProviderScope.SINGLETON,
2214
- imports: [PlatformMiddlewaresChain]
2215
- }), __metadata("design:paramtypes", [InjectorService, PlatformApplication])], Platform);
2216
-
2217
- /**
2218
- * Inject the Https.Server instance.
2219
- *
2220
- * ### Example
2221
- *
2222
- * ```typescript
2223
- * import {HttpsServer, Service} from "@tsed/common";
2224
- *
2225
- * @Service()
2226
- * export default class OtherService {
2227
- * constructor(@HttpsServer httpServer: HttpServer) {}
2228
- * }
2229
- * ```
2230
- *
2231
- * > Note: TypeScript transform and store `HttpsServer` as `Function` type in the metadata. So to inject a factory, you must use the `@Inject(type)` decorator.
2232
- *
2233
- * @param {Type<any>} target
2234
- * @param {string} targetKey
2235
- * @param {TypedPropertyDescriptor<Function> | number} descriptor
2236
- * @returns {any}
2237
- * @decorator
2238
- */
2239
-
2240
- function HttpsServer(target, targetKey, descriptor) {
2241
- return Inject(HttpsServer)(target, targetKey, descriptor);
2242
- }
2243
-
2244
- function listenServer(http, settings) {
2245
- const {
2246
- address,
2247
- port
2248
- } = settings;
2249
- const promise = new Promise((resolve, reject) => {
2250
- http.on("listening", resolve);
2251
- http.on("error", reject);
2252
- }).then(() => {
2253
- const port = http.address().port;
2254
- return {
2255
- address: settings.address,
2256
- port
2257
- };
2258
- });
2259
- http.listen(port, address);
2260
- return promise;
2261
- }
2262
-
2263
- function createHttpsServer(injector) {
2264
- injector.invoke(HttpsServer);
2265
- }
2266
- registerProvider({
2267
- provide: HttpsServer,
2268
- deps: [PlatformApplication, Configuration],
2269
- scope: ProviderScope.SINGLETON,
2270
- global: true,
2271
-
2272
- useFactory(platformApplication, settings) {
2273
- const options = settings.httpsOptions;
2274
- return Https.createServer(options, platformApplication.callback());
2275
- }
2276
-
2277
- });
2278
- async function listenHttpsServer(injector) {
2279
- const {
2280
- settings
2281
- } = injector;
2282
- const server = injector.get(HttpsServer);
2283
-
2284
- if (settings.httpsPort !== false && server) {
2285
- const {
2286
- address,
2287
- port
2288
- } = settings.getHttpsPort();
2289
- injector.logger.debug(`Start server on https://${address}:${port}`);
2290
- const options = await listenServer(server, {
2291
- address,
2292
- port
2293
- });
2294
- settings.setHttpsPort(options);
2295
- injector.logger.info(`Listen server on https://${options.address}:${options.port}`);
2296
- }
2297
- }
2298
-
2299
- /**
2300
- * Inject the Http.Server instance.
2301
- *
2302
- * ### Example
2303
- *
2304
- * ```typescript
2305
- * import {HttpServer, Service} from "@tsed/common";
2306
- *
2307
- * @Service()
2308
- * export default class OtherService {
2309
- * constructor(@HttpServer httpServer: HttpServer) {}
2310
- * }
2311
- * ```
2312
- *
2313
- * > Note: TypeScript transform and store `HttpServer` as `Function` type in the metadata. So to inject a factory, you must use the `@Inject(type)` decorator.
2314
- *
2315
- * @param {Type<any>} target
2316
- * @param {string} targetKey
2317
- * @param {TypedPropertyDescriptor<Function> | number} descriptor
2318
- * @returns {any}
2319
- * @decorator
2320
- */
2321
-
2322
- function HttpServer(target, targetKey, descriptor) {
2323
- return Inject(HttpServer)(target, targetKey, descriptor);
2324
- }
2325
-
2326
- function createHttpServer(injector) {
2327
- injector.invoke(HttpServer);
2328
- }
2329
- registerProvider({
2330
- provide: HttpServer,
2331
- deps: [PlatformApplication],
2332
- scope: ProviderScope.SINGLETON,
2333
- global: true,
2334
-
2335
- useFactory(platformApplication) {
2336
- return Http.createServer(platformApplication.callback());
2337
- }
2338
-
2339
- });
2340
- async function listenHttpServer(injector) {
2341
- const {
2342
- settings
2343
- } = injector;
2344
- const server = injector.get(HttpServer);
2345
-
2346
- if (settings.httpPort !== false && server) {
2347
- const {
2348
- address,
2349
- port
2350
- } = settings.getHttpPort();
2351
- injector.logger.debug(`Start server on http://${address}:${port}`);
2352
- const options = await listenServer(server, {
2353
- address,
2354
- port
2355
- });
2356
- settings.setHttpPort(options);
2357
- injector.logger.info(`Listen server on http://${options.address}:${options.port}`);
2358
- }
2359
- }
2360
-
2361
- $log.name = "TSED";
2362
- const DEFAULT_PROVIDERS = [{
2363
- provide: PlatformHandler
2364
- }, {
2365
- provide: PlatformResponse
2366
- }, {
2367
- provide: PlatformRequest
2368
- }, {
2369
- provide: PlatformRouter
2370
- }, {
2371
- provide: PlatformApplication
2372
- }, {
2373
- provide: Platform
2374
- }];
2375
- function createInjector({
2376
- providers = [],
2377
- settings = {}
2378
- }) {
2379
- const injector = new InjectorService();
2380
- injector.addProvider(PlatformConfiguration);
2381
- injector.settings = injector.invoke(PlatformConfiguration);
2382
- injector.logger = $log;
2383
- injector.settings.set(settings);
2384
- setLoggerLevel(injector);
2385
- providers = [...DEFAULT_PROVIDERS, ...providers];
2386
- toMap(providers, "provide").forEach((provider, token) => {
2387
- injector.addProvider(token, provider);
2388
- });
2389
- injector.invoke(PlatformApplication);
2390
- createHttpsServer(injector);
2391
- createHttpServer(injector);
2392
- return injector;
2393
- }
2394
-
2395
- /**
2396
- * @ignore
2397
- * @deprecated User injector.load(container, module) instead
2398
- */
2399
-
2400
- async function loadInjector(injector, container = createContainer()) {
2401
- injector.bootstrap(container);
2402
- return injector.load(container);
2403
- }
2404
-
2405
- function printRoutes(routes) {
2406
- const mapColor = {
2407
- GET: "green",
2408
- POST: "yellow",
2409
- PUT: "blue",
2410
- DELETE: "red",
2411
- PATCH: "magenta",
2412
- ALL: "cyan"
2413
- };
2414
- const list = routes.map(route => {
2415
- const obj = route.toJSON();
2416
- const method = obj.method.toUpperCase();
2417
- obj.method = {
2418
- length: method.length,
2419
- toString: () => {
2420
- return colorize(method, mapColor[method]);
2421
- }
2422
- };
2423
- return obj;
2424
- });
2425
- const str = $log.drawTable(list, {
2426
- padding: 1,
2427
- header: {
2428
- method: "Method",
2429
- url: "Endpoint",
2430
- name: "Class method"
2431
- }
2432
- });
2433
- return "\n" + str.trim();
2434
- }
2435
-
2436
- const _excluded$1 = ["reqIdBuilder"];
2437
-
2438
- const uuidv4 = require("uuid").v4;
2439
-
2440
- const defaultReqIdBuilder = req => req.get("x-request-id") || uuidv4().replace(/-/gi, "");
2441
- /**
2442
- * Create the TsED context to wrap request, response, injector, etc...
2443
- * @param injector
2444
- * @ignore
2445
- */
2446
-
2447
-
2448
- function createContext(injector) {
2449
- var _injector$getProvider, _injector$getProvider2;
2450
-
2451
- const ResponseKlass = (_injector$getProvider = injector.getProvider(PlatformResponse)) == null ? void 0 : _injector$getProvider.useClass;
2452
- const RequestKlass = (_injector$getProvider2 = injector.getProvider(PlatformRequest)) == null ? void 0 : _injector$getProvider2.useClass;
2453
-
2454
- const _ref = injector.settings.logger || {},
2455
- {
2456
- reqIdBuilder = defaultReqIdBuilder
2457
- } = _ref,
2458
- loggerOptions = _objectWithoutPropertiesLoose(_ref, _excluded$1);
2459
-
2460
- return async event => {
2461
- const ctx = new PlatformContext(_extends({
2462
- event,
2463
- id: reqIdBuilder(event.request),
2464
- logger: injector.logger
2465
- }, loggerOptions, {
2466
- injector,
2467
- ResponseKlass,
2468
- RequestKlass
2469
- }));
2470
- ctx.response.onEnd(async () => {
2471
- await ctx.emit("$onResponse", ctx);
2472
- await ctx.destroy();
2473
- });
2474
- await ctx.emit("$onRequest", ctx);
2475
- return ctx;
2476
- };
2477
- }
2478
-
2479
- function mapOptions$1(options) {
2480
- const opts = typeof options === "string" ? {
2481
- root: options
2482
- } : options;
2483
- return _extends({}, opts, {
2484
- hook: getValue(opts, "hook", "$afterRoutesInit")
2485
- });
2486
- }
2487
-
2488
- function getStaticsOptions(statics) {
2489
- return Object.entries(statics || {}).reduce((statics, [path, items]) => {
2490
- [].concat(items).forEach(options => {
2491
- statics.push({
2492
- path,
2493
- options: mapOptions$1(options)
2494
- });
2495
- });
2496
- return statics;
2497
- }, []);
2498
- }
2499
-
2500
- function getConfiguration(configuration = {}, module = null) {
2501
- const store = module ? Store.from(module).get("configuration") || {} : {};
2502
- const env = configuration.env || store.mount || process.env.NODE_ENV || Env.DEV;
2503
-
2504
- const config = _extends({
2505
- exclude: ["**/*.spec.ts", "**/*.spec.js"],
2506
- componentsScan: ["${rootDir}/mvc/**/*.ts", "${rootDir}/services/**/*.ts", "${rootDir}/middlewares/**/*.ts"],
2507
- env,
2508
- httpPort: 8080,
2509
- httpsPort: false
2510
- }, store, configuration, {
2511
- scopes: _extends({
2512
- [ProviderType.CONTROLLER]: ProviderScope.SINGLETON
2513
- }, store.scopes, configuration.scopes),
2514
- mount: store.mount || configuration.mount ? deepMerge(store.mount || {}, configuration.mount || {}) : {
2515
- "/rest": "${rootDir}/controllers/**/*.ts"
2516
- },
2517
- logger: _extends({
2518
- debug: false,
2519
- level: env === Env.TEST ? "off" : "info",
2520
- logRequest: true
2521
- }, store.logger, configuration.logger, {
2522
- jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2
2523
- })
2524
- });
2525
-
2526
- if (!configuration.disableComponentsScan && store.componentsScan && configuration.componentsScan) {
2527
- config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];
2528
- }
2529
-
2530
- return config;
2531
- }
2532
-
2533
- /**
2534
- * @platform
2535
- */
2536
-
2537
- var _injector = /*#__PURE__*/_classPrivateFieldLooseKey("injector");
2538
-
2539
- var _rootModule = /*#__PURE__*/_classPrivateFieldLooseKey("rootModule");
2540
-
2541
- class PlatformBuilder {
2542
- constructor({
2543
- name,
2544
- providers,
2545
- settings,
2546
- module
2547
- }) {
2548
- Object.defineProperty(this, _injector, {
2549
- writable: true,
2550
- value: void 0
2551
- });
2552
- Object.defineProperty(this, _rootModule, {
2553
- writable: true,
2554
- value: void 0
2555
- });
2556
- this.name = "";
2557
- this.startedAt = new Date();
2558
- this.current = new Date();
2559
- this.name = name;
2560
- _classPrivateFieldLooseBase(this, _rootModule)[_rootModule] = module;
2561
- const configuration = getConfiguration(settings, module);
2562
- configuration.PLATFORM_NAME = name;
2563
- _classPrivateFieldLooseBase(this, _injector)[_injector] = createInjector({
2564
- settings: configuration,
2565
- providers
2566
- });
2567
- this.log("Injector created...");
2568
- }
2569
-
2570
- get injector() {
2571
- return _classPrivateFieldLooseBase(this, _injector)[_injector];
2572
- }
2573
-
2574
- get rootModule() {
2575
- return _classPrivateFieldLooseBase(this, _injector)[_injector].get(_classPrivateFieldLooseBase(this, _rootModule)[_rootModule]);
2576
- }
2577
-
2578
- get app() {
2579
- return this.injector.get(PlatformApplication);
2580
- }
2581
-
2582
- get platform() {
2583
- return this.injector.get(Platform);
2584
- }
2585
- /**
2586
- * Return the settings configured by the decorator @@Configuration@@.
2587
- *
2588
- * ```typescript
2589
- * @Configuration({
2590
- * rootDir: Path.resolve(__dirname),
2591
- * port: 8000,
2592
- * httpsPort: 8080,
2593
- * mount: {
2594
- * "/rest": "${rootDir}/controllers/**\/*.js"
2595
- * }
2596
- * })
2597
- * export class Server {
2598
- * $onInit(){
2599
- * console.log(this.settings); // {rootDir, port, httpsPort,...}
2600
- * }
2601
- * }
2602
- * ```
2603
- *
2604
- * @returns {PlatformConfiguration}
2605
- */
2606
-
2607
-
2608
- get settings() {
2609
- return this.injector.settings;
2610
- }
2611
-
2612
- get logger() {
2613
- return this.injector.logger;
2614
- }
2615
-
2616
- get disableBootstrapLog() {
2617
- var _this$settings$logger;
2618
-
2619
- return (_this$settings$logger = this.settings.logger) == null ? void 0 : _this$settings$logger.disableBootstrapLog;
2620
- }
2621
-
2622
- static build(platformBuildClass, module, settings = {}) {
2623
- return new platformBuildClass({
2624
- name: nameOf(platformBuildClass).replace("Platform", "").toLowerCase(),
2625
- module,
2626
- settings,
2627
- providers: platformBuildClass.providers
2628
- });
2629
- }
2630
-
2631
- callback(req, res) {
2632
- if (req && res) {
2633
- return this.app.callback()(req, res);
2634
- }
2635
-
2636
- return this.app.callback();
2637
- }
2638
-
2639
- log(...data) {
2640
- return !this.disableBootstrapLog && this.logger.info(...data, this.diff());
2641
- }
2642
- /**
2643
- * Add classes to the components list
2644
- * @param classes
2645
- */
2646
-
2647
-
2648
- addComponents(classes) {
2649
- this.settings.componentsScan = this.settings.componentsScan.concat(classes);
2650
- return this;
2651
- }
2652
- /**
2653
- * Add classes decorated by @@Controller@@ to components container.
2654
- *
2655
- * ### Example
2656
- *
2657
- * ```typescript
2658
- * @Controller('/ctrl')
2659
- * class MyController{
2660
- * }
2661
- *
2662
- * platform.addControllers('/rest', [MyController])
2663
- * ```
2664
- *
2665
- * ::: tip
2666
- * If the MyController class isn't decorated, the class will be ignored.
2667
- * :::
2668
- *
2669
- * @param {string} endpoint
2670
- * @param {any[]} controllers
2671
- */
2672
-
2673
-
2674
- addControllers(endpoint, controllers) {
2675
- this.settings.mount[endpoint] = (this.settings.mount[endpoint] || []).concat(controllers);
2676
- }
2677
-
2678
- async runLifecycle() {
2679
- setLoggerLevel(this.injector);
2680
- await this.importProviders();
2681
- await this.loadInjector();
2682
- this.useContext();
2683
- this.useRouter();
2684
- await this.loadRoutes();
2685
- await this.logRoutes();
2686
- return this;
2687
- }
2688
-
2689
- async loadInjector() {
2690
- const {
2691
- injector
2692
- } = this;
2693
- this.log("Build providers");
2694
- const container = createContainer();
2695
- container.addProvider(_classPrivateFieldLooseBase(this, _rootModule)[_rootModule], {
2696
- type: "server:module",
2697
- scope: ProviderScope.SINGLETON
2698
- });
2699
- await injector.load(container);
2700
- this.log("Settings and injector loaded...");
2701
- await this.callHook("$afterInit");
2702
- }
2703
-
2704
- async listen() {
2705
- await this.callHook("$beforeListen");
2706
- await this.listenServers();
2707
- await this.callHook("$afterListen");
2708
- await this.ready();
2709
- }
2710
-
2711
- async stop() {
2712
- await this.callHook("$onDestroy");
2713
- return this.injector.destroy();
2714
- }
2715
-
2716
- async ready() {
2717
- const {
2718
- startedAt
2719
- } = this;
2720
- await this.callHook("$onReady");
2721
- await this.injector.emit("$onServerReady");
2722
- this.log(`Started in ${new Date().getTime() - startedAt.getTime()} ms`);
2723
- }
2724
-
2725
- async callHook(hook, ...args) {
2726
- const {
2727
- injector
2728
- } = this;
2729
-
2730
- if (!this.disableBootstrapLog) {
2731
- injector.logger.debug(`\x1B[1mCall hook ${hook}\x1B[22m`);
2732
- } // Load middlewares for the given hook
2733
-
2734
-
2735
- this.loadMiddlewaresFor(hook); // call hooks added by providers
2736
-
2737
- await injector.emit(hook, ...args);
2738
- }
2739
-
2740
- async loadStatics(hook) {
2741
- const statics = this.settings.get("statics");
2742
- getStaticsOptions(statics).forEach(({
2743
- path,
2744
- options
2745
- }) => {
2746
- if (options.hook === hook) {
2747
- this.platform.app.statics(path, options);
2748
- }
2749
- });
2750
- }
2751
-
2752
- useProvider(token, settings) {
2753
- this.injector.addProvider(token, settings);
2754
- return this;
2755
- }
2756
-
2757
- async bootstrap() {
2758
- return this.runLifecycle();
2759
- }
2760
-
2761
- diff() {
2762
- const ms = colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);
2763
- this.current = new Date();
2764
- return ms;
2765
- }
2766
-
2767
- async importProviders() {
2768
- this.injector.logger.debug("Scan components");
2769
- const providers = await importProviders(this.injector.settings, ["imports", "mount", "componentsScan"]);
2770
- const routes = providers.filter(provider => !!provider.route).map(({
2771
- route,
2772
- token
2773
- }) => ({
2774
- route,
2775
- token
2776
- }));
2777
- this.settings.set("routes", routes);
2778
- this.log("Providers loaded...");
2779
- }
2780
- /**
2781
- * Load middlewares from configuration for the given hook
2782
- * @param hook
2783
- * @protected
2784
- */
2785
-
2786
-
2787
- loadMiddlewaresFor(hook) {
2788
- return getMiddlewaresForHook(hook, this.settings, "$beforeRoutesInit").forEach(({
2789
- use
2790
- }) => {
2791
- this.app.use(use);
2792
- });
2793
- }
2794
-
2795
- useRouter() {
2796
- return this;
2797
- }
2798
-
2799
- useContext() {
2800
- return this;
2801
- }
2802
-
2803
- async listenServers() {
2804
- await Promise.all([listenHttpServer(this.injector), listenHttpsServer(this.injector)]);
2805
- }
2806
-
2807
- async logRoutes() {
2808
- var _this$settings$logger2;
2809
-
2810
- const {
2811
- logger,
2812
- platform
2813
- } = this;
2814
- this.log("Routes mounted...");
2815
-
2816
- if (!((_this$settings$logger2 = this.settings.logger) != null && _this$settings$logger2.disableRoutesSummary) && !this.disableBootstrapLog) {
2817
- logger.info(printRoutes(await this.injector.alterAsync("$logRoutes", platform.getRoutes())));
2818
- }
2819
- }
2820
-
2821
- async loadRoutes() {
2822
- var _this$settings$logger3, _this$settings$accept;
2823
-
2824
- // istanbul ignore next
2825
- if (((_this$settings$logger3 = this.settings.logger) == null ? void 0 : _this$settings$logger3.level) !== "off") {
2826
- const {
2827
- PlatformLogMiddleware
2828
- } = await import('@tsed/platform-log-middleware');
2829
- this.app.use(PlatformLogMiddleware);
2830
- }
2831
-
2832
- if ((_this$settings$accept = this.settings.acceptMimes) != null && _this$settings$accept.length) {
2833
- this.app.use(GlobalAcceptMimesMiddleware);
2834
- }
2835
-
2836
- this.log("Load routes");
2837
- await this.loadStatics("$beforeRoutesInit");
2838
- await this.callHook("$beforeRoutesInit");
2839
- const routes = this.injector.settings.get("routes");
2840
- this.platform.addRoutes(routes);
2841
- await this.callHook("$onRoutesInit");
2842
- await this.loadStatics("$afterRoutesInit");
2843
- await this.callHook("$afterRoutesInit");
2844
- }
2845
-
2846
- }
2847
-
2848
- /**
2849
- * Define multer option for all MultipartFile
2850
- *
2851
- * ```typescript
2852
- * import {Controller, Post, PlatformMulterFile, MultipartFile, MulterOptions} from "@tsed/common";
2853
- *
2854
- * @Controller('/')
2855
- * class MyCtrl {
2856
- * @Post('/file')
2857
- * private uploadFile(@MultipartFile("file1") file: PlatformMulterFile) {
2858
- *
2859
- * }
2860
- *
2861
- * @Post('/file')
2862
- * @MulterOptions({dest: "/other-dir"})
2863
- * private uploadFile(@MultipartFile("file1") file: PlatformMulterFile) {
2864
- *
2865
- * }
2866
- *
2867
- * @Post('/file2')
2868
- * @MulterOptions({dest: "/other-dir"})
2869
- * private uploadFile(@MultipartFile("file1") file: PlatformMulterFile, @MultipartFile("file2") file2: PlatformMulterFile) {
2870
- *
2871
- * }
2872
- *
2873
- * @Post('/files')
2874
- * private uploadFile(@MultipartFile("file1") files: PlatformMulterFile[]) {
2875
- *
2876
- * }
2877
- * }
2878
- * ```
2879
- *
2880
- * See the tutorial on the [multer configuration](/tutorials/multer.md).
2881
- *
2882
- * @param {multer.Options} options
2883
- * @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}
2884
- * @decorator
2885
- * @multer
2886
- */
2887
-
2888
- function MulterOptions(options) {
2889
- return (target, propertyKey, descriptor) => {
2890
- StoreMerge(PlatformMulterMiddleware, {
2891
- options
2892
- })(target, propertyKey, descriptor);
2893
- return descriptor;
2894
- };
2895
- }
2896
-
2897
- /**
2898
- * Define file size limit.
2899
- *
2900
- * ```typescript
2901
- * import {Controller, Post} from "@tsed/common";
2902
- * import {MulterOptions, MultipartFile} from "@tsed/common";
2903
- * import {Multer} from "@types/multer";
2904
- *
2905
- * type MulterFile = Express.Multer.File;
2906
- *
2907
- * @Controller('/')
2908
- * class MyCtrl {
2909
- * @Post('/file2')
2910
- * @MulterFileSize(1024) // (Ko). Applied for all fields
2911
- * private uploadFile(@MultipartFile("file1") file: MulterFile, @MultipartFile("file2") file2: MulterFile) {
2912
- *
2913
- * }
2914
- * }
2915
- * ```
2916
- *
2917
- * > See the tutorial on the [multer configuration](/tutorials/multer.md).
2918
- * @param fileSize
2919
- * @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}
2920
- * @decorator
2921
- * @multer
2922
- */
2923
-
2924
- function MulterFileSize(fileSize) {
2925
- return MulterOptions({
2926
- limits: {
2927
- fileSize
2928
- }
2929
- });
2930
- }
2931
-
2932
- function mapOptions(name, maxCount) {
2933
- return {
2934
- fields: [{
2935
- name,
2936
- maxCount
2937
- }]
2938
- };
2939
- }
2940
- /**
2941
- * Define a parameter as Multipart file.
2942
- *
2943
- * ```typescript
2944
- * import {Controller, Post} from "@tsed/common";
2945
- * import {MulterOptions, MultipartFile} from "@tsed/common";
2946
- * import {Multer} from "@types/multer";
2947
- *
2948
- * type MulterFile = Express.Multer.File;
2949
- *
2950
- * @Controller('/')
2951
- * class MyCtrl {
2952
- * @Post('/file')
2953
- * private uploadFile(@MultipartFile("file1") file: MulterFile) {
2954
- *
2955
- * }
2956
- *
2957
- * @Post('/file')
2958
- * @MulterOptions({dest: "/other-dir"})
2959
- * private uploadFile(@MultipartFile("file1") file: MulterFile) {
2960
- *
2961
- * }
2962
- *
2963
- * @Post('/file2')
2964
- * @MulterOptions({dest: "/other-dir"})
2965
- * private uploadFile(@MultipartFile("file1") file: MulterFile, @MultipartFile("file2") file2: MulterFile) {
2966
- *
2967
- * }
2968
- *
2969
- * @Post('/files')
2970
- * private uploadFile(@MultipartFile("file1") files: MulterFile[]) {
2971
- *
2972
- * }
2973
- * }
2974
- * ```
2975
- *
2976
- * > See the tutorial on the [multer configuration](/tutorials/multer.md).
2977
- *
2978
- * @param name
2979
- * @param maxCount
2980
- * @returns Function
2981
- * @decorator
2982
- * @input
2983
- */
2984
-
2985
-
2986
- function MultipartFile(name, maxCount) {
2987
- return (...args) => {
2988
- const [target, propertyKey, index] = args;
2989
- const multiple = Metadata.getParamTypes(target, propertyKey)[index] === Array;
2990
- name = typeof name === "object" ? undefined : name;
2991
- const expression = [name, !multiple && "0"].filter(Boolean).join(".");
2992
- const decorators = useDecorators(useMethodDecorators(Returns(400).Description(`<File too long | Too many parts | Too many files | Field name too long | Field value too long | Too many fields | Unexpected field> [fieldName] Example: File too long file1`), Consumes("multipart/form-data"), StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))), UseParam({
2993
- paramType: ParamTypes.FILES,
2994
- dataPath: "$ctx.request.files",
2995
- expression,
2996
- useValidation: true
2997
- }));
2998
- decorators(...args);
2999
- };
3000
- }
3001
-
3002
- /**
3003
- * Set a mime list which are acceptable and checks if the specified content types are acceptable, based on the request’s Accept HTTP header field.
3004
- *
3005
- * ```typescript
3006
- * @Controller('/mypath')
3007
- * export class MyCtrl {
3008
- *
3009
- * @Get('/')
3010
- * @AcceptMime('application/json')
3011
- * public getResource(){}
3012
- * }
3013
- * ```
3014
- *
3015
- * @param mimes
3016
- * @decorator
3017
- * @operation
3018
- * @response
3019
- */
3020
-
3021
- function AcceptMime(...mimes) {
3022
- return useDecorators(Produces(...mimes), StoreSet("acceptMimes", mimes));
3023
- }
3024
-
3025
- /**
3026
- *
3027
- * @param fn
3028
- * @decorator
3029
- * @deprecated Deprecated since 2021-10-05. Use JsonEntityFn instead.
3030
- */
3031
-
3032
- function EndpointFn(fn) {
3033
- return JsonEntityFn(fn);
3034
- }
3035
-
3036
- /**
3037
- * Use a view and sends the rendered HTML string to the client. Optional parameter:
3038
- *
3039
- * * viewOptions, an object whose properties define local variables for the view.
3040
- *
3041
- * The view argument is a string that is the file path of the view file to render.
3042
- * This can be an absolute path, or a path relative to the views setting.
3043
- * If the path does not contain a file extension, then the view engine setting determines the file extension.
3044
- * If the path does contain a file extension, then Express will load the module for the specified template engine (via require())
3045
- * and render it using the loaded module’s __express function.
3046
- *
3047
- * For more information, see [Using template engines with Express](http://expressjs.com/guide/using-template-engines.html).
3048
- *
3049
- * > NOTE: The view argument performs file system operations like reading a file from disk and evaluating Node.js modules,
3050
- * and as so for security reasons should not contain input from the end-user.
3051
- *
3052
- * @param path Relative path to the view file.
3053
- * @param options Additional options
3054
- * @decorator
3055
- * @operation
3056
- * @response
3057
- * @ignores
3058
- * @deprecated Use View decorator from @tsed/platform-views instead.
3059
- */
3060
- // istanbul ignore next
3061
-
3062
- function View(path, options) {
3063
- return StoreSet("view", {
3064
- path,
3065
- options
3066
- });
3067
- }
3068
-
3069
- /**
3070
- * Return the current response data. Prefer the @@Context@@ decorator to get or set data.
3071
- *
3072
- * @decorator
3073
- * @operation
3074
- * @input
3075
- * @deprecated Use `@Context() $ctx: Context` then $ctx.data.
3076
- */
3077
-
3078
- function ResponseData() {
3079
- return UseParam({
3080
- paramType: ParamTypes.$CTX,
3081
- dataPath: "$ctx.data"
3082
- });
3083
- }
3084
-
3085
- function getParamType$1(target, propertyKey, parameterIndex) {
3086
- const type = Metadata.getOwnParamTypes(target, propertyKey)[parameterIndex];
3087
-
3088
- if (isClass(type)) {
3089
- if (nameOf(type) === "PlatformResponse") {
3090
- return {
3091
- paramType: ParamTypes.PLATFORM_RESPONSE,
3092
- dataPath: "$ctx.response"
3093
- };
3094
- }
3095
-
3096
- if (type === ServerResponse) {
3097
- return {
3098
- paramType: ParamTypes.NODE_RESPONSE,
3099
- dataPath: "$ctx.response.res"
3100
- };
3101
- }
3102
- }
3103
-
3104
- return {
3105
- paramType: ParamTypes.RESPONSE,
3106
- dataPath: "$ctx.response.response"
3107
- };
3108
- }
3109
-
3110
- function Response() {
3111
- return Res();
3112
- }
3113
- function Res() {
3114
- return (target, propertyKey, parameterIndex) => {
3115
- const {
3116
- paramType,
3117
- dataPath
3118
- } = getParamType$1(target, propertyKey, parameterIndex);
3119
- UseParam({
3120
- paramType,
3121
- dataPath
3122
- })(target, propertyKey, parameterIndex);
3123
- };
3124
- }
3125
-
3126
- function getParamType(target, propertyKey, parameterIndex) {
3127
- const type = Metadata.getOwnParamTypes(target, propertyKey)[parameterIndex];
3128
-
3129
- if (isClass(type)) {
3130
- if (nameOf(type) === "PlatformRequest") {
3131
- return {
3132
- paramType: ParamTypes.PLATFORM_REQUEST,
3133
- dataPath: "$ctx.request"
3134
- };
3135
- }
3136
-
3137
- if (type === IncomingMessage) {
3138
- return {
3139
- paramType: ParamTypes.NODE_REQUEST,
3140
- dataPath: "$ctx.request.req"
3141
- };
3142
- }
3143
- }
3144
-
3145
- return {
3146
- paramType: ParamTypes.REQUEST,
3147
- dataPath: "$ctx.request.request"
3148
- };
3149
- }
3150
-
3151
- function Request(...args) {
3152
- // @ts-ignore
3153
- return Req(...args);
3154
- }
3155
- function Req(...args) {
3156
- const {
3157
- expression,
3158
- useType,
3159
- useConverter = false,
3160
- useValidation = false
3161
- } = mapParamsOptions(args);
3162
- return (target, propertyKey, parameterIndex) => {
3163
- const {
3164
- paramType,
3165
- dataPath
3166
- } = getParamType(target, propertyKey, parameterIndex);
3167
- UseParam({
3168
- paramType,
3169
- dataPath,
3170
- expression,
3171
- useType,
3172
- useConverter,
3173
- useValidation
3174
- })(target, propertyKey, parameterIndex);
3175
- };
3176
- }
3177
-
3178
- /**
3179
- * Get the Next function (for express application and middleware).
3180
- *
3181
- * @decorator
3182
- * @operation
3183
- * @input
3184
- */
3185
-
3186
- function Next() {
3187
- return UseParam({
3188
- paramType: ParamTypes.NEXT_FN,
3189
- dataPath: "next",
3190
- useConverter: false,
3191
- useValidation: false
3192
- });
3193
- }
3194
-
3195
- /**
3196
- * @returns {Function}
3197
- * @decorator
3198
- * @operation
3199
- * @input
3200
- */
3201
-
3202
- function Err() {
3203
- return UseParam({
3204
- paramType: ParamTypes.ERR,
3205
- dataPath: "err",
3206
- useValidation: false,
3207
- useConverter: false
3208
- });
3209
- }
3210
-
3211
- /**
3212
- * Get the current endpoint metadata.
3213
- * @decorator
3214
- * @operation
3215
- * @input
3216
- * @deprecated Use `@Context() $ctx: Context` then `$ctx.endpoint` instead.
3217
- */
3218
-
3219
- function EndpointInfo() {
3220
- return UseParam({
3221
- paramType: ParamTypes.$CTX,
3222
- dataPath: "$ctx.endpoint",
3223
- useConverter: false,
3224
- useValidation: false
3225
- });
3226
- }
3227
-
3228
- const _excluded = ["use", "collection"];
3229
-
3230
- /**
3231
- * @ignore
3232
- */
3233
- function mapReturnedResponse(_ref) {
3234
- let {
3235
- use,
3236
- collection
3237
- } = _ref,
3238
- options = _objectWithoutPropertiesLoose(_ref, _excluded);
3239
-
3240
- return _extends({}, options, {
3241
- type: options.type || use,
3242
- collectionType: options.collectionType || collection
3243
- });
3244
- }
3245
-
3246
- /**
3247
- * @platform
3248
- */
3249
-
3250
- class PlatformTest extends DITest {
3251
- static async create(settings = {}) {
3252
- DITest.injector = PlatformTest.createInjector(getConfiguration(settings));
3253
- const container = createContainer();
3254
- await DITest.injector.load(container);
3255
- }
3256
- /**
3257
- * Create a new injector with the right default services
3258
- */
3259
-
3260
-
3261
- static createInjector(settings = {}) {
3262
- return createInjector({
3263
- providers: [],
3264
- settings: DITest.configure(settings)
3265
- });
3266
- }
3267
- /**
3268
- * Load the server silently without listening port and configure it on test profile.
3269
- * @decorator
3270
- * @param mod
3271
- * @param settings
3272
- * @returns {Promise<void>}
3273
- */
3274
-
3275
-
3276
- static bootstrap(mod, settings = {}) {
3277
- return async function before() {
3278
- let instance;
3279
- const platform = settings.platform || PlatformTest.platformBuilder;
3280
- /* istanbul ignore next */
3281
-
3282
- if (!platform) {
3283
- throw new Error("Platform type is not specified. Have you added at least `import @tsed/platform-express` (or equivalent) on your Server.ts ?");
3284
- } // @ts-ignore
3285
-
3286
-
3287
- settings = DITest.configure(settings);
3288
- instance = await PlatformBuilder.build(platform, mod, settings).bootstrap();
3289
-
3290
- if (!settings.listen) {
3291
- await instance.callHook("$beforeListen");
3292
- await instance.callHook("$afterListen");
3293
- await instance.ready();
3294
- } else {
3295
- await instance.listen();
3296
- } // used by inject method
3297
-
3298
-
3299
- DITest.injector = instance.injector;
3300
- };
3301
- }
3302
- /**
3303
- * It injects services into the test function where you can alter, spy on, and manipulate them.
3304
- *
3305
- * The inject function has two parameters
3306
- *
3307
- * * an array of Service dependency injection tokens,
3308
- * * a test function whose parameters correspond exactly to each item in the injection token array.
3309
- *
3310
- * @param targets
3311
- * @param func
3312
- */
3313
-
3314
-
3315
- static inject(targets, func) {
3316
- return async function () {
3317
- if (!DITest.hasInjector()) {
3318
- await PlatformTest.create();
3319
- }
3320
-
3321
- const injector = DITest.injector;
3322
- const deps = [];
3323
-
3324
- for (const target of targets) {
3325
- deps.push(injector.has(target) ? injector.get(target) : await injector.invoke(target));
3326
- }
3327
-
3328
- return await func(...deps);
3329
- };
3330
- }
3331
- /**
3332
- * Return the raw application (express or koa).
3333
- * Use this callback with SuperTest.
3334
- *
3335
- * ```typescript
3336
- * let request: SuperTest.SuperTest<SuperTest.Test>;
3337
- * beforeEach(PlatformTest.bootstrap(Server, {
3338
- * mount: {
3339
- * "/rest": [ProductsController]
3340
- * }
3341
- * }));
3342
- * beforeEach(() => {
3343
- * request = SuperTest(PlatformTest.callback());
3344
- * });
3345
- * ```
3346
- */
3347
-
3348
-
3349
- static callback() {
3350
- var _DITest$injector$get;
3351
-
3352
- return (_DITest$injector$get = DITest.injector.get(PlatformApplication)) == null ? void 0 : _DITest$injector$get.callback();
3353
- }
3354
-
3355
- static createRequest(options = {}) {
3356
- return _extends({
3357
- headers: {},
3358
-
3359
- get(key) {
3360
- return this.headers[key.toLowerCase()];
3361
- },
3362
-
3363
- accepts(mime) {
3364
- return require("accepts")(this).types([].concat(mime));
3365
- }
3366
-
3367
- }, options);
3368
- }
3369
-
3370
- static createResponse(options = {}) {
3371
- return _extends({
3372
- headers: {},
3373
- locals: {},
3374
- statusCode: 200,
3375
-
3376
- status(code) {
3377
- this.statusCode = code;
3378
- return this;
3379
- },
3380
-
3381
- contentType(content) {
3382
- this.set("content-type", content);
3383
- },
3384
-
3385
- contentLength(content) {
3386
- this.set("content-length", content);
3387
- },
3388
-
3389
- redirect(status, path) {
3390
- this.statusCode = status;
3391
- this.set("location", path);
3392
- },
3393
-
3394
- location(path) {
3395
- this.set("location", path);
3396
- },
3397
-
3398
- get(key) {
3399
- return this.headers[key.toLowerCase()];
3400
- },
3401
-
3402
- getHeaders() {
3403
- return this.headers;
3404
- },
3405
-
3406
- set(key, value) {
3407
- this.headers[key.toLowerCase()] = value;
3408
- return this;
3409
- },
3410
-
3411
- send(data) {
3412
- this.data = data;
3413
- },
3414
-
3415
- json(data) {
3416
- this.data = data;
3417
- }
3418
-
3419
- }, options);
3420
- }
3421
-
3422
- static createRequestContext(options = {}) {
3423
- var _options$request, _options$event, _options$response, _options$event2;
3424
-
3425
- const event = {
3426
- request: (options == null ? void 0 : (_options$request = options.request) == null ? void 0 : _options$request.request) || (options == null ? void 0 : (_options$event = options.event) == null ? void 0 : _options$event.request) || PlatformTest.createRequest(),
3427
- response: (options == null ? void 0 : (_options$response = options.response) == null ? void 0 : _options$response.response) || (options == null ? void 0 : (_options$event2 = options.event) == null ? void 0 : _options$event2.response) || PlatformTest.createResponse()
3428
- };
3429
- return new PlatformContext(_extends({
3430
- id: "id",
3431
- injector: DITest.injector,
3432
- logger: DITest.injector.logger,
3433
- url: "/"
3434
- }, options, {
3435
- event
3436
- }));
3437
- }
3438
-
3439
- }
3440
-
3441
- /**
3442
- * @ignore
3443
- * @deprecated Will be removed in v7
3444
- */
3445
- class PlatformModule {}
3446
-
3447
- export { AcceptMime, AcceptMimesMiddleware, AnyToPromiseWithCtx, ControllerProvider, EndpointFn, EndpointInfo, EndpointMetadata, Err, GlobalAcceptMimesMiddleware, HandlerMetadata, HandlerType, HttpServer, HttpsServer, MulterFileSize, MulterOptions, MultipartFile, Next, PLATFORM_ROUTER_OPTIONS, Platform, PlatformAcceptMimesMiddleware, PlatformApplication, PlatformBuilder, PlatformConfiguration, PlatformContext, PlatformHandler, PlatformMiddlewaresChain, PlatformModule, PlatformMulterMiddleware, PlatformRequest, PlatformResponse, PlatformRouteDetails, PlatformRouter, PlatformTest, PropertyMetadata, ROUTER_OPTIONS, Req, Request, Res, Response, ResponseData, View, bindEndpointMiddleware, buildRouter, createContext, createHttpServer, createHttpsServer, createInjector, createRouter, getRouter, listenHttpServer, listenHttpsServer, listenServer, loadInjector, mapReturnedResponse, printRoutes, useCtxHandler };
3448
- //# sourceMappingURL=index.modern.js.map