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