@tsed/common 7.0.0-alpha.1 → 7.0.0-beta.3

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 (409) hide show
  1. package/lib/cjs/builder/PlatformBuilder.js +275 -0
  2. package/lib/cjs/builder/PlatformBuilder.js.map +1 -0
  3. package/lib/cjs/builder/PlatformControllerBuilder.js +85 -0
  4. package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -0
  5. package/lib/cjs/config/index.js +7 -0
  6. package/lib/cjs/config/index.js.map +1 -0
  7. package/lib/cjs/config/interfaces/ConverterSettings.js +3 -0
  8. package/lib/cjs/config/interfaces/ConverterSettings.js.map +1 -0
  9. package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js +3 -0
  10. package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js.map +1 -0
  11. package/lib/cjs/config/interfaces/PlatformLoggerSettings.js +3 -0
  12. package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -0
  13. package/lib/cjs/config/interfaces/PlatformMulterSettings.js +3 -0
  14. package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -0
  15. package/lib/cjs/config/interfaces/PlatformStaticsSettings.js +3 -0
  16. package/lib/cjs/config/interfaces/PlatformStaticsSettings.js.map +1 -0
  17. package/lib/cjs/config/interfaces/index.js +8 -0
  18. package/lib/cjs/config/interfaces/index.js.map +1 -0
  19. package/lib/cjs/config/services/PlatformConfiguration.js +181 -0
  20. package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -0
  21. package/lib/cjs/constants/routerOptions.js +5 -0
  22. package/lib/cjs/constants/routerOptions.js.map +1 -0
  23. package/lib/cjs/decorators/httpServer.js +32 -0
  24. package/lib/cjs/decorators/httpServer.js.map +1 -0
  25. package/lib/cjs/decorators/httpsServer.js +32 -0
  26. package/lib/cjs/decorators/httpsServer.js.map +1 -0
  27. package/lib/cjs/decorators/index.js +26 -0
  28. package/lib/cjs/decorators/index.js.map +1 -0
  29. package/lib/cjs/decorators/method/acceptMime.js +28 -0
  30. package/lib/cjs/decorators/method/acceptMime.js.map +1 -0
  31. package/lib/cjs/decorators/multer/index.js +7 -0
  32. package/lib/cjs/decorators/multer/index.js.map +1 -0
  33. package/lib/cjs/decorators/multer/multerFileSize.js +35 -0
  34. package/lib/cjs/decorators/multer/multerFileSize.js.map +1 -0
  35. package/lib/cjs/decorators/multer/multerOptions.js +52 -0
  36. package/lib/cjs/decorators/multer/multerOptions.js.map +1 -0
  37. package/lib/cjs/decorators/multer/multipartFile.js +78 -0
  38. package/lib/cjs/decorators/multer/multipartFile.js.map +1 -0
  39. package/lib/cjs/decorators/params/error.js +20 -0
  40. package/lib/cjs/decorators/params/error.js.map +1 -0
  41. package/lib/cjs/decorators/params/next.js +21 -0
  42. package/lib/cjs/decorators/params/next.js.map +1 -0
  43. package/lib/cjs/decorators/params/request.js +39 -0
  44. package/lib/cjs/decorators/params/request.js.map +1 -0
  45. package/lib/cjs/decorators/params/response.js +33 -0
  46. package/lib/cjs/decorators/params/response.js.map +1 -0
  47. package/lib/cjs/domain/AnyToPromiseWithCtx.js +27 -0
  48. package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -0
  49. package/lib/cjs/domain/ControllerProvider.js +51 -0
  50. package/lib/cjs/domain/ControllerProvider.js.map +1 -0
  51. package/lib/cjs/domain/EndpointMetadata.js +70 -0
  52. package/lib/cjs/domain/EndpointMetadata.js.map +1 -0
  53. package/lib/cjs/domain/HandlerMetadata.js +57 -0
  54. package/lib/cjs/domain/HandlerMetadata.js.map +1 -0
  55. package/lib/cjs/domain/PlatformContext.js +92 -0
  56. package/lib/cjs/domain/PlatformContext.js.map +1 -0
  57. package/lib/cjs/domain/PlatformRouteDetails.js +24 -0
  58. package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -0
  59. package/lib/cjs/domain/index.js +10 -0
  60. package/lib/cjs/domain/index.js.map +1 -0
  61. package/lib/cjs/index.js +34 -0
  62. package/lib/cjs/index.js.map +1 -0
  63. package/lib/cjs/interfaces/AfterInit.js +3 -0
  64. package/lib/cjs/interfaces/AfterInit.js.map +1 -0
  65. package/lib/cjs/interfaces/AfterListen.js +3 -0
  66. package/lib/cjs/interfaces/AfterListen.js.map +1 -0
  67. package/lib/cjs/interfaces/AfterRoutesInit.js +3 -0
  68. package/lib/cjs/interfaces/AfterRoutesInit.js.map +1 -0
  69. package/lib/cjs/interfaces/BeforeInit.js +3 -0
  70. package/lib/cjs/interfaces/BeforeInit.js.map +1 -0
  71. package/lib/cjs/interfaces/BeforeListen.js +3 -0
  72. package/lib/cjs/interfaces/BeforeListen.js.map +1 -0
  73. package/lib/cjs/interfaces/BeforeRoutesInit.js +3 -0
  74. package/lib/cjs/interfaces/BeforeRoutesInit.js.map +1 -0
  75. package/lib/cjs/interfaces/HandlerType.js +17 -0
  76. package/lib/cjs/interfaces/HandlerType.js.map +1 -0
  77. package/lib/cjs/interfaces/IncomingEvent.js +3 -0
  78. package/lib/cjs/interfaces/IncomingEvent.js.map +1 -0
  79. package/lib/cjs/interfaces/OnReady.js +3 -0
  80. package/lib/cjs/interfaces/OnReady.js.map +1 -0
  81. package/lib/cjs/interfaces/OnRequest.js +3 -0
  82. package/lib/cjs/interfaces/OnRequest.js.map +1 -0
  83. package/lib/cjs/interfaces/OnResponse.js +3 -0
  84. package/lib/cjs/interfaces/OnResponse.js.map +1 -0
  85. package/lib/cjs/interfaces/OnRoutesInit.js +3 -0
  86. package/lib/cjs/interfaces/OnRoutesInit.js.map +1 -0
  87. package/lib/cjs/interfaces/PathType.js +3 -0
  88. package/lib/cjs/interfaces/PathType.js.map +1 -0
  89. package/lib/cjs/interfaces/PlatformAdapter.js +3 -0
  90. package/lib/cjs/interfaces/PlatformAdapter.js.map +1 -0
  91. package/lib/cjs/interfaces/PlatformRouteOptions.js +3 -0
  92. package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -0
  93. package/lib/cjs/interfaces/ResponseErrorObject.js +3 -0
  94. package/lib/cjs/interfaces/ResponseErrorObject.js.map +1 -0
  95. package/lib/cjs/interfaces/Route.js +3 -0
  96. package/lib/cjs/interfaces/Route.js.map +1 -0
  97. package/lib/cjs/interfaces/index.js +21 -0
  98. package/lib/cjs/interfaces/index.js.map +1 -0
  99. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +37 -0
  100. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
  101. package/lib/cjs/middlewares/PlatformMulterMiddleware.js +55 -0
  102. package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -0
  103. package/lib/cjs/middlewares/__mock__/FakeCtrl.js +12 -0
  104. package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +1 -0
  105. package/lib/cjs/middlewares/bindEndpointMiddleware.js +13 -0
  106. package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +1 -0
  107. package/lib/cjs/middlewares/index.js +7 -0
  108. package/lib/cjs/middlewares/index.js.map +1 -0
  109. package/lib/cjs/services/FakeRawDriver.js +26 -0
  110. package/lib/cjs/services/FakeRawDriver.js.map +1 -0
  111. package/lib/cjs/services/Platform.js +107 -0
  112. package/lib/cjs/services/Platform.js.map +1 -0
  113. package/lib/cjs/services/PlatformApplication.js +34 -0
  114. package/lib/cjs/services/PlatformApplication.js.map +1 -0
  115. package/lib/cjs/services/PlatformHandler.js +233 -0
  116. package/lib/cjs/services/PlatformHandler.js.map +1 -0
  117. package/lib/cjs/services/PlatformMiddlewaresChain.js +34 -0
  118. package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -0
  119. package/lib/cjs/services/PlatformRequest.js +138 -0
  120. package/lib/cjs/services/PlatformRequest.js.map +1 -0
  121. package/lib/cjs/services/PlatformResponse.js +271 -0
  122. package/lib/cjs/services/PlatformResponse.js.map +1 -0
  123. package/lib/cjs/services/PlatformRouter.js +126 -0
  124. package/lib/cjs/services/PlatformRouter.js.map +1 -0
  125. package/lib/cjs/services/PlatformTest.js +166 -0
  126. package/lib/cjs/services/PlatformTest.js.map +1 -0
  127. package/lib/cjs/services/index.js +12 -0
  128. package/lib/cjs/services/index.js.map +1 -0
  129. package/lib/cjs/utils/createContext.js +38 -0
  130. package/lib/cjs/utils/createContext.js.map +1 -0
  131. package/lib/cjs/utils/createHandlerMetadata.js +49 -0
  132. package/lib/cjs/utils/createHandlerMetadata.js.map +1 -0
  133. package/lib/cjs/utils/createHttpServer.js +34 -0
  134. package/lib/cjs/utils/createHttpServer.js.map +1 -0
  135. package/lib/cjs/utils/createHttpsServer.js +34 -0
  136. package/lib/cjs/utils/createHttpsServer.js.map +1 -0
  137. package/lib/cjs/utils/createInjector.js +38 -0
  138. package/lib/cjs/utils/createInjector.js.map +1 -0
  139. package/lib/cjs/utils/getConfiguration.js +42 -0
  140. package/lib/cjs/utils/getConfiguration.js.map +1 -0
  141. package/lib/cjs/utils/getStaticsOptions.js +21 -0
  142. package/lib/cjs/utils/getStaticsOptions.js.map +1 -0
  143. package/lib/cjs/utils/index.js +11 -0
  144. package/lib/cjs/utils/index.js.map +1 -0
  145. package/lib/cjs/utils/listenServer.js +21 -0
  146. package/lib/cjs/utils/listenServer.js.map +1 -0
  147. package/lib/cjs/utils/mapReturnedResponse.js +15 -0
  148. package/lib/cjs/utils/mapReturnedResponse.js.map +1 -0
  149. package/lib/cjs/utils/printRoutes.js +36 -0
  150. package/lib/cjs/utils/printRoutes.js.map +1 -0
  151. package/lib/cjs/utils/setResponseHeaders.js +35 -0
  152. package/lib/cjs/utils/setResponseHeaders.js.map +1 -0
  153. package/lib/cjs/utils/useCtxHandler.js +15 -0
  154. package/lib/cjs/utils/useCtxHandler.js.map +1 -0
  155. package/lib/esm/builder/PlatformBuilder.js +271 -0
  156. package/lib/esm/builder/PlatformBuilder.js.map +1 -0
  157. package/lib/esm/builder/PlatformControllerBuilder.js +79 -0
  158. package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -0
  159. package/lib/esm/config/index.js +4 -0
  160. package/lib/esm/config/index.js.map +1 -0
  161. package/lib/esm/config/interfaces/ConverterSettings.js +2 -0
  162. package/lib/esm/config/interfaces/ConverterSettings.js.map +1 -0
  163. package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js +2 -0
  164. package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js.map +1 -0
  165. package/lib/esm/config/interfaces/PlatformLoggerSettings.js +2 -0
  166. package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -0
  167. package/lib/esm/config/interfaces/PlatformMulterSettings.js +2 -0
  168. package/lib/esm/config/interfaces/PlatformMulterSettings.js.map +1 -0
  169. package/lib/esm/config/interfaces/PlatformStaticsSettings.js +2 -0
  170. package/lib/esm/config/interfaces/PlatformStaticsSettings.js.map +1 -0
  171. package/lib/esm/config/interfaces/index.js +5 -0
  172. package/lib/esm/config/interfaces/index.js.map +1 -0
  173. package/lib/esm/config/services/PlatformConfiguration.js +178 -0
  174. package/lib/esm/config/services/PlatformConfiguration.js.map +1 -0
  175. package/lib/esm/constants/routerOptions.js +2 -0
  176. package/lib/esm/constants/routerOptions.js.map +1 -0
  177. package/lib/esm/decorators/httpServer.js +28 -0
  178. package/lib/esm/decorators/httpServer.js.map +1 -0
  179. package/lib/esm/decorators/httpsServer.js +28 -0
  180. package/lib/esm/decorators/httpsServer.js.map +1 -0
  181. package/lib/esm/decorators/index.js +14 -0
  182. package/lib/esm/decorators/index.js.map +1 -0
  183. package/lib/esm/decorators/method/acceptMime.js +24 -0
  184. package/lib/esm/decorators/method/acceptMime.js.map +1 -0
  185. package/lib/esm/decorators/multer/index.js +4 -0
  186. package/lib/esm/decorators/multer/index.js.map +1 -0
  187. package/lib/esm/decorators/multer/multerFileSize.js +31 -0
  188. package/lib/esm/decorators/multer/multerFileSize.js.map +1 -0
  189. package/lib/esm/decorators/multer/multerOptions.js +48 -0
  190. package/lib/esm/decorators/multer/multerOptions.js.map +1 -0
  191. package/lib/esm/decorators/multer/multipartFile.js +74 -0
  192. package/lib/esm/decorators/multer/multipartFile.js.map +1 -0
  193. package/lib/esm/decorators/params/error.js +16 -0
  194. package/lib/esm/decorators/params/error.js.map +1 -0
  195. package/lib/esm/decorators/params/next.js +17 -0
  196. package/lib/esm/decorators/params/next.js.map +1 -0
  197. package/lib/esm/decorators/params/request.js +34 -0
  198. package/lib/esm/decorators/params/request.js.map +1 -0
  199. package/lib/esm/decorators/params/response.js +28 -0
  200. package/lib/esm/decorators/params/response.js.map +1 -0
  201. package/lib/esm/domain/AnyToPromiseWithCtx.js +23 -0
  202. package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -0
  203. package/lib/esm/domain/ControllerProvider.js +47 -0
  204. package/lib/esm/domain/ControllerProvider.js.map +1 -0
  205. package/lib/esm/domain/EndpointMetadata.js +67 -0
  206. package/lib/esm/domain/EndpointMetadata.js.map +1 -0
  207. package/lib/esm/domain/HandlerMetadata.js +53 -0
  208. package/lib/esm/domain/HandlerMetadata.js.map +1 -0
  209. package/lib/esm/domain/PlatformContext.js +88 -0
  210. package/lib/esm/domain/PlatformContext.js.map +1 -0
  211. package/lib/esm/domain/PlatformRouteDetails.js +20 -0
  212. package/lib/esm/domain/PlatformRouteDetails.js.map +1 -0
  213. package/lib/esm/domain/index.js +7 -0
  214. package/lib/esm/domain/index.js.map +1 -0
  215. package/lib/esm/index.js +28 -0
  216. package/lib/esm/index.js.map +1 -0
  217. package/lib/esm/interfaces/AfterInit.js +2 -0
  218. package/lib/esm/interfaces/AfterInit.js.map +1 -0
  219. package/lib/esm/interfaces/AfterListen.js +2 -0
  220. package/lib/esm/interfaces/AfterListen.js.map +1 -0
  221. package/lib/esm/interfaces/AfterRoutesInit.js +2 -0
  222. package/lib/esm/interfaces/AfterRoutesInit.js.map +1 -0
  223. package/lib/esm/interfaces/BeforeInit.js +2 -0
  224. package/lib/esm/interfaces/BeforeInit.js.map +1 -0
  225. package/lib/esm/interfaces/BeforeListen.js +2 -0
  226. package/lib/esm/interfaces/BeforeListen.js.map +1 -0
  227. package/lib/esm/interfaces/BeforeRoutesInit.js +2 -0
  228. package/lib/esm/interfaces/BeforeRoutesInit.js.map +1 -0
  229. package/lib/esm/interfaces/HandlerType.js +14 -0
  230. package/lib/esm/interfaces/HandlerType.js.map +1 -0
  231. package/lib/esm/interfaces/IncomingEvent.js +2 -0
  232. package/lib/esm/interfaces/IncomingEvent.js.map +1 -0
  233. package/lib/esm/interfaces/OnReady.js +2 -0
  234. package/lib/esm/interfaces/OnReady.js.map +1 -0
  235. package/lib/esm/interfaces/OnRequest.js +2 -0
  236. package/lib/esm/interfaces/OnRequest.js.map +1 -0
  237. package/lib/esm/interfaces/OnResponse.js +2 -0
  238. package/lib/esm/interfaces/OnResponse.js.map +1 -0
  239. package/lib/esm/interfaces/OnRoutesInit.js +2 -0
  240. package/lib/esm/interfaces/OnRoutesInit.js.map +1 -0
  241. package/lib/esm/interfaces/PathType.js +2 -0
  242. package/lib/esm/interfaces/PathType.js.map +1 -0
  243. package/lib/esm/interfaces/PlatformAdapter.js +2 -0
  244. package/lib/esm/interfaces/PlatformAdapter.js.map +1 -0
  245. package/lib/esm/interfaces/PlatformRouteOptions.js +2 -0
  246. package/lib/esm/interfaces/PlatformRouteOptions.js.map +1 -0
  247. package/lib/esm/interfaces/ResponseErrorObject.js +2 -0
  248. package/lib/esm/interfaces/ResponseErrorObject.js.map +1 -0
  249. package/lib/esm/interfaces/Route.js +2 -0
  250. package/lib/esm/interfaces/Route.js.map +1 -0
  251. package/lib/esm/interfaces/index.js +18 -0
  252. package/lib/esm/interfaces/index.js.map +1 -0
  253. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +34 -0
  254. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
  255. package/lib/esm/middlewares/PlatformMulterMiddleware.js +52 -0
  256. package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -0
  257. package/lib/esm/middlewares/__mock__/FakeCtrl.js +9 -0
  258. package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +1 -0
  259. package/lib/esm/middlewares/bindEndpointMiddleware.js +9 -0
  260. package/lib/esm/middlewares/bindEndpointMiddleware.js.map +1 -0
  261. package/lib/esm/middlewares/index.js +4 -0
  262. package/lib/esm/middlewares/index.js.map +1 -0
  263. package/lib/esm/services/FakeRawDriver.js +22 -0
  264. package/lib/esm/services/FakeRawDriver.js.map +1 -0
  265. package/lib/esm/services/Platform.js +104 -0
  266. package/lib/esm/services/Platform.js.map +1 -0
  267. package/lib/esm/services/PlatformApplication.js +31 -0
  268. package/lib/esm/services/PlatformApplication.js.map +1 -0
  269. package/lib/esm/services/PlatformHandler.js +230 -0
  270. package/lib/esm/services/PlatformHandler.js.map +1 -0
  271. package/lib/esm/services/PlatformMiddlewaresChain.js +31 -0
  272. package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -0
  273. package/lib/esm/services/PlatformRequest.js +135 -0
  274. package/lib/esm/services/PlatformRequest.js.map +1 -0
  275. package/lib/esm/services/PlatformResponse.js +268 -0
  276. package/lib/esm/services/PlatformResponse.js.map +1 -0
  277. package/lib/esm/services/PlatformRouter.js +123 -0
  278. package/lib/esm/services/PlatformRouter.js.map +1 -0
  279. package/lib/esm/services/PlatformTest.js +162 -0
  280. package/lib/esm/services/PlatformTest.js.map +1 -0
  281. package/lib/esm/services/index.js +9 -0
  282. package/lib/esm/services/index.js.map +1 -0
  283. package/lib/esm/utils/createContext.js +34 -0
  284. package/lib/esm/utils/createContext.js.map +1 -0
  285. package/lib/esm/utils/createHandlerMetadata.js +45 -0
  286. package/lib/esm/utils/createHandlerMetadata.js.map +1 -0
  287. package/lib/esm/utils/createHttpServer.js +29 -0
  288. package/lib/esm/utils/createHttpServer.js.map +1 -0
  289. package/lib/esm/utils/createHttpsServer.js +29 -0
  290. package/lib/esm/utils/createHttpsServer.js.map +1 -0
  291. package/lib/esm/utils/createInjector.js +34 -0
  292. package/lib/esm/utils/createInjector.js.map +1 -0
  293. package/lib/esm/utils/getConfiguration.js +38 -0
  294. package/lib/esm/utils/getConfiguration.js.map +1 -0
  295. package/lib/esm/utils/getStaticsOptions.js +17 -0
  296. package/lib/esm/utils/getStaticsOptions.js.map +1 -0
  297. package/lib/esm/utils/index.js +8 -0
  298. package/lib/esm/utils/index.js.map +1 -0
  299. package/lib/esm/utils/listenServer.js +17 -0
  300. package/lib/esm/utils/listenServer.js.map +1 -0
  301. package/lib/esm/utils/mapReturnedResponse.js +11 -0
  302. package/lib/esm/utils/mapReturnedResponse.js.map +1 -0
  303. package/lib/esm/utils/printRoutes.js +32 -0
  304. package/lib/esm/utils/printRoutes.js.map +1 -0
  305. package/lib/esm/utils/setResponseHeaders.js +31 -0
  306. package/lib/esm/utils/setResponseHeaders.js.map +1 -0
  307. package/lib/esm/utils/useCtxHandler.js +11 -0
  308. package/lib/esm/utils/useCtxHandler.js.map +1 -0
  309. package/lib/{builder → types/builder}/PlatformBuilder.d.ts +25 -30
  310. package/lib/types/builder/PlatformControllerBuilder.d.ts +17 -0
  311. package/lib/{config → types/config}/index.d.ts +0 -0
  312. package/lib/{config → types/config}/interfaces/ConverterSettings.d.ts +0 -0
  313. package/lib/{config → types/config}/interfaces/EndpointDirectoriesSettings.d.ts +0 -0
  314. package/lib/{config → types/config}/interfaces/PlatformLoggerSettings.d.ts +0 -16
  315. package/lib/{config → types/config}/interfaces/PlatformMulterSettings.d.ts +0 -0
  316. package/lib/{config → types/config}/interfaces/PlatformStaticsSettings.d.ts +1 -0
  317. package/lib/{config → types/config}/interfaces/index.d.ts +17 -2
  318. package/lib/{config → types/config}/services/PlatformConfiguration.d.ts +13 -11
  319. package/lib/{constants → types/constants}/routerOptions.d.ts +0 -0
  320. package/lib/{decorators → types/decorators}/httpServer.d.ts +1 -0
  321. package/lib/{decorators → types/decorators}/httpsServer.d.ts +1 -0
  322. package/lib/{decorators → types/decorators}/index.d.ts +1 -5
  323. package/lib/{decorators → types/decorators}/method/acceptMime.d.ts +0 -0
  324. package/lib/{decorators → types/decorators}/multer/index.d.ts +0 -0
  325. package/lib/{decorators → types/decorators}/multer/multerFileSize.d.ts +0 -0
  326. package/lib/{decorators → types/decorators}/multer/multerOptions.d.ts +0 -0
  327. package/lib/{decorators → types/decorators}/multer/multipartFile.d.ts +0 -0
  328. package/lib/{decorators → types/decorators}/params/error.d.ts +0 -0
  329. package/lib/{decorators → types/decorators}/params/next.d.ts +0 -0
  330. package/lib/{decorators → types/decorators}/params/request.d.ts +0 -0
  331. package/lib/{decorators → types/decorators}/params/response.d.ts +0 -0
  332. package/lib/{domain → types/domain}/AnyToPromiseWithCtx.d.ts +0 -0
  333. package/lib/types/domain/ControllerProvider.d.ts +24 -0
  334. package/lib/{domain → types/domain}/EndpointMetadata.d.ts +3 -42
  335. package/lib/{domain → types/domain}/HandlerMetadata.d.ts +2 -2
  336. package/lib/{domain → types/domain}/PlatformContext.d.ts +1 -1
  337. package/lib/{domain → types/domain}/PlatformRouteDetails.d.ts +4 -10
  338. package/lib/{domain → types/domain}/index.d.ts +0 -0
  339. package/lib/{index.d.ts → types/index.d.ts} +2 -3
  340. package/lib/{interfaces → types/interfaces}/AfterInit.d.ts +0 -0
  341. package/lib/{interfaces → types/interfaces}/AfterListen.d.ts +0 -0
  342. package/lib/{interfaces → types/interfaces}/AfterRoutesInit.d.ts +0 -0
  343. package/lib/{interfaces → types/interfaces}/BeforeInit.d.ts +0 -0
  344. package/lib/{interfaces → types/interfaces}/BeforeListen.d.ts +0 -0
  345. package/lib/{interfaces → types/interfaces}/BeforeRoutesInit.d.ts +0 -0
  346. package/lib/{interfaces → types/interfaces}/HandlerType.d.ts +0 -0
  347. package/lib/{interfaces → types/interfaces}/IncomingEvent.d.ts +0 -0
  348. package/lib/{interfaces → types/interfaces}/OnReady.d.ts +0 -0
  349. package/lib/{interfaces → types/interfaces}/OnRequest.d.ts +0 -0
  350. package/lib/{interfaces → types/interfaces}/OnResponse.d.ts +0 -0
  351. package/lib/{interfaces → types/interfaces}/OnRoutesInit.d.ts +0 -0
  352. package/lib/{interfaces → types/interfaces}/PathType.d.ts +0 -0
  353. package/lib/types/interfaces/PlatformAdapter.d.ts +19 -0
  354. package/lib/{interfaces → types/interfaces}/PlatformRouteOptions.d.ts +5 -3
  355. package/lib/{interfaces → types/interfaces}/ResponseErrorObject.d.ts +0 -0
  356. package/lib/{interfaces → types/interfaces}/Route.d.ts +0 -0
  357. package/lib/{interfaces → types/interfaces}/index.d.ts +1 -2
  358. package/lib/{middlewares → types/middlewares}/PlatformAcceptMimesMiddleware.d.ts +0 -0
  359. package/lib/{middlewares → types/middlewares}/PlatformMulterMiddleware.d.ts +0 -0
  360. package/lib/{middlewares/data → types/middlewares/__mock__}/FakeCtrl.d.ts +0 -0
  361. package/lib/{middlewares → types/middlewares}/bindEndpointMiddleware.d.ts +0 -0
  362. package/lib/{middlewares → types/middlewares}/index.d.ts +0 -1
  363. package/lib/{services → types/services}/FakeRawDriver.d.ts +0 -0
  364. package/lib/{services → types/services}/Platform.d.ts +12 -6
  365. package/lib/{services → types/services}/PlatformApplication.d.ts +0 -0
  366. package/lib/{services → types/services}/PlatformHandler.d.ts +3 -8
  367. package/lib/types/services/PlatformMiddlewaresChain.d.ts +6 -0
  368. package/lib/{services → types/services}/PlatformRequest.d.ts +2 -1
  369. package/lib/{services → types/services}/PlatformResponse.d.ts +4 -4
  370. package/lib/{services → types/services}/PlatformRouter.d.ts +4 -3
  371. package/lib/{services → types/services}/PlatformTest.d.ts +7 -6
  372. package/lib/{services → types/services}/index.d.ts +1 -1
  373. package/lib/{utils → types/utils}/createContext.d.ts +0 -0
  374. package/lib/{utils → types/utils}/createHandlerMetadata.d.ts +0 -0
  375. package/lib/types/utils/createHttpServer.d.ts +4 -0
  376. package/lib/types/utils/createHttpsServer.d.ts +4 -0
  377. package/lib/types/utils/createInjector.d.ts +7 -0
  378. package/lib/types/utils/getConfiguration.d.ts +2 -0
  379. package/lib/types/utils/getStaticsOptions.d.ts +5 -0
  380. package/lib/{utils → types/utils}/index.d.ts +0 -1
  381. package/lib/types/utils/listenServer.d.ts +7 -0
  382. package/lib/{utils → types/utils}/mapReturnedResponse.d.ts +0 -0
  383. package/lib/{utils → types/utils}/printRoutes.d.ts +0 -0
  384. package/lib/{utils → types/utils}/setResponseHeaders.d.ts +0 -0
  385. package/lib/{utils → types/utils}/useCtxHandler.d.ts +0 -0
  386. package/package.json +29 -24
  387. package/tsconfig.compile.esm.json +23 -0
  388. package/lib/PlatformModule.d.ts +0 -15
  389. package/lib/builder/PlatformControllerBuilder.d.ts +0 -19
  390. package/lib/decorators/class/controller.d.ts +0 -43
  391. package/lib/decorators/method/endpointFn.d.ts +0 -8
  392. package/lib/decorators/method/location.d.ts +0 -1
  393. package/lib/decorators/method/redirect.d.ts +0 -1
  394. package/lib/decorators/method/route.d.ts +0 -128
  395. package/lib/domain/ControllerProvider.d.ts +0 -54
  396. package/lib/index.js +0 -3990
  397. package/lib/index.js.map +0 -1
  398. package/lib/index.modern.js +0 -3870
  399. package/lib/index.modern.js.map +0 -1
  400. package/lib/interfaces/PlatformRouterMethods.d.ts +0 -10
  401. package/lib/middlewares/PlatformLogMiddleware.d.ts +0 -44
  402. package/lib/registries/ControllerRegistry.d.ts +0 -1
  403. package/lib/services/ConverterService.d.ts +0 -27
  404. package/lib/utils/createHttpServer.d.ts +0 -3
  405. package/lib/utils/createHttpsServer.d.ts +0 -3
  406. package/lib/utils/createInjector.d.ts +0 -2
  407. package/lib/utils/createPlatformApplication.d.ts +0 -2
  408. package/lib/utils/getControllerPath.d.ts +0 -2
  409. package/lib/utils/listenServer.d.ts +0 -10
@@ -0,0 +1,271 @@
1
+ var _PlatformBuilder_injector, _PlatformBuilder_rootModule, _PlatformBuilder_promise, _PlatformBuilder_adapter, _PlatformBuilder_servers;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
+ import { nameOf } from "@tsed/core";
4
+ import { colors, createContainer, ProviderScope, setLoggerLevel } from "@tsed/di";
5
+ import { importProviders } from "@tsed/components-scan";
6
+ import { getMiddlewaresForHook } from "@tsed/platform-middlewares";
7
+ import { Platform } from "../services/Platform";
8
+ import { PlatformApplication } from "../services/PlatformApplication";
9
+ import { createHttpServer, createHttpsServer, createInjector, printRoutes } from "../utils";
10
+ import { getStaticsOptions } from "../utils/getStaticsOptions";
11
+ import { getConfiguration } from "../utils/getConfiguration";
12
+ /**
13
+ * @platform
14
+ */
15
+ export class PlatformBuilder {
16
+ constructor(adapter, module, settings) {
17
+ this.name = "";
18
+ this.startedAt = new Date();
19
+ this.current = new Date();
20
+ _PlatformBuilder_injector.set(this, void 0);
21
+ _PlatformBuilder_rootModule.set(this, void 0);
22
+ _PlatformBuilder_promise.set(this, void 0);
23
+ _PlatformBuilder_adapter.set(this, void 0);
24
+ _PlatformBuilder_servers.set(this, void 0);
25
+ __classPrivateFieldSet(this, _PlatformBuilder_rootModule, module, "f");
26
+ const adapterKlass = adapter || PlatformBuilder.adapter;
27
+ const name = nameOf(adapterKlass).replace("Platform", "").toLowerCase();
28
+ const configuration = getConfiguration(settings, module);
29
+ configuration.PLATFORM_NAME = name;
30
+ this.name = name;
31
+ __classPrivateFieldSet(this, _PlatformBuilder_adapter, new adapterKlass(this), "f");
32
+ __classPrivateFieldSet(this, _PlatformBuilder_injector, createInjector({
33
+ settings: configuration,
34
+ providers: __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").providers
35
+ }), "f");
36
+ this.createHttpServers();
37
+ __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").onInit && __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").onInit();
38
+ this.log("Injector created...");
39
+ }
40
+ get injector() {
41
+ return __classPrivateFieldGet(this, _PlatformBuilder_injector, "f");
42
+ }
43
+ get rootModule() {
44
+ return __classPrivateFieldGet(this, _PlatformBuilder_injector, "f").get(__classPrivateFieldGet(this, _PlatformBuilder_rootModule, "f"));
45
+ }
46
+ get app() {
47
+ return this.injector.get(PlatformApplication);
48
+ }
49
+ get platform() {
50
+ return this.injector.get(Platform);
51
+ }
52
+ /**
53
+ * Return the settings configured by the decorator @@Configuration@@.
54
+ *
55
+ * ```typescript
56
+ * @Configuration({
57
+ * rootDir: Path.resolve(__dirname),
58
+ * port: 8000,
59
+ * httpsPort: 8080,
60
+ * mount: {
61
+ * "/rest": "${rootDir}/controllers/**\/*.js"
62
+ * }
63
+ * })
64
+ * export class Server {
65
+ * $onInit(){
66
+ * console.log(this.settings); // {rootDir, port, httpsPort,...}
67
+ * }
68
+ * }
69
+ * ```
70
+ *
71
+ * @returns {PlatformConfiguration}
72
+ */
73
+ get settings() {
74
+ return this.injector.settings;
75
+ }
76
+ get logger() {
77
+ return this.injector.logger;
78
+ }
79
+ get disableBootstrapLog() {
80
+ var _a;
81
+ return (_a = this.settings.logger) === null || _a === void 0 ? void 0 : _a.disableBootstrapLog;
82
+ }
83
+ static create(module, settings) {
84
+ return this.build(module, {
85
+ httpsPort: false,
86
+ httpPort: false,
87
+ ...settings,
88
+ disableComponentsScan: true
89
+ });
90
+ }
91
+ static build(module, { adapter, ...settings }) {
92
+ return new PlatformBuilder(adapter, module, settings);
93
+ }
94
+ /**
95
+ * Bootstrap a server application
96
+ * @param module
97
+ * @param settings
98
+ */
99
+ static async bootstrap(module, settings) {
100
+ return this.build(module, settings).bootstrap();
101
+ }
102
+ callback(req, res) {
103
+ if (req && res) {
104
+ return this.app.callback()(req, res);
105
+ }
106
+ return this.app.callback();
107
+ }
108
+ log(...data) {
109
+ return !this.disableBootstrapLog && this.logger.info(...data, this.diff());
110
+ }
111
+ /**
112
+ * Add classes to the components list
113
+ * @param classes
114
+ */
115
+ addComponents(classes) {
116
+ this.settings.componentsScan = this.settings.componentsScan.concat(classes);
117
+ return this;
118
+ }
119
+ /**
120
+ * Add classes decorated by @@Controller@@ to components container.
121
+ *
122
+ * ### Example
123
+ *
124
+ * ```typescript
125
+ * @Controller('/ctrl')
126
+ * class MyController{
127
+ * }
128
+ *
129
+ * platform.addControllers('/rest', [MyController])
130
+ * ```
131
+ *
132
+ * ::: tip
133
+ * If the MyController class isn't decorated, the class will be ignored.
134
+ * :::
135
+ *
136
+ * @param {string} endpoint
137
+ * @param {any[]} controllers
138
+ */
139
+ addControllers(endpoint, controllers) {
140
+ this.settings.mount[endpoint] = (this.settings.mount[endpoint] || []).concat(controllers);
141
+ }
142
+ async runLifecycle() {
143
+ setLoggerLevel(this.injector);
144
+ await this.importProviders();
145
+ await this.loadInjector();
146
+ __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").useContext && __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").useContext();
147
+ __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").useRouter && __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").useRouter();
148
+ await this.loadRoutes();
149
+ await this.logRoutes();
150
+ return this;
151
+ }
152
+ async loadInjector() {
153
+ const { injector } = this;
154
+ this.log("Build providers");
155
+ const container = createContainer();
156
+ container.addProvider(__classPrivateFieldGet(this, _PlatformBuilder_rootModule, "f"), {
157
+ type: "server:module",
158
+ scope: ProviderScope.SINGLETON
159
+ });
160
+ await injector.load(container);
161
+ this.log("Settings and injector loaded...");
162
+ await this.callHook("$afterInit");
163
+ }
164
+ async listen(network = true) {
165
+ if (!__classPrivateFieldGet(this, _PlatformBuilder_promise, "f")) {
166
+ await this.bootstrap();
167
+ }
168
+ await this.callHook("$beforeListen");
169
+ if (network) {
170
+ await this.listenServers();
171
+ }
172
+ await this.callHook("$afterListen");
173
+ await this.ready();
174
+ }
175
+ async stop() {
176
+ await this.callHook("$onDestroy");
177
+ return this.injector.destroy();
178
+ }
179
+ async ready() {
180
+ const { startedAt } = this;
181
+ await this.callHook("$onReady");
182
+ await this.injector.emit("$onServerReady");
183
+ this.log(`Started in ${new Date().getTime() - startedAt.getTime()} ms`);
184
+ }
185
+ async callHook(hook, ...args) {
186
+ const { injector } = this;
187
+ if (!this.disableBootstrapLog) {
188
+ injector.logger.debug(`\x1B[1mCall hook ${hook}\x1B[22m`);
189
+ }
190
+ // Load middlewares for the given hook
191
+ this.loadMiddlewaresFor(hook);
192
+ // call hooks added by providers
193
+ await injector.emit(hook, ...args);
194
+ }
195
+ async loadStatics(hook) {
196
+ const statics = this.settings.get("statics");
197
+ getStaticsOptions(statics).forEach(({ path, options }) => {
198
+ if (options.hook === hook) {
199
+ this.platform.app.statics(path, options);
200
+ }
201
+ });
202
+ }
203
+ useProvider(token, settings) {
204
+ this.injector.addProvider(token, settings);
205
+ return this;
206
+ }
207
+ async bootstrap() {
208
+ __classPrivateFieldSet(this, _PlatformBuilder_promise, __classPrivateFieldGet(this, _PlatformBuilder_promise, "f") || this.runLifecycle(), "f");
209
+ return __classPrivateFieldGet(this, _PlatformBuilder_promise, "f");
210
+ }
211
+ async loadRoutes() {
212
+ var _a;
213
+ __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").beforeLoadRoutes && (await __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").beforeLoadRoutes());
214
+ // istanbul ignore next
215
+ if (((_a = this.settings.logger) === null || _a === void 0 ? void 0 : _a.level) !== "off") {
216
+ const { PlatformLogMiddleware } = await import("@tsed/platform-log-middleware");
217
+ this.app.use(PlatformLogMiddleware);
218
+ }
219
+ this.log("Load routes");
220
+ if (this.rootModule.$beforeRoutesInit) {
221
+ await this.rootModule.$beforeRoutesInit();
222
+ this.rootModule.$beforeRoutesInit = () => { };
223
+ }
224
+ await this.loadStatics("$beforeRoutesInit");
225
+ await this.callHook("$beforeRoutesInit");
226
+ const routes = this.injector.settings.get("routes");
227
+ this.platform.addRoutes(routes);
228
+ await this.callHook("$onRoutesInit");
229
+ await this.loadStatics("$afterRoutesInit");
230
+ await this.callHook("$afterRoutesInit");
231
+ __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").afterLoadRoutes && (await __classPrivateFieldGet(this, _PlatformBuilder_adapter, "f").afterLoadRoutes());
232
+ }
233
+ diff() {
234
+ const ms = colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);
235
+ this.current = new Date();
236
+ return ms;
237
+ }
238
+ async importProviders() {
239
+ this.injector.logger.debug("Scan components");
240
+ const providers = await importProviders(this.injector.settings, ["imports", "mount", "componentsScan"]);
241
+ const routes = providers.filter((provider) => !!provider.route).map(({ route, token }) => ({ route, token }));
242
+ this.settings.set("routes", routes);
243
+ this.log("Providers loaded...");
244
+ }
245
+ /**
246
+ * Load middlewares from configuration for the given hook
247
+ * @param hook
248
+ * @protected
249
+ */
250
+ loadMiddlewaresFor(hook) {
251
+ return getMiddlewaresForHook(hook, this.settings, "$beforeRoutesInit").forEach(({ use }) => {
252
+ this.app.use(use);
253
+ });
254
+ }
255
+ createHttpServers() {
256
+ __classPrivateFieldSet(this, _PlatformBuilder_servers, [createHttpServer(__classPrivateFieldGet(this, _PlatformBuilder_injector, "f"), this.callback()), createHttpsServer(__classPrivateFieldGet(this, _PlatformBuilder_injector, "f"), this.callback())].filter(Boolean), "f");
257
+ }
258
+ async listenServers() {
259
+ await Promise.all(__classPrivateFieldGet(this, _PlatformBuilder_servers, "f").map((cb) => cb && cb()));
260
+ }
261
+ async logRoutes() {
262
+ var _a;
263
+ const { logger, platform } = this;
264
+ this.log("Routes mounted...");
265
+ if (!((_a = this.settings.logger) === null || _a === void 0 ? void 0 : _a.disableRoutesSummary) && !this.disableBootstrapLog) {
266
+ logger.info(printRoutes(await this.injector.alterAsync("$logRoutes", platform.getRoutes())));
267
+ }
268
+ }
269
+ }
270
+ _PlatformBuilder_injector = new WeakMap(), _PlatformBuilder_rootModule = new WeakMap(), _PlatformBuilder_promise = new WeakMap(), _PlatformBuilder_adapter = new WeakMap(), _PlatformBuilder_servers = new WeakMap();
271
+ //# sourceMappingURL=PlatformBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformBuilder.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,MAAM,EAAO,MAAM,YAAY,CAAC;AACxC,OAAO,EAAC,MAAM,EAAE,eAAe,EAA8B,aAAa,EAAE,cAAc,EAAC,MAAM,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,CAAC,OAAO,CAAC,CAAC,EAAC,GAAG,EAAC,EAAE,EAAE;YACvF,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC;IAES,iBAAiB;QACzB,uBAAA,IAAI,4BAAY,CAAC,gBAAgB,CAAC,uBAAA,IAAI,iCAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,iBAAiB,CAAC,uBAAA,IAAI,iCAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAC5H,OAAO,CACC,MAAA,CAAC;IACb,CAAC;IAES,KAAK,CAAC,aAAa;QAC3B,MAAM,OAAO,CAAC,GAAG,CAAC,uBAAA,IAAI,gCAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;IAES,KAAK,CAAC,SAAS;;QACvB,MAAM,EAAC,MAAM,EAAE,QAAQ,EAAC,GAAG,IAAI,CAAC;QAEhC,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAE9B,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,MAAM,0CAAE,oBAAoB,CAAA,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;YAC5E,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;SAC9F;IACH,CAAC;CACF","sourcesContent":["import {nameOf, Type} from \"@tsed/core\";\nimport {colors, createContainer, InjectorService, IProvider, ProviderScope, setLoggerLevel} from \"@tsed/di\";\nimport {importProviders} from \"@tsed/components-scan\";\nimport {getMiddlewaresForHook} from \"@tsed/platform-middlewares\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {createHttpServer, createHttpsServer, createInjector, printRoutes} from \"../utils\";\nimport {PlatformStaticsSettings} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {getStaticsOptions} from \"../utils/getStaticsOptions\";\nimport {Route} from \"../interfaces/Route\";\nimport {getConfiguration} from \"../utils/getConfiguration\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {PlatformAdapter, PlatformBuilderSettings} from \"../interfaces/PlatformAdapter\";\n\n/**\n * @platform\n */\nexport class PlatformBuilder<App = TsED.Application, Router = TsED.Router> {\n public static adapter: Type<PlatformAdapter>;\n\n readonly name: string = \"\";\n protected startedAt = new Date();\n protected current = new Date();\n\n #injector: InjectorService;\n #rootModule: Type<any>;\n #promise: Promise<this>;\n #adapter: PlatformAdapter<App, Router>;\n #servers: (() => Promise<void>)[];\n\n protected constructor(adapter: Type<PlatformAdapter<App, Router>> | undefined, module: Type, settings: Partial<TsED.Configuration>) {\n this.#rootModule = module;\n const adapterKlass = adapter || PlatformBuilder.adapter;\n const name = nameOf(adapterKlass).replace(\"Platform\", \"\").toLowerCase();\n\n const configuration = getConfiguration(settings, module);\n configuration.PLATFORM_NAME = name;\n this.name = name;\n this.#adapter = new adapterKlass(this);\n\n this.#injector = createInjector({\n settings: configuration,\n providers: this.#adapter.providers\n });\n\n this.createHttpServers();\n\n this.#adapter.onInit && this.#adapter.onInit();\n\n this.log(\"Injector created...\");\n }\n\n get injector(): InjectorService {\n return this.#injector;\n }\n\n get rootModule(): any {\n return this.#injector.get(this.#rootModule);\n }\n\n get app(): PlatformApplication<App, Router> {\n return this.injector.get<PlatformApplication<App, Router>>(PlatformApplication)!;\n }\n\n get platform() {\n return this.injector.get<Platform>(Platform)!;\n }\n\n /**\n * Return the settings configured by the decorator @@Configuration@@.\n *\n * ```typescript\n * @Configuration({\n * rootDir: Path.resolve(__dirname),\n * port: 8000,\n * httpsPort: 8080,\n * mount: {\n * \"/rest\": \"${rootDir}/controllers/**\\/*.js\"\n * }\n * })\n * export class Server {\n * $onInit(){\n * console.log(this.settings); // {rootDir, port, httpsPort,...}\n * }\n * }\n * ```\n *\n * @returns {PlatformConfiguration}\n */\n get settings() {\n return this.injector.settings;\n }\n\n get logger() {\n return this.injector.logger;\n }\n\n get disableBootstrapLog() {\n return this.settings.logger?.disableBootstrapLog;\n }\n\n static create<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>) {\n return this.build(module, {\n httpsPort: false,\n httpPort: false,\n ...settings,\n disableComponentsScan: true\n });\n }\n\n static build<App = TsED.Application, Router = TsED.Router>(\n module: Type<any>,\n {adapter, ...settings}: PlatformBuilderSettings<App, Router>\n ) {\n return new PlatformBuilder(adapter, module, settings);\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>) {\n return this.build<App, Router>(module, settings).bootstrap();\n }\n\n callback(): (req: IncomingMessage, res: ServerResponse) => void;\n callback(req: IncomingMessage, res: ServerResponse): void;\n callback(req?: IncomingMessage, res?: ServerResponse) {\n if (req && res) {\n return this.app.callback()(req, res);\n }\n\n return this.app.callback();\n }\n\n log(...data: any[]) {\n return !this.disableBootstrapLog && this.logger.info(...data, this.diff());\n }\n\n /**\n * Add classes to the components list\n * @param classes\n */\n public addComponents(classes: any | any[]) {\n this.settings.componentsScan = this.settings.componentsScan.concat(classes);\n\n return this;\n }\n\n /**\n * Add classes decorated by @@Controller@@ to components container.\n *\n * ### Example\n *\n * ```typescript\n * @Controller('/ctrl')\n * class MyController{\n * }\n *\n * platform.addControllers('/rest', [MyController])\n * ```\n *\n * ::: tip\n * If the MyController class isn't decorated, the class will be ignored.\n * :::\n *\n * @param {string} endpoint\n * @param {any[]} controllers\n */\n public addControllers(endpoint: string, controllers: any | string | (any | string)[]) {\n this.settings.mount[endpoint] = (this.settings.mount[endpoint] || []).concat(controllers);\n }\n\n public async runLifecycle() {\n setLoggerLevel(this.injector);\n\n await this.importProviders();\n await this.loadInjector();\n\n this.#adapter.useContext && this.#adapter.useContext();\n this.#adapter.useRouter && this.#adapter.useRouter();\n\n await this.loadRoutes();\n await this.logRoutes();\n\n return this;\n }\n\n async loadInjector() {\n const {injector} = this;\n this.log(\"Build providers\");\n\n const container = createContainer();\n\n container.addProvider(this.#rootModule, {\n type: \"server:module\",\n scope: ProviderScope.SINGLETON\n });\n\n await injector.load(container);\n\n this.log(\"Settings and injector loaded...\");\n\n await this.callHook(\"$afterInit\");\n }\n\n async listen(network = true) {\n if (!this.#promise) {\n await this.bootstrap();\n }\n\n await this.callHook(\"$beforeListen\");\n\n if (network) {\n await this.listenServers();\n }\n\n await this.callHook(\"$afterListen\");\n\n await this.ready();\n }\n\n async stop() {\n await this.callHook(\"$onDestroy\");\n return this.injector.destroy();\n }\n\n public async ready() {\n const {startedAt} = this;\n\n await this.callHook(\"$onReady\");\n await this.injector.emit(\"$onServerReady\");\n\n this.log(`Started in ${new Date().getTime() - startedAt.getTime()} ms`);\n }\n\n async callHook(hook: string, ...args: any[]) {\n const {injector} = this;\n\n if (!this.disableBootstrapLog) {\n injector.logger.debug(`\\x1B[1mCall hook ${hook}\\x1B[22m`);\n }\n\n // Load middlewares for the given hook\n this.loadMiddlewaresFor(hook);\n\n // call hooks added by providers\n await injector.emit(hook, ...args);\n }\n\n async loadStatics(hook: string): Promise<void> {\n const statics = this.settings.get<PlatformStaticsSettings>(\"statics\");\n\n getStaticsOptions(statics).forEach(({path, options}) => {\n if (options.hook === hook) {\n this.platform.app.statics(path, options);\n }\n });\n }\n\n useProvider(token: Type<any>, settings?: Partial<IProvider>) {\n this.injector.addProvider(token, settings);\n\n return this;\n }\n\n async bootstrap() {\n this.#promise = this.#promise || this.runLifecycle();\n\n return this.#promise;\n }\n\n protected async loadRoutes() {\n this.#adapter.beforeLoadRoutes && (await this.#adapter.beforeLoadRoutes());\n\n // istanbul ignore next\n if (this.settings.logger?.level !== \"off\") {\n const {PlatformLogMiddleware} = await import(\"@tsed/platform-log-middleware\");\n this.app.use(PlatformLogMiddleware);\n }\n\n this.log(\"Load routes\");\n\n if (this.rootModule.$beforeRoutesInit) {\n await this.rootModule.$beforeRoutesInit();\n this.rootModule.$beforeRoutesInit = () => {};\n }\n\n await this.loadStatics(\"$beforeRoutesInit\");\n await this.callHook(\"$beforeRoutesInit\");\n\n const routes = this.injector.settings.get<Route[]>(\"routes\");\n\n this.platform.addRoutes(routes);\n\n await this.callHook(\"$onRoutesInit\");\n\n await this.loadStatics(\"$afterRoutesInit\");\n\n await this.callHook(\"$afterRoutesInit\");\n\n this.#adapter.afterLoadRoutes && (await this.#adapter.afterLoadRoutes());\n }\n\n protected diff() {\n const ms = colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);\n this.current = new Date();\n return ms;\n }\n\n protected async importProviders() {\n this.injector.logger.debug(\"Scan components\");\n\n const providers = await importProviders(this.injector.settings, [\"imports\", \"mount\", \"componentsScan\"]);\n const routes = providers.filter((provider) => !!provider.route).map(({route, token}) => ({route, token}));\n\n this.settings.set(\"routes\", routes);\n this.log(\"Providers loaded...\");\n }\n\n /**\n * Load middlewares from configuration for the given hook\n * @param hook\n * @protected\n */\n protected loadMiddlewaresFor(hook: string): void {\n return getMiddlewaresForHook(hook, this.settings, \"$beforeRoutesInit\").forEach(({use}) => {\n this.app.use(use);\n });\n }\n\n protected createHttpServers() {\n this.#servers = [createHttpServer(this.#injector, this.callback()), createHttpsServer(this.#injector, this.callback())].filter(\n Boolean\n ) as any[];\n }\n\n protected async listenServers(): Promise<void> {\n await Promise.all(this.#servers.map((cb) => cb && cb()));\n }\n\n protected async logRoutes() {\n const {logger, platform} = this;\n\n this.log(\"Routes mounted...\");\n\n if (!this.settings.logger?.disableRoutesSummary && !this.disableBootstrapLog) {\n logger.info(printRoutes(await this.injector.alterAsync(\"$logRoutes\", platform.getRoutes())));\n }\n }\n}\n"]}
@@ -0,0 +1,79 @@
1
+ import { GlobalProviders, ProviderType } from "@tsed/di";
2
+ import { getOperationsRoutes, OperationMethods } from "@tsed/schema";
3
+ import { ControllerProvider } from "../domain/ControllerProvider";
4
+ import { PlatformRouter } from "../services/PlatformRouter";
5
+ import { PlatformMiddlewaresChain } from "../services/PlatformMiddlewaresChain";
6
+ GlobalProviders.createRegistry(ProviderType.CONTROLLER, ControllerProvider, {
7
+ onInvoke(provider, locals, { injector }) {
8
+ const router = createRouter(injector, provider);
9
+ locals.set(PlatformRouter, router);
10
+ }
11
+ });
12
+ /**
13
+ * @ignore
14
+ */
15
+ function formatMethod(method) {
16
+ return (method === OperationMethods.CUSTOM ? "use" : method || "use").toLowerCase();
17
+ }
18
+ /**
19
+ * @ignore
20
+ */
21
+ export function getRouter(injector, provider) {
22
+ return injector.get(provider.tokenRouter);
23
+ }
24
+ /**
25
+ * @ignore
26
+ */
27
+ export function createRouter(injector, provider) {
28
+ const token = provider.tokenRouter;
29
+ if (injector.has(token)) {
30
+ return getRouter(injector, provider);
31
+ }
32
+ const router = PlatformRouter.create(injector, provider.routerOptions);
33
+ return injector
34
+ .add(token, {
35
+ useValue: router
36
+ })
37
+ .invoke(token);
38
+ }
39
+ /**
40
+ * @ignore
41
+ * @param injector
42
+ * @param provider
43
+ */
44
+ export function buildRouter(injector, provider) {
45
+ const { middlewares: { useBefore }, children } = provider;
46
+ // Controller lifecycle
47
+ const router = createRouter(injector, provider);
48
+ if (!router.isBuilt) {
49
+ router.isBuilt = true;
50
+ const platformMiddlewaresChain = injector.get(PlatformMiddlewaresChain);
51
+ useBefore // Controller before-middleware
52
+ .filter((o) => typeof o === "function")
53
+ .forEach((middleware) => {
54
+ router.use(middleware);
55
+ });
56
+ // build all endpoints and his middlewares
57
+ getOperationsRoutes(provider.token).forEach((operationRoute) => {
58
+ const handlers = platformMiddlewaresChain === null || platformMiddlewaresChain === void 0 ? void 0 : platformMiddlewaresChain.get(provider, operationRoute);
59
+ router.addRoute({
60
+ handlers,
61
+ token: operationRoute.token,
62
+ method: formatMethod(operationRoute.method),
63
+ path: operationRoute.path,
64
+ isFinal: operationRoute.isFinal
65
+ });
66
+ });
67
+ // build children controllers
68
+ children.forEach((child) => {
69
+ const childProvider = injector.getProvider(child);
70
+ /* istanbul ignore next */
71
+ if (!childProvider) {
72
+ throw new Error("Controller component not found in the ControllerRegistry");
73
+ }
74
+ router.use(childProvider.path, buildRouter(injector, childProvider));
75
+ });
76
+ }
77
+ return router;
78
+ }
79
+ //# sourceMappingURL=PlatformControllerBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformControllerBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformControllerBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAmB,YAAY,EAAC,MAAM,UAAU,CAAC;AACxE,OAAO,EAAC,mBAAmB,EAAE,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACnE,OAAO,EAAC,kBAAkB,EAAC,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAC,wBAAwB,EAAC,MAAM,sCAAsC,CAAC;AAE9E,eAAe,CAAC,cAAc,CAAC,YAAY,CAAC,UAAU,EAAE,kBAAkB,EAAE;IAC1E,QAAQ,CAAC,QAA4B,EAAE,MAAW,EAAE,EAAC,QAAQ,EAAC;QAC5D,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;CACF,CAAC,CAAC;AAEH;;GAEG;AACH,SAAS,YAAY,CAAC,MAA0B;IAC9C,OAAO,CAAC,MAAM,KAAK,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACtF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,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C,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE;YAC/E,MAAM,QAAQ,GAAG,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAE,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;YAEzE,MAAM,CAAC,QAAQ,CAAC;gBACd,QAAQ;gBACR,KAAK,EAAE,cAAc,CAAC,KAAK;gBAC3B,MAAM,EAAE,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC;gBAC3C,IAAI,EAAE,cAAc,CAAC,IAAI;gBACzB,OAAO,EAAE,cAAc,CAAC,OAAO;aAChC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,6BAA6B;QAC7B,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAgB,EAAE,EAAE;YACpC,MAAM,aAAa,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAuB,CAAC;YAExE,0BAA0B;YAC1B,IAAI,CAAC,aAAa,EAAE;gBAClB,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;aAC7E;YAED,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {GlobalProviders, InjectorService, ProviderType} from \"@tsed/di\";\nimport {getOperationsRoutes, OperationMethods} from \"@tsed/schema\";\nimport {ControllerProvider} from \"../domain/ControllerProvider\";\nimport {PlatformRouter} from \"../services/PlatformRouter\";\nimport {EndpointMetadata} from \"../domain/EndpointMetadata\";\nimport {PlatformMiddlewaresChain} from \"../services/PlatformMiddlewaresChain\";\n\nGlobalProviders.createRegistry(ProviderType.CONTROLLER, ControllerProvider, {\n onInvoke(provider: ControllerProvider, locals: any, {injector}) {\n const router = createRouter(injector, provider);\n locals.set(PlatformRouter, router);\n }\n});\n\n/**\n * @ignore\n */\nfunction formatMethod(method: string | undefined) {\n return (method === OperationMethods.CUSTOM ? \"use\" : method || \"use\").toLowerCase();\n}\n\n/**\n * @ignore\n */\nexport function getRouter(injector: InjectorService, provider: ControllerProvider) {\n return injector.get(provider.tokenRouter)!;\n}\n\n/**\n * @ignore\n */\nexport function createRouter(injector: InjectorService, provider: ControllerProvider): PlatformRouter {\n const token = provider.tokenRouter;\n\n if (injector.has(token)) {\n return getRouter(injector, provider);\n }\n\n const router = PlatformRouter.create(injector, provider.routerOptions);\n\n return injector\n .add(token, {\n useValue: router\n })\n .invoke<PlatformRouter>(token);\n}\n\n/**\n * @ignore\n * @param injector\n * @param provider\n */\nexport function buildRouter(injector: InjectorService, provider: ControllerProvider) {\n const {\n middlewares: {useBefore},\n children\n } = provider;\n\n // Controller lifecycle\n const router = createRouter(injector, provider);\n\n if (!router.isBuilt) {\n router.isBuilt = true;\n\n const platformMiddlewaresChain = injector.get<PlatformMiddlewaresChain>(PlatformMiddlewaresChain);\n\n useBefore // Controller before-middleware\n .filter((o) => typeof o === \"function\")\n .forEach((middleware: any) => {\n router.use(middleware);\n });\n\n // build all endpoints and his middlewares\n getOperationsRoutes<EndpointMetadata>(provider.token).forEach((operationRoute) => {\n const handlers = platformMiddlewaresChain?.get(provider, operationRoute);\n\n router.addRoute({\n handlers,\n token: operationRoute.token,\n method: formatMethod(operationRoute.method),\n path: operationRoute.path,\n isFinal: operationRoute.isFinal\n });\n });\n\n // build children controllers\n children.forEach((child: Type<any>) => {\n const childProvider = injector.getProvider(child) as ControllerProvider;\n\n /* istanbul ignore next */\n if (!childProvider) {\n throw new Error(\"Controller component not found in the ControllerRegistry\");\n }\n\n router.use(childProvider.path, buildRouter(injector, childProvider));\n });\n }\n\n return router;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export * from "./interfaces";
2
+ export * from "./services/PlatformConfiguration";
3
+ export * from "./services/PlatformConfiguration";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC","sourcesContent":["export * from \"./interfaces\";\nexport * from \"./services/PlatformConfiguration\";\nexport * from \"./services/PlatformConfiguration\";\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ConverterSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConverterSettings.js","sourceRoot":"","sources":["../../../../src/config/interfaces/ConverterSettings.ts"],"names":[],"mappings":"","sourcesContent":["export interface ConverterSettings {\n /**\n * Converter additional property policy. (see [Converters](/docs/converters.md))\n */\n additionalProperties?: \"error\" | \"accept\" | \"ignore\";\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=EndpointDirectoriesSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EndpointDirectoriesSettings.js","sourceRoot":"","sources":["../../../../src/config/interfaces/EndpointDirectoriesSettings.ts"],"names":[],"mappings":"","sourcesContent":["export interface EndpointDirectoriesSettings {\n [endpoint: string]: any | string | (any | string)[];\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PlatformLoggerSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformLoggerSettings.js","sourceRoot":"","sources":["../../../../src/config/interfaces/PlatformLoggerSettings.ts"],"names":[],"mappings":"","sourcesContent":["export interface PlatformLoggerSettings {\n /**\n * Enable debug mode. By default debug is false.\n */\n debug?: boolean;\n /**\n * Enable info mode. By default debug is false.\n */\n level?: \"debug\" | \"info\" | \"warn\" | \"error\" | \"off\";\n /**\n * Enable log performance tracker and disable log server.\n */\n perf?: boolean;\n /**\n * List of regexp to ignore log.\n */\n ignoreUrlPatterns?: string[];\n /**\n * The number of space characters to use as white space in JSON output. Default is 2 (0 in production).\n */\n jsonIndentation?: number;\n /**\n * A function called for each incoming request to create a request id.\n * @returns {number}\n */\n reqIdBuilder?: (req: TsED.Request) => string;\n /**\n * Disable routes table displayed in the logger. By default debug is `false`.\n */\n disableRoutesSummary?: boolean;\n /**\n * Disable bootstrap log displayed in the logger. By default debug is `false`.\n */\n disableBootstrapLog?: boolean;\n /**\n * Specify log format. Example: `%[%d{[yyyy-MM-dd hh:mm:ss,SSS}] %p%] %m`. See [@tsed/logger configuration](https://tsedio.github.io/logger/).\n */\n format?: string;\n /**\n * Specify the log stack size for the context.logger. When the stack.length is reach, the logger is flushed during the request.\n * Default size is set to 30.\n */\n maxStackSize?: number;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PlatformMulterSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformMulterSettings.js","sourceRoot":"","sources":["../../../../src/config/interfaces/PlatformMulterSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {Request} from \"express\";\nimport {FileFilterCallback} from \"multer\";\nimport {Readable} from \"stream\";\n\ndeclare global {\n namespace TsED {\n export interface MulterFile {\n /** Name of the form field associated with this file. */\n fieldname: string;\n /** Name of the file on the uploader's computer. */\n originalname: string;\n /** Value of the `Content-Type` header for this file. */\n mimetype: string;\n /** Size of the file in bytes. */\n size: number;\n /**\n * A readable stream of this file. Only available to the `_handleFile`\n * callback for custom `StorageEngine`s.\n */\n stream: Readable;\n /** `DiskStorage` only: Directory to which this file has been uploaded. */\n destination: string;\n /** `DiskStorage` only: Name of this file within `destination`. */\n filename: string;\n /** `DiskStorage` only: Full path to the uploaded file. */\n path: string;\n /** `MemoryStorage` only: A Buffer containing the entire file. */\n buffer: Buffer;\n }\n\n export interface MulterStorageEngine {}\n\n export interface MulterOptions {\n /**\n * A `StorageEngine` responsible for processing files uploaded via Multer.\n * Takes precedence over `dest`.\n */\n storage?: MulterStorageEngine;\n /**\n * The destination directory for uploaded files. If `storage` is not set\n * and `dest` is, Multer will create a `DiskStorage` instance configured\n * to store files at `dest` with random filenames.\n *\n * Ignored if `storage` is set.\n */\n dest?: string;\n /**\n * An object specifying various limits on incoming data. This object is\n * passed to Busboy directly, and the details of properties can be found\n * at https://github.com/mscdex/busboy#busboy-methods.\n */\n limits?: {\n /** Maximum size of each form field name in bytes. (Default: 100) */\n fieldNameSize?: number;\n /** Maximum size of each form field value in bytes. (Default: 1048576) */\n fieldSize?: number;\n /** Maximum number of non-file form fields. (Default: Infinity) */\n fields?: number;\n /** Maximum size of each file in bytes. (Default: Infinity) */\n fileSize?: number;\n /** Maximum number of file fields. (Default: Infinity) */\n files?: number;\n /** Maximum number of parts (non-file fields + files). (Default: Infinity) */\n parts?: number;\n /** Maximum number of headers. (Default: 2000) */\n headerPairs?: number;\n };\n /** Preserve the full path of the original filename rather than the basename. (Default: false) */\n preservePath?: boolean;\n /**\n * Optional function to control which files are uploaded. This is called\n * for every file that is processed.\n *\n * @param req The Express `Request` object.\n * @param file Object containing information about the processed file.\n * @param callback a function to control which files should be uploaded and which should be skipped.\n */\n fileFilter?(req: Request, file: MulterFile, callback: FileFilterCallback): void;\n }\n\n export interface MulterField {\n name: string;\n maxCount?: number;\n }\n\n export type MulterHandler = (req: any, res: any) => Promise<any>;\n\n export interface Multer {\n /**\n * Returns middleware that processes a single file associated with the\n * given form field.\n *\n * The `Request` object will be populated with a `file` object containing\n * information about the processed file.\n *\n * @param fieldName Name of the multipart form field to process.\n */\n single(fieldName: string): MulterHandler;\n\n /**\n * Returns middleware that processes multiple files sharing the same field\n * name.\n *\n * The `Request` object will be populated with a `files` array containing\n * an information object for each processed file.\n *\n * @param fieldName Shared name of the multipart form fields to process.\n * @param maxCount Optional. Maximum number of files to process. (default: Infinity)\n * @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if more than `maxCount` files are associated with `fieldName`\n */\n array(fieldName: string, maxCount?: number): MulterHandler;\n\n /**\n * Returns middleware that processes multiple files associated with the\n * given form fields.\n *\n * The `Request` object will be populated with a `files` object which\n * maps each field name to an array of the associated file information\n * objects.\n *\n * @param fields Array of `Field` objects describing multipart form fields to process.\n * @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if more than `maxCount` files are associated with `fieldName` for any field.\n */\n fields(fields: MulterField[]): MulterHandler;\n\n /**\n * Returns middleware that processes all files contained in the multipart\n * request.\n *\n * The `Request` object will be populated with a `files` array containing\n * an information object for each processed file.\n */\n any(): MulterHandler;\n\n /**\n * Returns middleware that accepts only non-file multipart form fields.\n *\n * @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if any file is encountered.\n */\n none(): MulterHandler;\n }\n }\n}\n\nexport type PlatformMulter = TsED.Multer;\nexport type PlatformMulterSettings = TsED.MulterOptions;\nexport type PlatformMulterFile = TsED.MulterFile;\nexport type PlatformMulterField = TsED.MulterField;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PlatformStaticsSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformStaticsSettings.js","sourceRoot":"","sources":["../../../../src/config/interfaces/PlatformStaticsSettings.ts"],"names":[],"mappings":"","sourcesContent":["declare global {\n namespace TsED {\n // @ts-ignore\n export interface StaticsOptions {\n root: string;\n hook?: \"$beforeRoutesInit\" | \"$afterRoutesInit\";\n\n [key: string]: any;\n }\n }\n}\n\nexport interface PlatformStaticsOptions extends TsED.StaticsOptions {\n root: string;\n\n [key: string]: any;\n}\n\nexport type PathOrStaticsOptions = string | PlatformStaticsOptions;\n\nexport interface PlatformStaticsSettings {\n [endpoint: string]: PathOrStaticsOptions | PathOrStaticsOptions[];\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export * from "./PlatformLoggerSettings";
2
+ export * from "./EndpointDirectoriesSettings";
3
+ export * from "./PlatformStaticsSettings";
4
+ export * from "./PlatformMulterSettings";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/config/interfaces/index.ts"],"names":[],"mappings":"AA6FA,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC","sourcesContent":["import {Env} from \"@tsed/core\";\nimport {ConverterSettings} from \"./ConverterSettings\";\nimport {EndpointDirectoriesSettings} from \"./EndpointDirectoriesSettings\";\nimport {PlatformLoggerSettings} from \"./PlatformLoggerSettings\";\nimport {PlatformMulterSettings} from \"./PlatformMulterSettings\";\nimport {PlatformStaticsSettings} from \"./PlatformStaticsSettings\";\nimport type Http from \"http\";\nimport type Https from \"https\";\n\ndeclare global {\n namespace TsED {\n interface LoggerConfiguration extends Partial<PlatformLoggerSettings> {}\n interface Configuration {\n /**\n * The root directory where you build run project. By default, it's equal to `process.cwd().\n */\n rootDir: string;\n /**\n * The environment profile. By default the environment profile is equals to `NODE_ENV`.\n */\n env: Env;\n /**\n * Port number for the [HTTP.Server](https://nodejs.org/api/http.html#http_class_http_server).\n */\n port: string | number;\n /**\n * Port number for the [HTTP.Server](https://nodejs.org/api/http.html#http_class_http_server).\n */\n httpPort: string | number | boolean;\n /**\n * [Https.ServerOptions](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener)):\n * - `key` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | &lt;Object[]&gt;: The private key of the server in PEM format. To support multiple keys using different algorithms an array can be provided either as a plain array of key strings or an array of objects in the format `{pem: key, passphrase: passphrase}`. This option is required for ciphers that make use of private keys.\n * - `passphrase` &lt;string&gt; A string containing the passphrase for the private key or pfx.\n * - `cert` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | [&lt;Buffer[]&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer): A string, Buffer, array of strings, or array of Buffers containing the certificate key of the server in PEM format. (Required)\n * - `ca` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | [&lt;Buffer[]&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer): A string, Buffer, array of strings, or array of Buffers of trusted certificates in PEM format. If this is omitted several well known \"root\" CAs (like VeriSign) will be used. These are used to authorize connections.\n */\n httpOptions: Http.ServerOptions;\n /**\n * Port number for the [HTTPs.Server](https://nodejs.org/api/https.html#https_class_https_server).\n */\n httpsPort: string | number | boolean;\n /**\n * [Https.ServerOptions](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener)):\n * - `key` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | &lt;Object[]&gt;: The private key of the server in PEM format. To support multiple keys using different algorithms an array can be provided either as a plain array of key strings or an array of objects in the format `{pem: key, passphrase: passphrase}`. This option is required for ciphers that make use of private keys.\n * - `passphrase` &lt;string&gt; A string containing the passphrase for the private key or pfx.\n * - `cert` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | [&lt;Buffer[]&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer): A string, Buffer, array of strings, or array of Buffers containing the certificate key of the server in PEM format. (Required)\n * - `ca` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | [&lt;Buffer[]&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer): A string, Buffer, array of strings, or array of Buffers of trusted certificates in PEM format. If this is omitted several well known \"root\" CAs (like VeriSign) will be used. These are used to authorize connections.\n */\n httpsOptions: Https.ServerOptions;\n /**\n * Mount all controllers under a directories to an endpoint.\n */\n mount: EndpointDirectoriesSettings;\n /**\n * List of directories to scan [Services](/docs/services.md), [Middlewares](/docs/middlewares.md) or [Converters](/docs/converters.md).\n */\n componentsScan: (string | RegExp)[];\n /**\n * Disable the glob pattern. In v7 the componentsScan options will be removed in favor of external module loader.\n */\n disableComponentsScan: boolean;\n /**\n * List of glob patterns. Exclude all files which matching with this list when Server scan all components with the `mount` or `scanComponents` options.\n */\n exclude: string[];\n /**\n * Configure the mimes accepted by default by the server.\n */\n acceptMimes: string[];\n /**\n * Enable debug mode. By default debug is false.\n */\n debug: boolean;\n /**\n * Converter configuration.\n */\n converter: Partial<ConverterSettings>;\n /**\n * Logger configuration.\n */\n logger?: LoggerConfiguration;\n /**\n * Object to mount all directories under to his endpoints. See more on [Serve Static](/tutorials/serve-static-files.md).\n */\n statics: PlatformStaticsSettings;\n /**\n * Object configure Multer. See more on [Upload file](/tutorials/serve-static-files.md).\n */\n multer: PlatformMulterSettings;\n }\n }\n}\n\nexport * from \"./PlatformLoggerSettings\";\nexport * from \"./EndpointDirectoriesSettings\";\nexport * from \"./PlatformStaticsSettings\";\nexport * from \"./PlatformMulterSettings\";\n"]}