@tsed/common 7.0.0-alpha.2 → 7.0.0-beta.11

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 (414) hide show
  1. package/lib/cjs/builder/PlatformBuilder.js +281 -0
  2. package/lib/cjs/builder/PlatformBuilder.js.map +1 -0
  3. package/lib/cjs/builder/PlatformControllerBuilder.js +82 -0
  4. package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -0
  5. package/lib/cjs/config/interfaces/ConverterSettings.js +3 -0
  6. package/lib/cjs/config/interfaces/ConverterSettings.js.map +1 -0
  7. package/lib/cjs/config/interfaces/PlatformLoggerSettings.js +3 -0
  8. package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -0
  9. package/lib/cjs/config/interfaces/PlatformMulterSettings.js +3 -0
  10. package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -0
  11. package/lib/cjs/config/interfaces/PlatformStaticsSettings.js +3 -0
  12. package/lib/cjs/config/interfaces/PlatformStaticsSettings.js.map +1 -0
  13. package/lib/cjs/config/services/PlatformConfiguration.js +187 -0
  14. package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -0
  15. package/lib/cjs/constants/routerOptions.js +5 -0
  16. package/lib/cjs/constants/routerOptions.js.map +1 -0
  17. package/lib/cjs/decorators/multer/multerFileSize.js +35 -0
  18. package/lib/cjs/decorators/multer/multerFileSize.js.map +1 -0
  19. package/lib/cjs/decorators/multer/multerOptions.js +52 -0
  20. package/lib/cjs/decorators/multer/multerOptions.js.map +1 -0
  21. package/lib/cjs/decorators/multer/multipartFile.js +78 -0
  22. package/lib/cjs/decorators/multer/multipartFile.js.map +1 -0
  23. package/lib/cjs/decorators/params/error.js +20 -0
  24. package/lib/cjs/decorators/params/error.js.map +1 -0
  25. package/lib/cjs/decorators/params/next.js +21 -0
  26. package/lib/cjs/decorators/params/next.js.map +1 -0
  27. package/lib/cjs/decorators/params/request.js +39 -0
  28. package/lib/cjs/decorators/params/request.js.map +1 -0
  29. package/lib/cjs/decorators/params/response.js +33 -0
  30. package/lib/cjs/decorators/params/response.js.map +1 -0
  31. package/lib/cjs/domain/AnyToPromiseWithCtx.js +27 -0
  32. package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -0
  33. package/lib/cjs/domain/ControllerProvider.js +51 -0
  34. package/lib/cjs/domain/ControllerProvider.js.map +1 -0
  35. package/lib/cjs/domain/EndpointMetadata.js +6 -0
  36. package/lib/cjs/domain/EndpointMetadata.js.map +1 -0
  37. package/lib/cjs/domain/HandlerMetadata.js +57 -0
  38. package/lib/cjs/domain/HandlerMetadata.js.map +1 -0
  39. package/lib/cjs/domain/PlatformContext.js +92 -0
  40. package/lib/cjs/domain/PlatformContext.js.map +1 -0
  41. package/lib/cjs/domain/PlatformRouteDetails.js +24 -0
  42. package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -0
  43. package/lib/cjs/exports.js +31 -0
  44. package/lib/cjs/exports.js.map +1 -0
  45. package/lib/cjs/index.js +68 -0
  46. package/lib/cjs/index.js.map +1 -0
  47. package/lib/cjs/interfaces/AfterInit.js +3 -0
  48. package/lib/cjs/interfaces/AfterInit.js.map +1 -0
  49. package/lib/cjs/interfaces/AfterListen.js +3 -0
  50. package/lib/cjs/interfaces/AfterListen.js.map +1 -0
  51. package/lib/cjs/interfaces/AfterRoutesInit.js +3 -0
  52. package/lib/cjs/interfaces/AfterRoutesInit.js.map +1 -0
  53. package/lib/cjs/interfaces/BeforeInit.js +3 -0
  54. package/lib/cjs/interfaces/BeforeInit.js.map +1 -0
  55. package/lib/cjs/interfaces/BeforeListen.js +3 -0
  56. package/lib/cjs/interfaces/BeforeListen.js.map +1 -0
  57. package/lib/cjs/interfaces/BeforeRoutesInit.js +3 -0
  58. package/lib/cjs/interfaces/BeforeRoutesInit.js.map +1 -0
  59. package/lib/cjs/interfaces/HandlerType.js +17 -0
  60. package/lib/cjs/interfaces/HandlerType.js.map +1 -0
  61. package/lib/cjs/interfaces/IncomingEvent.js +3 -0
  62. package/lib/cjs/interfaces/IncomingEvent.js.map +1 -0
  63. package/lib/cjs/interfaces/OnReady.js +3 -0
  64. package/lib/cjs/interfaces/OnReady.js.map +1 -0
  65. package/lib/cjs/interfaces/OnRequest.js +3 -0
  66. package/lib/cjs/interfaces/OnRequest.js.map +1 -0
  67. package/lib/cjs/interfaces/OnResponse.js +3 -0
  68. package/lib/cjs/interfaces/OnResponse.js.map +1 -0
  69. package/lib/cjs/interfaces/OnRoutesInit.js +3 -0
  70. package/lib/cjs/interfaces/OnRoutesInit.js.map +1 -0
  71. package/lib/cjs/interfaces/PlatformRouteOptions.js +3 -0
  72. package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -0
  73. package/lib/cjs/interfaces/ResponseErrorObject.js +3 -0
  74. package/lib/cjs/interfaces/ResponseErrorObject.js.map +1 -0
  75. package/lib/cjs/interfaces/Route.js +3 -0
  76. package/lib/cjs/interfaces/Route.js.map +1 -0
  77. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +37 -0
  78. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
  79. package/lib/cjs/middlewares/PlatformMulterMiddleware.js +67 -0
  80. package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -0
  81. package/lib/cjs/middlewares/__mock__/FakeCtrl.js +12 -0
  82. package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +1 -0
  83. package/lib/cjs/middlewares/bindEndpointMiddleware.js +13 -0
  84. package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +1 -0
  85. package/lib/cjs/package.json +3 -0
  86. package/lib/cjs/services/FakeAdapter.js +55 -0
  87. package/lib/cjs/services/FakeAdapter.js.map +1 -0
  88. package/lib/cjs/services/Platform.js +128 -0
  89. package/lib/cjs/services/Platform.js.map +1 -0
  90. package/lib/cjs/services/PlatformAdapter.js +14 -0
  91. package/lib/cjs/services/PlatformAdapter.js.map +1 -0
  92. package/lib/cjs/services/PlatformApplication.js +32 -0
  93. package/lib/cjs/services/PlatformApplication.js.map +1 -0
  94. package/lib/cjs/services/PlatformHandler.js +235 -0
  95. package/lib/cjs/services/PlatformHandler.js.map +1 -0
  96. package/lib/cjs/services/PlatformMiddlewaresChain.js +75 -0
  97. package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -0
  98. package/lib/cjs/services/PlatformRequest.js +138 -0
  99. package/lib/cjs/services/PlatformRequest.js.map +1 -0
  100. package/lib/cjs/services/PlatformResponse.js +271 -0
  101. package/lib/cjs/services/PlatformResponse.js.map +1 -0
  102. package/lib/cjs/services/PlatformRouter.js +108 -0
  103. package/lib/cjs/services/PlatformRouter.js.map +1 -0
  104. package/lib/cjs/services/PlatformTest.js +173 -0
  105. package/lib/cjs/services/PlatformTest.js.map +1 -0
  106. package/lib/cjs/utils/__mock__/Test1.js +8 -0
  107. package/lib/cjs/utils/__mock__/Test1.js.map +1 -0
  108. package/lib/cjs/utils/__mock__/Test2.js +8 -0
  109. package/lib/cjs/utils/__mock__/Test2.js.map +1 -0
  110. package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js +12 -0
  111. package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js.map +1 -0
  112. package/lib/cjs/utils/__mock__/module1/Module1.js +19 -0
  113. package/lib/cjs/utils/__mock__/module1/Module1.js.map +1 -0
  114. package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js +17 -0
  115. package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js.map +1 -0
  116. package/lib/cjs/utils/__mock__/module1/services/M1Service.js +17 -0
  117. package/lib/cjs/utils/__mock__/module1/services/M1Service.js.map +1 -0
  118. package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js +15 -0
  119. package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js.map +1 -0
  120. package/lib/cjs/utils/__mock__/module1/submodule/SubService.js +12 -0
  121. package/lib/cjs/utils/__mock__/module1/submodule/SubService.js.map +1 -0
  122. package/lib/cjs/utils/__mock__/module2/Module2.js +18 -0
  123. package/lib/cjs/utils/__mock__/module2/Module2.js.map +1 -0
  124. package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js +12 -0
  125. package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js.map +1 -0
  126. package/lib/cjs/utils/createContext.js +38 -0
  127. package/lib/cjs/utils/createContext.js.map +1 -0
  128. package/lib/cjs/utils/createHandlerMetadata.js +49 -0
  129. package/lib/cjs/utils/createHandlerMetadata.js.map +1 -0
  130. package/lib/cjs/utils/createHttpServer.js +29 -0
  131. package/lib/cjs/utils/createHttpServer.js.map +1 -0
  132. package/lib/cjs/utils/createHttpsServer.js +29 -0
  133. package/lib/cjs/utils/createHttpsServer.js.map +1 -0
  134. package/lib/cjs/utils/createInjector.js +46 -0
  135. package/lib/cjs/utils/createInjector.js.map +1 -0
  136. package/lib/cjs/utils/getConfiguration.js +46 -0
  137. package/lib/cjs/utils/getConfiguration.js.map +1 -0
  138. package/lib/cjs/utils/getStaticsOptions.js +21 -0
  139. package/lib/cjs/utils/getStaticsOptions.js.map +1 -0
  140. package/lib/cjs/utils/listenServer.js +21 -0
  141. package/lib/cjs/utils/listenServer.js.map +1 -0
  142. package/lib/cjs/utils/mapReturnedResponse.js +15 -0
  143. package/lib/cjs/utils/mapReturnedResponse.js.map +1 -0
  144. package/lib/cjs/utils/printRoutes.js +36 -0
  145. package/lib/cjs/utils/printRoutes.js.map +1 -0
  146. package/lib/cjs/utils/setResponseHeaders.js +35 -0
  147. package/lib/cjs/utils/setResponseHeaders.js.map +1 -0
  148. package/lib/cjs/utils/useCtxHandler.js +15 -0
  149. package/lib/cjs/utils/useCtxHandler.js.map +1 -0
  150. package/lib/esm/builder/PlatformBuilder.js +277 -0
  151. package/lib/esm/builder/PlatformBuilder.js.map +1 -0
  152. package/lib/esm/builder/PlatformControllerBuilder.js +76 -0
  153. package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -0
  154. package/lib/esm/config/interfaces/ConverterSettings.js +2 -0
  155. package/lib/esm/config/interfaces/ConverterSettings.js.map +1 -0
  156. package/lib/esm/config/interfaces/PlatformLoggerSettings.js +2 -0
  157. package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -0
  158. package/lib/esm/config/interfaces/PlatformMulterSettings.js +2 -0
  159. package/lib/esm/config/interfaces/PlatformMulterSettings.js.map +1 -0
  160. package/lib/esm/config/interfaces/PlatformStaticsSettings.js +2 -0
  161. package/lib/esm/config/interfaces/PlatformStaticsSettings.js.map +1 -0
  162. package/lib/esm/config/services/PlatformConfiguration.js +184 -0
  163. package/lib/esm/config/services/PlatformConfiguration.js.map +1 -0
  164. package/lib/esm/constants/routerOptions.js +2 -0
  165. package/lib/esm/constants/routerOptions.js.map +1 -0
  166. package/lib/esm/decorators/multer/multerFileSize.js +31 -0
  167. package/lib/esm/decorators/multer/multerFileSize.js.map +1 -0
  168. package/lib/esm/decorators/multer/multerOptions.js +48 -0
  169. package/lib/esm/decorators/multer/multerOptions.js.map +1 -0
  170. package/lib/esm/decorators/multer/multipartFile.js +74 -0
  171. package/lib/esm/decorators/multer/multipartFile.js.map +1 -0
  172. package/lib/esm/decorators/params/error.js +16 -0
  173. package/lib/esm/decorators/params/error.js.map +1 -0
  174. package/lib/esm/decorators/params/next.js +17 -0
  175. package/lib/esm/decorators/params/next.js.map +1 -0
  176. package/lib/esm/decorators/params/request.js +34 -0
  177. package/lib/esm/decorators/params/request.js.map +1 -0
  178. package/lib/esm/decorators/params/response.js +28 -0
  179. package/lib/esm/decorators/params/response.js.map +1 -0
  180. package/lib/esm/domain/AnyToPromiseWithCtx.js +23 -0
  181. package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -0
  182. package/lib/esm/domain/ControllerProvider.js +47 -0
  183. package/lib/esm/domain/ControllerProvider.js.map +1 -0
  184. package/lib/esm/domain/EndpointMetadata.js +2 -0
  185. package/lib/esm/domain/EndpointMetadata.js.map +1 -0
  186. package/lib/esm/domain/HandlerMetadata.js +53 -0
  187. package/lib/esm/domain/HandlerMetadata.js.map +1 -0
  188. package/lib/esm/domain/PlatformContext.js +88 -0
  189. package/lib/esm/domain/PlatformContext.js.map +1 -0
  190. package/lib/esm/domain/PlatformRouteDetails.js +20 -0
  191. package/lib/esm/domain/PlatformRouteDetails.js.map +1 -0
  192. package/lib/esm/exports.js +13 -0
  193. package/lib/esm/exports.js.map +1 -0
  194. package/lib/esm/index.js +65 -0
  195. package/lib/esm/index.js.map +1 -0
  196. package/lib/esm/interfaces/AfterInit.js +2 -0
  197. package/lib/esm/interfaces/AfterInit.js.map +1 -0
  198. package/lib/esm/interfaces/AfterListen.js +2 -0
  199. package/lib/esm/interfaces/AfterListen.js.map +1 -0
  200. package/lib/esm/interfaces/AfterRoutesInit.js +2 -0
  201. package/lib/esm/interfaces/AfterRoutesInit.js.map +1 -0
  202. package/lib/esm/interfaces/BeforeInit.js +2 -0
  203. package/lib/esm/interfaces/BeforeInit.js.map +1 -0
  204. package/lib/esm/interfaces/BeforeListen.js +2 -0
  205. package/lib/esm/interfaces/BeforeListen.js.map +1 -0
  206. package/lib/esm/interfaces/BeforeRoutesInit.js +2 -0
  207. package/lib/esm/interfaces/BeforeRoutesInit.js.map +1 -0
  208. package/lib/esm/interfaces/HandlerType.js +14 -0
  209. package/lib/esm/interfaces/HandlerType.js.map +1 -0
  210. package/lib/esm/interfaces/IncomingEvent.js +2 -0
  211. package/lib/esm/interfaces/IncomingEvent.js.map +1 -0
  212. package/lib/esm/interfaces/OnReady.js +2 -0
  213. package/lib/esm/interfaces/OnReady.js.map +1 -0
  214. package/lib/esm/interfaces/OnRequest.js +2 -0
  215. package/lib/esm/interfaces/OnRequest.js.map +1 -0
  216. package/lib/esm/interfaces/OnResponse.js +2 -0
  217. package/lib/esm/interfaces/OnResponse.js.map +1 -0
  218. package/lib/esm/interfaces/OnRoutesInit.js +2 -0
  219. package/lib/esm/interfaces/OnRoutesInit.js.map +1 -0
  220. package/lib/esm/interfaces/PlatformRouteOptions.js +2 -0
  221. package/lib/esm/interfaces/PlatformRouteOptions.js.map +1 -0
  222. package/lib/esm/interfaces/ResponseErrorObject.js +2 -0
  223. package/lib/esm/interfaces/ResponseErrorObject.js.map +1 -0
  224. package/lib/esm/interfaces/Route.js +2 -0
  225. package/lib/esm/interfaces/Route.js.map +1 -0
  226. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +34 -0
  227. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
  228. package/lib/esm/middlewares/PlatformMulterMiddleware.js +63 -0
  229. package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -0
  230. package/lib/esm/middlewares/__mock__/FakeCtrl.js +9 -0
  231. package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +1 -0
  232. package/lib/esm/middlewares/bindEndpointMiddleware.js +9 -0
  233. package/lib/esm/middlewares/bindEndpointMiddleware.js.map +1 -0
  234. package/lib/esm/package.json +3 -0
  235. package/lib/esm/services/FakeAdapter.js +51 -0
  236. package/lib/esm/services/FakeAdapter.js.map +1 -0
  237. package/lib/esm/services/Platform.js +125 -0
  238. package/lib/esm/services/Platform.js.map +1 -0
  239. package/lib/esm/services/PlatformAdapter.js +10 -0
  240. package/lib/esm/services/PlatformAdapter.js.map +1 -0
  241. package/lib/esm/services/PlatformApplication.js +29 -0
  242. package/lib/esm/services/PlatformApplication.js.map +1 -0
  243. package/lib/esm/services/PlatformHandler.js +232 -0
  244. package/lib/esm/services/PlatformHandler.js.map +1 -0
  245. package/lib/esm/services/PlatformMiddlewaresChain.js +72 -0
  246. package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -0
  247. package/lib/esm/services/PlatformRequest.js +135 -0
  248. package/lib/esm/services/PlatformRequest.js.map +1 -0
  249. package/lib/esm/services/PlatformResponse.js +268 -0
  250. package/lib/esm/services/PlatformResponse.js.map +1 -0
  251. package/lib/esm/services/PlatformRouter.js +105 -0
  252. package/lib/esm/services/PlatformRouter.js.map +1 -0
  253. package/lib/esm/services/PlatformTest.js +168 -0
  254. package/lib/esm/services/PlatformTest.js.map +1 -0
  255. package/lib/esm/utils/__mock__/Test1.js +4 -0
  256. package/lib/esm/utils/__mock__/Test1.js.map +1 -0
  257. package/lib/esm/utils/__mock__/Test2.js +4 -0
  258. package/lib/esm/utils/__mock__/Test2.js.map +1 -0
  259. package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js +9 -0
  260. package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js.map +1 -0
  261. package/lib/esm/utils/__mock__/module1/Module1.js +16 -0
  262. package/lib/esm/utils/__mock__/module1/Module1.js.map +1 -0
  263. package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js +14 -0
  264. package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js.map +1 -0
  265. package/lib/esm/utils/__mock__/module1/services/M1Service.js +14 -0
  266. package/lib/esm/utils/__mock__/module1/services/M1Service.js.map +1 -0
  267. package/lib/esm/utils/__mock__/module1/submodule/SubModule.js +12 -0
  268. package/lib/esm/utils/__mock__/module1/submodule/SubModule.js.map +1 -0
  269. package/lib/esm/utils/__mock__/module1/submodule/SubService.js +9 -0
  270. package/lib/esm/utils/__mock__/module1/submodule/SubService.js.map +1 -0
  271. package/lib/esm/utils/__mock__/module2/Module2.js +15 -0
  272. package/lib/esm/utils/__mock__/module2/Module2.js.map +1 -0
  273. package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js +9 -0
  274. package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js.map +1 -0
  275. package/lib/esm/utils/createContext.js +34 -0
  276. package/lib/esm/utils/createContext.js.map +1 -0
  277. package/lib/esm/utils/createHandlerMetadata.js +45 -0
  278. package/lib/esm/utils/createHandlerMetadata.js.map +1 -0
  279. package/lib/esm/utils/createHttpServer.js +24 -0
  280. package/lib/esm/utils/createHttpServer.js.map +1 -0
  281. package/lib/esm/utils/createHttpsServer.js +24 -0
  282. package/lib/esm/utils/createHttpsServer.js.map +1 -0
  283. package/lib/esm/utils/createInjector.js +42 -0
  284. package/lib/esm/utils/createInjector.js.map +1 -0
  285. package/lib/esm/utils/getConfiguration.js +42 -0
  286. package/lib/esm/utils/getConfiguration.js.map +1 -0
  287. package/lib/esm/utils/getStaticsOptions.js +17 -0
  288. package/lib/esm/utils/getStaticsOptions.js.map +1 -0
  289. package/lib/esm/utils/listenServer.js +17 -0
  290. package/lib/esm/utils/listenServer.js.map +1 -0
  291. package/lib/esm/utils/mapReturnedResponse.js +11 -0
  292. package/lib/esm/utils/mapReturnedResponse.js.map +1 -0
  293. package/lib/esm/utils/printRoutes.js +32 -0
  294. package/lib/esm/utils/printRoutes.js.map +1 -0
  295. package/lib/esm/utils/setResponseHeaders.js +31 -0
  296. package/lib/esm/utils/setResponseHeaders.js.map +1 -0
  297. package/lib/esm/utils/useCtxHandler.js +11 -0
  298. package/lib/esm/utils/useCtxHandler.js.map +1 -0
  299. package/lib/{builder → types/builder}/PlatformBuilder.d.ts +30 -34
  300. package/lib/types/builder/PlatformControllerBuilder.d.ts +18 -0
  301. package/lib/{config → types/config}/interfaces/ConverterSettings.d.ts +0 -0
  302. package/lib/{config → types/config}/interfaces/PlatformLoggerSettings.d.ts +0 -0
  303. package/lib/types/config/interfaces/PlatformMulterSettings.d.ts +14 -0
  304. package/lib/{config → types/config}/interfaces/PlatformStaticsSettings.d.ts +1 -0
  305. package/lib/{config → types/config}/services/PlatformConfiguration.d.ts +24 -17
  306. package/lib/{constants → types/constants}/routerOptions.d.ts +0 -0
  307. package/lib/{decorators → types/decorators}/multer/multerFileSize.d.ts +0 -0
  308. package/lib/{decorators → types/decorators}/multer/multerOptions.d.ts +0 -0
  309. package/lib/{decorators → types/decorators}/multer/multipartFile.d.ts +0 -0
  310. package/lib/{decorators → types/decorators}/params/error.d.ts +0 -0
  311. package/lib/{decorators → types/decorators}/params/next.d.ts +0 -0
  312. package/lib/{decorators → types/decorators}/params/request.d.ts +0 -0
  313. package/lib/{decorators → types/decorators}/params/response.d.ts +0 -0
  314. package/lib/{domain → types/domain}/AnyToPromiseWithCtx.d.ts +0 -0
  315. package/lib/types/domain/ControllerProvider.d.ts +24 -0
  316. package/lib/types/domain/EndpointMetadata.d.ts +1 -0
  317. package/lib/{domain → types/domain}/HandlerMetadata.d.ts +2 -2
  318. package/lib/{domain → types/domain}/PlatformContext.d.ts +1 -1
  319. package/lib/types/domain/PlatformRouteDetails.d.ts +22 -0
  320. package/lib/types/exports.d.ts +12 -0
  321. package/lib/types/index.d.ts +64 -0
  322. package/lib/{interfaces → types/interfaces}/AfterInit.d.ts +0 -0
  323. package/lib/{interfaces → types/interfaces}/AfterListen.d.ts +0 -0
  324. package/lib/{interfaces → types/interfaces}/AfterRoutesInit.d.ts +0 -0
  325. package/lib/{interfaces → types/interfaces}/BeforeInit.d.ts +0 -0
  326. package/lib/{interfaces → types/interfaces}/BeforeListen.d.ts +0 -0
  327. package/lib/{interfaces → types/interfaces}/BeforeRoutesInit.d.ts +0 -0
  328. package/lib/{interfaces → types/interfaces}/HandlerType.d.ts +0 -0
  329. package/lib/{interfaces → types/interfaces}/IncomingEvent.d.ts +0 -0
  330. package/lib/{interfaces → types/interfaces}/OnReady.d.ts +0 -0
  331. package/lib/{interfaces → types/interfaces}/OnRequest.d.ts +0 -0
  332. package/lib/{interfaces → types/interfaces}/OnResponse.d.ts +0 -0
  333. package/lib/{interfaces → types/interfaces}/OnRoutesInit.d.ts +0 -0
  334. package/lib/{interfaces → types/interfaces}/PlatformRouteOptions.d.ts +5 -3
  335. package/lib/{interfaces → types/interfaces}/ResponseErrorObject.d.ts +0 -0
  336. package/lib/{interfaces → types/interfaces}/Route.d.ts +0 -0
  337. package/lib/{middlewares → types/middlewares}/PlatformAcceptMimesMiddleware.d.ts +0 -0
  338. package/lib/{middlewares → types/middlewares}/PlatformMulterMiddleware.d.ts +8 -3
  339. package/lib/{middlewares/data → types/middlewares/__mock__}/FakeCtrl.d.ts +0 -0
  340. package/lib/types/middlewares/bindEndpointMiddleware.d.ts +6 -0
  341. package/lib/types/services/FakeAdapter.d.ts +30 -0
  342. package/lib/{services → types/services}/Platform.d.ts +22 -7
  343. package/lib/types/services/PlatformAdapter.d.ts +47 -0
  344. package/lib/{services → types/services}/PlatformApplication.d.ts +3 -3
  345. package/lib/{services → types/services}/PlatformHandler.d.ts +1 -1
  346. package/lib/types/services/PlatformMiddlewaresChain.d.ts +10 -0
  347. package/lib/{services → types/services}/PlatformRequest.d.ts +2 -1
  348. package/lib/{services → types/services}/PlatformResponse.d.ts +10 -10
  349. package/lib/{services → types/services}/PlatformRouter.d.ts +12 -8
  350. package/lib/{services → types/services}/PlatformTest.d.ts +6 -5
  351. package/lib/types/utils/__mock__/Test1.d.ts +3 -0
  352. package/lib/types/utils/__mock__/Test2.d.ts +3 -0
  353. package/lib/types/utils/__mock__/controllers/rest/TestCtrl.d.ts +2 -0
  354. package/lib/types/utils/__mock__/module1/Module1.d.ts +2 -0
  355. package/lib/types/utils/__mock__/module1/controllers/M1Ctrl1.d.ts +5 -0
  356. package/lib/types/utils/__mock__/module1/services/M1Service.d.ts +5 -0
  357. package/lib/types/utils/__mock__/module1/submodule/SubModule.d.ts +2 -0
  358. package/lib/types/utils/__mock__/module1/submodule/SubService.d.ts +2 -0
  359. package/lib/types/utils/__mock__/module2/Module2.d.ts +2 -0
  360. package/lib/types/utils/__mock__/module2/controllers/M2Ctrl.d.ts +2 -0
  361. package/lib/{utils → types/utils}/createContext.d.ts +0 -0
  362. package/lib/{utils → types/utils}/createHandlerMetadata.d.ts +1 -1
  363. package/lib/types/utils/createHttpServer.d.ts +4 -0
  364. package/lib/types/utils/createHttpsServer.d.ts +5 -0
  365. package/lib/types/utils/createInjector.d.ts +9 -0
  366. package/lib/types/utils/getConfiguration.d.ts +2 -0
  367. package/lib/types/utils/getStaticsOptions.d.ts +5 -0
  368. package/lib/types/utils/listenServer.d.ts +7 -0
  369. package/lib/{utils → types/utils}/mapReturnedResponse.d.ts +0 -0
  370. package/lib/{utils → types/utils}/printRoutes.d.ts +0 -0
  371. package/lib/{utils → types/utils}/setResponseHeaders.d.ts +0 -0
  372. package/lib/{utils → types/utils}/useCtxHandler.d.ts +0 -0
  373. package/package.json +47 -34
  374. package/readme.md +50 -57
  375. package/tsconfig.compile.esm.json +13 -0
  376. package/lib/PlatformModule.d.ts +0 -15
  377. package/lib/builder/PlatformControllerBuilder.d.ts +0 -19
  378. package/lib/config/index.d.ts +0 -3
  379. package/lib/config/interfaces/EndpointDirectoriesSettings.d.ts +0 -3
  380. package/lib/config/interfaces/PlatformMulterSettings.d.ts +0 -138
  381. package/lib/config/interfaces/index.d.ts +0 -84
  382. package/lib/decorators/httpServer.d.ts +0 -27
  383. package/lib/decorators/httpsServer.d.ts +0 -27
  384. package/lib/decorators/index.d.ts +0 -13
  385. package/lib/decorators/method/acceptMime.d.ts +0 -19
  386. package/lib/decorators/method/endpointFn.d.ts +0 -8
  387. package/lib/decorators/method/location.d.ts +0 -1
  388. package/lib/decorators/method/redirect.d.ts +0 -1
  389. package/lib/decorators/method/route.d.ts +0 -1
  390. package/lib/decorators/multer/index.d.ts +0 -3
  391. package/lib/domain/ControllerProvider.d.ts +0 -53
  392. package/lib/domain/EndpointMetadata.d.ts +0 -88
  393. package/lib/domain/PlatformRouteDetails.d.ts +0 -29
  394. package/lib/domain/index.d.ts +0 -6
  395. package/lib/index.d.ts +0 -22
  396. package/lib/index.js +0 -3651
  397. package/lib/index.js.map +0 -1
  398. package/lib/index.modern.js +0 -3464
  399. package/lib/index.modern.js.map +0 -1
  400. package/lib/interfaces/PathType.d.ts +0 -1
  401. package/lib/interfaces/PlatformRouterMethods.d.ts +0 -10
  402. package/lib/interfaces/index.d.ts +0 -17
  403. package/lib/middlewares/bindEndpointMiddleware.d.ts +0 -5
  404. package/lib/middlewares/index.d.ts +0 -3
  405. package/lib/registries/ControllerRegistry.d.ts +0 -1
  406. package/lib/services/FakeRawDriver.d.ts +0 -15
  407. package/lib/services/index.d.ts +0 -7
  408. package/lib/utils/createHttpServer.d.ts +0 -3
  409. package/lib/utils/createHttpsServer.d.ts +0 -3
  410. package/lib/utils/createInjector.d.ts +0 -2
  411. package/lib/utils/createPlatformApplication.d.ts +0 -2
  412. package/lib/utils/getControllerPath.d.ts +0 -2
  413. package/lib/utils/index.d.ts +0 -8
  414. package/lib/utils/listenServer.d.ts +0 -10
@@ -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;AAC1D,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,QAAyB,EAAE,QAA4B;IAC/E,OAAO,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAE,CAAC;AAC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,CAAC,MAAM,CAAC;gBAC3C,IAAI,EAAE,cAAc,CAAC,IAAI;gBACzB,OAAO,EAAE,cAAc,CAAC,OAAO;aAChC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,WAAW,GAAU,CAAC,GAAG,eAAe,EAAE,GAAG,SAAS,CAAC,CAAC;QAC9D,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,EAAE,WAAW,CAAC,CAAC,CAAC;QACpF,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 {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 * @param parentUseBefore\n */\nexport function buildRouter(injector: InjectorService, provider: ControllerProvider, parentUseBefore: any[] = []) {\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 // build all endpoints and his middlewares\n getOperationsRoutes(provider.token).forEach((operationRoute) => {\n const handlers = platformMiddlewaresChain?.get(provider, operationRoute, parentUseBefore);\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 const middlewares: any[] = [...parentUseBefore, ...useBefore];\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, middlewares));\n });\n }\n\n return router;\n}\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=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 type {Express} from \"express\";\nimport type multer from \"multer\";\n\ndeclare global {\n namespace TsED {\n export type MulterFile = Express.Multer.File;\n export type MulterStorageEngine = multer.StorageEngine;\n export type MulterOptions = multer.Options;\n export type MulterField = multer.Field;\n export type Multer = multer.Multer;\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,184 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { getHostInfoFromPort } from "@tsed/core";
3
+ import { DIConfiguration, Injectable, ProviderScope } from "@tsed/di";
4
+ import { $log } from "@tsed/logger";
5
+ const rootDir = process.cwd();
6
+ /**
7
+ * `PlatformConfiguration` contains all information about your Server configuration.
8
+ */
9
+ let PlatformConfiguration = class PlatformConfiguration extends DIConfiguration {
10
+ constructor() {
11
+ super({ rootDir });
12
+ }
13
+ get version() {
14
+ return this.getRaw("version");
15
+ }
16
+ set version(v) {
17
+ this.setRaw("version", v);
18
+ }
19
+ get rootDir() {
20
+ return this.getRaw("rootDir");
21
+ }
22
+ set rootDir(value) {
23
+ this.setRaw("rootDir", value);
24
+ }
25
+ get port() {
26
+ return this.httpPort;
27
+ }
28
+ set port(value) {
29
+ this.httpPort = value;
30
+ }
31
+ get httpsOptions() {
32
+ return this.getRaw("httpsOptions");
33
+ }
34
+ set httpsOptions(value) {
35
+ this.setRaw("httpsOptions", value);
36
+ }
37
+ get httpPort() {
38
+ return this.getRaw("httpPort");
39
+ }
40
+ set httpPort(value) {
41
+ this.setRaw("httpPort", value);
42
+ }
43
+ get httpsPort() {
44
+ return this.getRaw("httpsPort");
45
+ }
46
+ set httpsPort(value) {
47
+ this.setRaw("httpsPort", value);
48
+ }
49
+ get env() {
50
+ return this.getRaw("env");
51
+ }
52
+ set env(value) {
53
+ this.setRaw("env", value);
54
+ }
55
+ get mount() {
56
+ return this.get("mount");
57
+ }
58
+ set mount(value) {
59
+ this.setRaw("mount", value);
60
+ }
61
+ /**
62
+ * @deprecated
63
+ */
64
+ get componentsScan() {
65
+ return this.resolve(this.getRaw("componentsScan"));
66
+ }
67
+ /**
68
+ * @deprecated
69
+ */
70
+ set componentsScan(value) {
71
+ this.setRaw("componentsScan", value);
72
+ }
73
+ get statics() {
74
+ return this.getRaw("statics") || this.getRaw("serveStatic") || {};
75
+ }
76
+ set statics(value) {
77
+ this.setRaw("statics", value);
78
+ }
79
+ get acceptMimes() {
80
+ return this.getRaw("acceptMimes");
81
+ }
82
+ set acceptMimes(value) {
83
+ this.setRaw("acceptMimes", value || []);
84
+ }
85
+ get debug() {
86
+ return this.logger.level === "debug";
87
+ }
88
+ set debug(debug) {
89
+ this.logger = { ...this.logger, level: debug ? "debug" : "info" };
90
+ }
91
+ get converter() {
92
+ return this.get("converter") || {};
93
+ }
94
+ set converter(options) {
95
+ this.setRaw("converter", options);
96
+ }
97
+ get logger() {
98
+ return this.get("logger");
99
+ }
100
+ set logger(value) {
101
+ const logger = { ...this.logger, ...value };
102
+ logger.debug = logger.level === "debug";
103
+ this.setRaw("logger", logger);
104
+ this.setRaw("debug", logger.debug);
105
+ if (logger.format) {
106
+ $log.appenders.set("stdout", {
107
+ type: "stdout",
108
+ levels: ["info", "debug"],
109
+ layout: {
110
+ type: "pattern",
111
+ pattern: logger.format
112
+ }
113
+ });
114
+ $log.appenders.set("stderr", {
115
+ levels: ["trace", "fatal", "error", "warn"],
116
+ type: "stderr",
117
+ layout: {
118
+ type: "pattern",
119
+ pattern: logger.format
120
+ }
121
+ });
122
+ }
123
+ }
124
+ get exclude() {
125
+ return this.get("exclude");
126
+ }
127
+ set exclude(exclude) {
128
+ this.setRaw("exclude", exclude);
129
+ }
130
+ get additionalProperties() {
131
+ return this.get("converter.additionalProperties") === "accept";
132
+ }
133
+ /**
134
+ *
135
+ * @returns {string|number}
136
+ */
137
+ getHttpPort() {
138
+ return getHostInfoFromPort("http", this.getRaw("httpPort"));
139
+ }
140
+ /**
141
+ *
142
+ * @param settings
143
+ */
144
+ setHttpPort(settings) {
145
+ this.setRaw("httpPort", `${settings.address}:${settings.port}`);
146
+ }
147
+ /**
148
+ *
149
+ * @returns {string|number}
150
+ */
151
+ getHttpsPort() {
152
+ return getHostInfoFromPort("https", this.getRaw("httpsPort"));
153
+ }
154
+ /**
155
+ *
156
+ * @param settings
157
+ */
158
+ setHttpsPort(settings) {
159
+ this.setRaw("httpsPort", `${settings.address}:${settings.port}`);
160
+ }
161
+ getBestHost() {
162
+ const { httpsPort, httpPort } = this;
163
+ if (httpsPort) {
164
+ return this.getHttpsPort();
165
+ }
166
+ if (httpPort) {
167
+ return this.getHttpPort();
168
+ }
169
+ return {
170
+ toString() {
171
+ return "/";
172
+ }
173
+ };
174
+ }
175
+ };
176
+ PlatformConfiguration = __decorate([
177
+ Injectable({
178
+ scope: ProviderScope.SINGLETON,
179
+ global: true
180
+ }),
181
+ __metadata("design:paramtypes", [])
182
+ ], PlatformConfiguration);
183
+ export { PlatformConfiguration };
184
+ //# sourceMappingURL=PlatformConfiguration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformConfiguration.js","sourceRoot":"","sources":["../../../../src/config/services/PlatformConfiguration.ts"],"names":[],"mappings":";AAAA,OAAO,EAAM,mBAAmB,EAAC,MAAM,YAAY,CAAC;AACpD,OAAO,EAAC,eAAe,EAAE,UAAU,EAAE,aAAa,EAAgB,MAAM,UAAU,CAAC;AACnF,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAKlC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EA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MAAM,EAAE,IAAI;KACb,CAAC;;GACW,qBAAqB,CAgNjC;SAhNY,qBAAqB","sourcesContent":["import {Env, getHostInfoFromPort} from \"@tsed/core\";\nimport {DIConfiguration, Injectable, ProviderScope, TokenProvider} from \"@tsed/di\";\nimport {$log} from \"@tsed/logger\";\nimport Https from \"https\";\nimport {ConverterSettings} from \"../interfaces/ConverterSettings\";\nimport {PlatformLoggerSettings} from \"../interfaces/PlatformLoggerSettings\";\n\nconst rootDir = process.cwd();\n\n/**\n * `PlatformConfiguration` contains all information about your Server configuration.\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n global: true\n})\nexport class PlatformConfiguration extends DIConfiguration {\n constructor() {\n super({rootDir});\n }\n\n get version() {\n return this.getRaw(\"version\");\n }\n\n set version(v: string) {\n this.setRaw(\"version\", v);\n }\n\n get rootDir() {\n return this.getRaw(\"rootDir\");\n }\n\n set rootDir(value: string) {\n this.setRaw(\"rootDir\", value);\n }\n\n get port(): string | number | false {\n return this.httpPort;\n }\n\n set port(value: string | number | false) {\n this.httpPort = value;\n }\n\n get httpsOptions(): Https.ServerOptions {\n return this.getRaw(\"httpsOptions\");\n }\n\n set httpsOptions(value: Https.ServerOptions) {\n this.setRaw(\"httpsOptions\", value);\n }\n\n get httpPort(): string | number | false {\n return this.getRaw(\"httpPort\");\n }\n\n set httpPort(value: string | number | false) {\n this.setRaw(\"httpPort\", value);\n }\n\n get httpsPort(): string | number | false {\n return this.getRaw(\"httpsPort\");\n }\n\n set httpsPort(value: string | number | false) {\n this.setRaw(\"httpsPort\", value);\n }\n\n get env(): Env {\n return this.getRaw(\"env\");\n }\n\n set env(value: Env) {\n this.setRaw(\"env\", value);\n }\n\n get mount(): Record<string, TokenProvider[]> {\n return this.get(\"mount\");\n }\n\n set mount(value: Record<string, TokenProvider[]>) {\n this.setRaw(\"mount\", value);\n }\n\n /**\n * @deprecated\n */\n get componentsScan(): string[] {\n return this.resolve(this.getRaw(\"componentsScan\"));\n }\n\n /**\n * @deprecated\n */\n set componentsScan(value: string[]) {\n this.setRaw(\"componentsScan\", value);\n }\n\n get statics(): Record<string, (any | string)[]> {\n return this.getRaw(\"statics\") || this.getRaw(\"serveStatic\") || {};\n }\n\n set statics(value: Record<string, (any | string)[]>) {\n this.setRaw(\"statics\", value);\n }\n\n get acceptMimes(): string[] {\n return this.getRaw(\"acceptMimes\");\n }\n\n set acceptMimes(value: string[]) {\n this.setRaw(\"acceptMimes\", value || []);\n }\n\n get debug(): boolean {\n return this.logger.level === \"debug\";\n }\n\n set debug(debug: boolean) {\n this.logger = {...this.logger, level: debug ? \"debug\" : \"info\"};\n }\n\n get converter(): Partial<ConverterSettings> {\n return this.get(\"converter\") || {};\n }\n\n set converter(options: Partial<ConverterSettings>) {\n this.setRaw(\"converter\", options);\n }\n\n get logger(): Partial<PlatformLoggerSettings> {\n return this.get(\"logger\");\n }\n\n set logger(value: Partial<PlatformLoggerSettings>) {\n const logger = {...this.logger, ...value};\n logger.debug = logger.level === \"debug\";\n\n this.setRaw(\"logger\", logger);\n this.setRaw(\"debug\", logger.debug);\n\n if (logger.format) {\n $log.appenders.set(\"stdout\", {\n type: \"stdout\",\n levels: [\"info\", \"debug\"],\n layout: {\n type: \"pattern\",\n pattern: logger.format\n }\n });\n\n $log.appenders.set(\"stderr\", {\n levels: [\"trace\", \"fatal\", \"error\", \"warn\"],\n type: \"stderr\",\n layout: {\n type: \"pattern\",\n pattern: logger.format\n }\n });\n }\n }\n\n get exclude() {\n return this.get(\"exclude\");\n }\n\n set exclude(exclude: string[]) {\n this.setRaw(\"exclude\", exclude);\n }\n\n get additionalProperties() {\n return this.get(\"converter.additionalProperties\") === \"accept\";\n }\n\n /**\n *\n * @returns {string|number}\n */\n getHttpPort(): ReturnType<typeof getHostInfoFromPort> {\n return getHostInfoFromPort(\"http\", this.getRaw(\"httpPort\"));\n }\n\n /**\n *\n * @param settings\n */\n setHttpPort(settings: {address: string; port: number}) {\n this.setRaw(\"httpPort\", `${settings.address}:${settings.port}`);\n }\n\n /**\n *\n * @returns {string|number}\n */\n getHttpsPort() {\n return getHostInfoFromPort(\"https\", this.getRaw(\"httpsPort\"));\n }\n\n /**\n *\n * @param settings\n */\n setHttpsPort(settings: {address: string; port: number}) {\n this.setRaw(\"httpsPort\", `${settings.address}:${settings.port}`);\n }\n\n getBestHost() {\n const {httpsPort, httpPort} = this;\n\n if (httpsPort) {\n return this.getHttpsPort();\n }\n\n if (httpPort) {\n return this.getHttpPort();\n }\n\n return {\n toString() {\n return \"/\";\n }\n };\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export const ROUTER_OPTIONS = Symbol.for("ROUTER_OPTIONS");
2
+ //# sourceMappingURL=routerOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routerOptions.js","sourceRoot":"","sources":["../../../src/constants/routerOptions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["export const ROUTER_OPTIONS = Symbol.for(\"ROUTER_OPTIONS\");\n"]}
@@ -0,0 +1,31 @@
1
+ import { MulterOptions } from "./multerOptions.js";
2
+ /**
3
+ * Define file size limit.
4
+ *
5
+ * ```typescript
6
+ * import {Controller, Post} from "@tsed/common";
7
+ * import {MulterOptions, MultipartFile} from "@tsed/common";
8
+ * import {Multer} from "@types/multer";
9
+ *
10
+ * type MulterFile = Express.Multer.File;
11
+ *
12
+ * @Controller('/')
13
+ * class MyCtrl {
14
+ * @Post('/file2')
15
+ * @MulterFileSize(1024) // (Ko). Applied for all fields
16
+ * private uploadFile(@MultipartFile("file1") file: MulterFile, @MultipartFile("file2") file2: MulterFile) {
17
+ *
18
+ * }
19
+ * }
20
+ * ```
21
+ *
22
+ * > See the tutorial on the [multer configuration](/tutorials/multer.md).
23
+ * @param fileSize
24
+ * @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}
25
+ * @decorator
26
+ * @multer
27
+ */
28
+ export function MulterFileSize(fileSize) {
29
+ return MulterOptions({ limits: { fileSize } });
30
+ }
31
+ //# sourceMappingURL=multerFileSize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multerFileSize.js","sourceRoot":"","sources":["../../../../src/decorators/multer/multerFileSize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,OAAO,aAAa,CAAC,EAAC,MAAM,EAAE,EAAC,QAAQ,EAAC,EAAC,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import {MulterOptions} from \"./multerOptions\";\n\n/**\n * Define file size limit.\n *\n * ```typescript\n * import {Controller, Post} from \"@tsed/common\";\n * import {MulterOptions, MultipartFile} from \"@tsed/common\";\n * import {Multer} from \"@types/multer\";\n *\n * type MulterFile = Express.Multer.File;\n *\n * @Controller('/')\n * class MyCtrl {\n * @Post('/file2')\n * @MulterFileSize(1024) // (Ko). Applied for all fields\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile, @MultipartFile(\"file2\") file2: MulterFile) {\n *\n * }\n * }\n * ```\n *\n * > See the tutorial on the [multer configuration](/tutorials/multer.md).\n * @param fileSize\n * @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}\n * @decorator\n * @multer\n */\nexport function MulterFileSize(fileSize: number): MethodDecorator {\n return MulterOptions({limits: {fileSize}});\n}\n"]}
@@ -0,0 +1,48 @@
1
+ import { StoreMerge } from "@tsed/core";
2
+ import { PlatformMulterMiddleware } from "../../middlewares/PlatformMulterMiddleware.js";
3
+ /**
4
+ * Define multer option for all MultipartFile
5
+ *
6
+ * ```typescript
7
+ * import {Controller, Post, PlatformMulterFile, MultipartFile, MulterOptions} from "@tsed/common";
8
+ *
9
+ * @Controller('/')
10
+ * class MyCtrl {
11
+ * @Post('/file')
12
+ * private uploadFile(@MultipartFile("file1") file: PlatformMulterFile) {
13
+ *
14
+ * }
15
+ *
16
+ * @Post('/file')
17
+ * @MulterOptions({dest: "/other-dir"})
18
+ * private uploadFile(@MultipartFile("file1") file: PlatformMulterFile) {
19
+ *
20
+ * }
21
+ *
22
+ * @Post('/file2')
23
+ * @MulterOptions({dest: "/other-dir"})
24
+ * private uploadFile(@MultipartFile("file1") file: PlatformMulterFile, @MultipartFile("file2") file2: PlatformMulterFile) {
25
+ *
26
+ * }
27
+ *
28
+ * @Post('/files')
29
+ * private uploadFile(@MultipartFile("file1") files: PlatformMulterFile[]) {
30
+ *
31
+ * }
32
+ * }
33
+ * ```
34
+ *
35
+ * See the tutorial on the [multer configuration](/tutorials/multer.md).
36
+ *
37
+ * @param {multer.Options} options
38
+ * @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}
39
+ * @decorator
40
+ * @multer
41
+ */
42
+ export function MulterOptions(options) {
43
+ return (target, propertyKey, descriptor) => {
44
+ StoreMerge(PlatformMulterMiddleware, { options })(target, propertyKey, descriptor);
45
+ return descriptor;
46
+ };
47
+ }
48
+ //# sourceMappingURL=multerOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multerOptions.js","sourceRoot":"","sources":["../../../../src/decorators/multer/multerOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAC,wBAAwB,EAAC,MAAM,4CAA4C,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,UAAU,aAAa,CAAC,OAA+B;IAC3D,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,UAA8B,EAAE,EAAE;QAC1E,UAAU,CAAC,wBAAwB,EAAE,EAAC,OAAO,EAAC,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QAEjF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {StoreMerge} from \"@tsed/core\";\nimport {PlatformMulterSettings} from \"../../config/interfaces/PlatformMulterSettings\";\nimport {PlatformMulterMiddleware} from \"../../middlewares/PlatformMulterMiddleware\";\n\n/**\n * Define multer option for all MultipartFile\n *\n * ```typescript\n * import {Controller, Post, PlatformMulterFile, MultipartFile, MulterOptions} from \"@tsed/common\";\n *\n * @Controller('/')\n * class MyCtrl {\n * @Post('/file')\n * private uploadFile(@MultipartFile(\"file1\") file: PlatformMulterFile) {\n *\n * }\n *\n * @Post('/file')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: PlatformMulterFile) {\n *\n * }\n *\n * @Post('/file2')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: PlatformMulterFile, @MultipartFile(\"file2\") file2: PlatformMulterFile) {\n *\n * }\n *\n * @Post('/files')\n * private uploadFile(@MultipartFile(\"file1\") files: PlatformMulterFile[]) {\n *\n * }\n * }\n * ```\n *\n * See the tutorial on the [multer configuration](/tutorials/multer.md).\n *\n * @param {multer.Options} options\n * @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}\n * @decorator\n * @multer\n */\nexport function MulterOptions(options: PlatformMulterSettings): MethodDecorator {\n return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {\n StoreMerge(PlatformMulterMiddleware, {options})(target, propertyKey, descriptor);\n\n return descriptor;\n };\n}\n"]}
@@ -0,0 +1,74 @@
1
+ import { Metadata, StoreMerge, useDecorators, useMethodDecorators } from "@tsed/core";
2
+ import { ParamTypes, UseParam } from "@tsed/platform-params";
3
+ import { InFile } from "@tsed/schema";
4
+ import { PlatformMulterMiddleware } from "../../middlewares/PlatformMulterMiddleware.js";
5
+ function mapOptions(name, maxCount) {
6
+ return {
7
+ fields: [
8
+ {
9
+ name,
10
+ maxCount
11
+ }
12
+ ]
13
+ };
14
+ }
15
+ /**
16
+ * Define a parameter as Multipart file.
17
+ *
18
+ * ```typescript
19
+ * import {Controller, Post} from "@tsed/common";
20
+ * import {MulterOptions, MultipartFile} from "@tsed/common";
21
+ * import {Multer} from "@types/multer";
22
+ *
23
+ * type MulterFile = Express.Multer.File;
24
+ *
25
+ * @Controller('/')
26
+ * class MyCtrl {
27
+ * @Post('/file')
28
+ * private uploadFile(@MultipartFile("file1") file: MulterFile) {
29
+ *
30
+ * }
31
+ *
32
+ * @Post('/file')
33
+ * @MulterOptions({dest: "/other-dir"})
34
+ * private uploadFile(@MultipartFile("file1") file: MulterFile) {
35
+ *
36
+ * }
37
+ *
38
+ * @Post('/file2')
39
+ * @MulterOptions({dest: "/other-dir"})
40
+ * private uploadFile(@MultipartFile("file1") file: MulterFile, @MultipartFile("file2") file2: MulterFile) {
41
+ *
42
+ * }
43
+ *
44
+ * @Post('/files')
45
+ * private uploadFile(@MultipartFile("file1") files: MulterFile[]) {
46
+ *
47
+ * }
48
+ * }
49
+ * ```
50
+ *
51
+ * > See the tutorial on the [multer configuration](/tutorials/multer.md).
52
+ *
53
+ * @param name
54
+ * @param maxCount
55
+ * @returns Function
56
+ * @decorator
57
+ * @input
58
+ */
59
+ export function MultipartFile(name, maxCount) {
60
+ return (...args) => {
61
+ const [target, propertyKey, index] = args;
62
+ const multiple = Metadata.getParamTypes(target, propertyKey)[index] === Array;
63
+ name = (typeof name === "object" ? undefined : name);
64
+ const expression = [name, !multiple && "0"].filter(Boolean).join(".");
65
+ const decorators = useDecorators(InFile(name), useMethodDecorators(StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))), UseParam({
66
+ paramType: ParamTypes.FILES,
67
+ dataPath: "$ctx.request.files",
68
+ expression,
69
+ useValidation: true
70
+ }));
71
+ decorators(...args);
72
+ };
73
+ }
74
+ //# sourceMappingURL=multipartFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multipartFile.js","sourceRoot":"","sources":["../../../../src/decorators/multer/multipartFile.ts"],"names":[],"mappings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AC9B,UAAU;YACV,aAAa,EAAE,IAAI;SACpB,CAAC,CACH,CAAC;QAEF,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {DecoratorParameters, Metadata, StoreMerge, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {ParamTypes, UseParam} from \"@tsed/platform-params\";\nimport {InFile} from \"@tsed/schema\";\nimport {PlatformMulterFile} from \"../../config/interfaces/PlatformMulterSettings\";\nimport {MulterInputOptions, PlatformMulterMiddleware} from \"../../middlewares/PlatformMulterMiddleware\";\n\nfunction mapOptions(name: string, maxCount: number | undefined): MulterInputOptions {\n return {\n fields: [\n {\n name,\n maxCount\n }\n ]\n };\n}\n\n/**\n * Define a parameter as Multipart file.\n *\n * ```typescript\n * import {Controller, Post} from \"@tsed/common\";\n * import {MulterOptions, MultipartFile} from \"@tsed/common\";\n * import {Multer} from \"@types/multer\";\n *\n * type MulterFile = Express.Multer.File;\n *\n * @Controller('/')\n * class MyCtrl {\n * @Post('/file')\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file2')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile, @MultipartFile(\"file2\") file2: MulterFile) {\n *\n * }\n *\n * @Post('/files')\n * private uploadFile(@MultipartFile(\"file1\") files: MulterFile[]) {\n *\n * }\n * }\n * ```\n *\n * > See the tutorial on the [multer configuration](/tutorials/multer.md).\n *\n * @param name\n * @param maxCount\n * @returns Function\n * @decorator\n * @input\n */\nexport function MultipartFile(name: string, maxCount?: number): ParameterDecorator {\n return (...args: DecoratorParameters): void => {\n const [target, propertyKey, index] = args;\n const multiple = Metadata.getParamTypes(target, propertyKey)[index as number] === Array;\n\n name = (typeof name === \"object\" ? undefined : name)!;\n\n const expression = [name, !multiple && \"0\"].filter(Boolean).join(\".\");\n\n const decorators = useDecorators(\n InFile(name),\n useMethodDecorators(StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))),\n UseParam({\n paramType: ParamTypes.FILES,\n dataPath: \"$ctx.request.files\",\n expression,\n useValidation: true\n })\n );\n\n decorators(...args);\n };\n}\n\nexport type MultipartFile = PlatformMulterFile;\n"]}
@@ -0,0 +1,16 @@
1
+ import { ParamTypes, UseParam } from "@tsed/platform-params";
2
+ /**
3
+ * @returns {Function}
4
+ * @decorator
5
+ * @operation
6
+ * @input
7
+ */
8
+ export function Err() {
9
+ return UseParam({
10
+ paramType: ParamTypes.ERR,
11
+ dataPath: "err",
12
+ useValidation: false,
13
+ useConverter: false
14
+ });
15
+ }
16
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../src/decorators/params/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,UAAU,GAAG;IACjB,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,GAAG;QACzB,QAAQ,EAAE,KAAK;QACf,aAAa,EAAE,KAAK;QACpB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {ParamTypes, UseParam} from \"@tsed/platform-params\";\n\n/**\n * @returns {Function}\n * @decorator\n * @operation\n * @input\n */\nexport function Err(): Function {\n return UseParam({\n paramType: ParamTypes.ERR,\n dataPath: \"err\",\n useValidation: false,\n useConverter: false\n });\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import { ParamTypes, UseParam } from "@tsed/platform-params";
2
+ /**
3
+ * Get the Next function (for express application and middleware).
4
+ *
5
+ * @decorator
6
+ * @operation
7
+ * @input
8
+ */
9
+ export function Next() {
10
+ return UseParam({
11
+ paramType: ParamTypes.NEXT_FN,
12
+ dataPath: "next",
13
+ useConverter: false,
14
+ useValidation: false
15
+ });
16
+ }
17
+ //# sourceMappingURL=next.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next.js","sourceRoot":"","sources":["../../../../src/decorators/params/next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,UAAU,IAAI;IAClB,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,OAAO;QAC7B,QAAQ,EAAE,MAAM;QAChB,YAAY,EAAE,KAAK;QACnB,aAAa,EAAE,KAAK;KACrB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {ParamTypes, UseParam} from \"@tsed/platform-params\";\n\n/**\n * Get the Next function (for express application and middleware).\n *\n * @decorator\n * @operation\n * @input\n */\nexport function Next(): ParameterDecorator {\n return UseParam({\n paramType: ParamTypes.NEXT_FN,\n dataPath: \"next\",\n useConverter: false,\n useValidation: false\n });\n}\n\ndeclare global {\n namespace TsED {\n export interface NextFunction extends Function {}\n }\n}\n/**\n * Get the Next function (for express application and middleware).\n *\n * @decorator\n * @operation\n * @input\n */\nexport type Next = TsED.NextFunction;\n"]}
@@ -0,0 +1,34 @@
1
+ import { isClass, Metadata, nameOf } from "@tsed/core";
2
+ import { IncomingMessage } from "http";
3
+ import { mapParamsOptions, ParamTypes, UseParam } from "@tsed/platform-params";
4
+ function getParamType(target, propertyKey, parameterIndex) {
5
+ const type = Metadata.getOwnParamTypes(target, propertyKey)[parameterIndex];
6
+ if (isClass(type)) {
7
+ if (nameOf(type) === "PlatformRequest") {
8
+ return { paramType: ParamTypes.PLATFORM_REQUEST, dataPath: "$ctx.request" };
9
+ }
10
+ if (type === IncomingMessage) {
11
+ return { paramType: ParamTypes.NODE_REQUEST, dataPath: "$ctx.request.req" };
12
+ }
13
+ }
14
+ return { paramType: ParamTypes.REQUEST, dataPath: "$ctx.request.request" };
15
+ }
16
+ export function Request(...args) {
17
+ // @ts-ignore
18
+ return Req(...args);
19
+ }
20
+ export function Req(...args) {
21
+ const { expression, useType, useConverter = false, useValidation = false } = mapParamsOptions(args);
22
+ return (target, propertyKey, parameterIndex) => {
23
+ const { paramType, dataPath } = getParamType(target, propertyKey, parameterIndex);
24
+ UseParam({
25
+ paramType,
26
+ dataPath,
27
+ expression,
28
+ useType,
29
+ useConverter,
30
+ useValidation
31
+ })(target, propertyKey, parameterIndex);
32
+ };
33
+ }
34
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/decorators/params/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAO,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,MAAM,CAAC;AACrC,OAAO,EAAC,gBAAgB,EAAgB,UAAU,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAE3F,SAAS,YAAY,CAAC,MAAc,EAAE,WAA4B,EAAE,cAAsB;IACxF,MAAM,IAAI,GAAG,QAAQ,CAAC,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,cAAc,CAAC,CAAC;IAE5E,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;QACjB,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,iBAAiB,EAAE;YACtC,OAAO,EAAC,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EAAC,CAAC;SAC3E;QAED,IAAI,IAAI,KAAK,eAAe,EAAE;YAC5B,OAAO,EAAC,SAAS,EAAE,UAAU,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAC,CAAC;SAC3E;KACF;IAED,OAAO,EAAC,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAC,CAAC;AAC3E,CAAC;AAcD,MAAM,UAAU,OAAO,CAAC,GAAG,IAAW;IACpC,aAAa;IACb,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AACtB,CAAC;AAeD,MAAM,UAAU,GAAG,CAAC,GAAG,IAAW;IAChC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAElG,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE;QAC7C,MAAM,EAAC,SAAS,EAAE,QAAQ,EAAC,GAAG,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;QAEhF,QAAQ,CAAC;YACP,SAAS;YACT,QAAQ;YACR,UAAU;YACV,OAAO;YACP,YAAY;YACZ,aAAa;SACd,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;IAC1C,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {isClass, Metadata, nameOf, Type} from \"@tsed/core\";\nimport {IncomingMessage} from \"http\";\nimport {mapParamsOptions, ParamOptions, ParamTypes, UseParam} from \"@tsed/platform-params\";\n\nfunction getParamType(target: Object, propertyKey: string | symbol, parameterIndex: number) {\n const type = Metadata.getOwnParamTypes(target, propertyKey)[parameterIndex];\n\n if (isClass(type)) {\n if (nameOf(type) === \"PlatformRequest\") {\n return {paramType: ParamTypes.PLATFORM_REQUEST, dataPath: \"$ctx.request\"};\n }\n\n if (type === IncomingMessage) {\n return {paramType: ParamTypes.NODE_REQUEST, dataPath: \"$ctx.request.req\"};\n }\n }\n\n return {paramType: ParamTypes.REQUEST, dataPath: \"$ctx.request.request\"};\n}\n\n/**\n * Request service.\n *\n * @decorator\n * @operation\n * @input\n */\nexport function Request(expression: string, useType: Type<any>): ParameterDecorator;\nexport function Request(expression: string): ParameterDecorator;\nexport function Request(useType: Type<any>): ParameterDecorator;\nexport function Request(options: ParamOptions<any>): ParameterDecorator;\nexport function Request(): ParameterDecorator;\nexport function Request(...args: any[]): ParameterDecorator {\n // @ts-ignore\n return Req(...args);\n}\n\n/**\n * Request service.\n *\n * @alias Request\n * @decorator\n * @operation\n * @input\n */\nexport function Req(expression: string, useType: Type<any>): ParameterDecorator;\nexport function Req(expression: string): ParameterDecorator;\nexport function Req(useType: Type<any>): ParameterDecorator;\nexport function Req(options: Partial<ParamOptions>): ParameterDecorator;\nexport function Req(): ParameterDecorator;\nexport function Req(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = false, useValidation = false} = mapParamsOptions(args);\n\n return (target, propertyKey, parameterIndex) => {\n const {paramType, dataPath} = getParamType(target, propertyKey, parameterIndex);\n\n UseParam({\n paramType,\n dataPath,\n expression,\n useType,\n useConverter,\n useValidation\n })(target, propertyKey, parameterIndex);\n };\n}\n\n/**\n * Request service.\n *\n * @decorator\n * @operation\n * @input\n */\nexport interface Request extends TsED.Request {}\n\n/**\n * Request service.\n *\n * @alias Request\n * @decorator\n * @operation\n * @input\n */\nexport interface Req extends Request {}\n"]}
@@ -0,0 +1,28 @@
1
+ import { isClass, Metadata, nameOf } from "@tsed/core";
2
+ import { ParamTypes, UseParam } from "@tsed/platform-params";
3
+ import { ServerResponse } from "http";
4
+ function getParamType(target, propertyKey, parameterIndex) {
5
+ const type = Metadata.getOwnParamTypes(target, propertyKey)[parameterIndex];
6
+ if (isClass(type)) {
7
+ if (nameOf(type) === "PlatformResponse") {
8
+ return { paramType: ParamTypes.PLATFORM_RESPONSE, dataPath: "$ctx.response" };
9
+ }
10
+ if (type === ServerResponse) {
11
+ return { paramType: ParamTypes.NODE_RESPONSE, dataPath: "$ctx.response.res" };
12
+ }
13
+ }
14
+ return { paramType: ParamTypes.RESPONSE, dataPath: "$ctx.response.response" };
15
+ }
16
+ export function Response() {
17
+ return Res();
18
+ }
19
+ export function Res() {
20
+ return (target, propertyKey, parameterIndex) => {
21
+ const { paramType, dataPath } = getParamType(target, propertyKey, parameterIndex);
22
+ UseParam({
23
+ paramType,
24
+ dataPath
25
+ })(target, propertyKey, parameterIndex);
26
+ };
27
+ }
28
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/decorators/params/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AACrD,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAC,MAAM,MAAM,CAAC;AAEpC,SAAS,YAAY,CAAC,MAAc,EAAE,WAA4B,EAAE,cAAsB;IACxF,MAAM,IAAI,GAAG,QAAQ,CAAC,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,cAAc,CAAC,CAAC;IAE5E,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;QACjB,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,kBAAkB,EAAE;YACvC,OAAO,EAAC,SAAS,EAAE,UAAU,CAAC,iBAAiB,EAAE,QAAQ,EAAE,eAAe,EAAC,CAAC;SAC7E;QAED,IAAI,IAAI,KAAK,cAAc,EAAE;YAC3B,OAAO,EAAC,SAAS,EAAE,UAAU,CAAC,aAAa,EAAE,QAAQ,EAAE,mBAAmB,EAAC,CAAC;SAC7E;KACF;IAED,OAAO,EAAC,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,wBAAwB,EAAC,CAAC;AAC9E,CAAC;AAWD,MAAM,UAAU,QAAQ;IACtB,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAYD,MAAM,UAAU,GAAG;IACjB,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE;QAC7C,MAAM,EAAC,SAAS,EAAE,QAAQ,EAAC,GAAG,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;QAChF,QAAQ,CAAC;YACP,SAAS;YACT,QAAQ;SACT,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;IAC1C,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {isClass, Metadata, nameOf} from \"@tsed/core\";\nimport {ParamTypes, UseParam} from \"@tsed/platform-params\";\nimport {ServerResponse} from \"http\";\n\nfunction getParamType(target: Object, propertyKey: string | symbol, parameterIndex: number) {\n const type = Metadata.getOwnParamTypes(target, propertyKey)[parameterIndex];\n\n if (isClass(type)) {\n if (nameOf(type) === \"PlatformResponse\") {\n return {paramType: ParamTypes.PLATFORM_RESPONSE, dataPath: \"$ctx.response\"};\n }\n\n if (type === ServerResponse) {\n return {paramType: ParamTypes.NODE_RESPONSE, dataPath: \"$ctx.response.res\"};\n }\n }\n\n return {paramType: ParamTypes.RESPONSE, dataPath: \"$ctx.response.response\"};\n}\n\n/**\n * Response service.\n *\n * @decorator\n * @operation\n * @input\n * @response\n */\nexport function Response(): ParameterDecorator;\nexport function Response(): ParameterDecorator {\n return Res();\n}\n\n/**\n * Request service.\n *\n * @alias Response\n * @decorator\n * @operation\n * @input\n * @response\n */\nexport function Res(): ParameterDecorator;\nexport function Res(): ParameterDecorator {\n return (target, propertyKey, parameterIndex) => {\n const {paramType, dataPath} = getParamType(target, propertyKey, parameterIndex);\n UseParam({\n paramType,\n dataPath\n })(target, propertyKey, parameterIndex);\n };\n}\n\n/**\n * Response service.\n *\n * @decorator\n * @operation\n * @input\n * @response\n */\nexport interface Response extends TsED.Response {}\n\n/**\n * Response service.\n *\n * @alias Response\n * @decorator\n * @operation\n * @input\n * @response\n */\nexport interface Res extends Response {}\n"]}
@@ -0,0 +1,23 @@
1
+ import { AnyToPromise } from "@tsed/core";
2
+ export class AnyToPromiseWithCtx extends AnyToPromise {
3
+ constructor({ $ctx, err }) {
4
+ super();
5
+ this.$ctx = $ctx;
6
+ this.err = err;
7
+ }
8
+ isDone() {
9
+ const { $ctx } = this;
10
+ return ($ctx === null || $ctx === void 0 ? void 0 : $ctx.isDone()) || super.isDone();
11
+ }
12
+ async call(cb) {
13
+ return super.call(() => cb(this));
14
+ }
15
+ destroy() {
16
+ // @ts-ignore
17
+ delete this.$ctx;
18
+ }
19
+ isCanceledResponse(process) {
20
+ return process === this.$ctx.getResponse();
21
+ }
22
+ }
23
+ //# sourceMappingURL=AnyToPromiseWithCtx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnyToPromiseWithCtx.js","sourceRoot":"","sources":["../../../src/domain/AnyToPromiseWithCtx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,YAAY,EAAC,MAAM,YAAY,CAAC;AAW1D,MAAM,OAAO,mBAAoB,SAAQ,YAAY;IAInD,YAAY,EAAC,IAAI,EAAE,GAAG,EAAwB;QAC5C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,MAAM;QACJ,MAAM,EAAC,IAAI,EAAC,GAAG,IAAI,CAAC;QAEpB,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,EAAE,KAAI,KAAK,CAAC,MAAM,EAAE,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAY;QACrB,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;QACL,aAAa;QACb,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,kBAAkB,CAAC,OAAY;QAC7B,OAAO,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IAC7C,CAAC;CACF","sourcesContent":["import {AnyPromiseResult, AnyToPromise} from \"@tsed/core\";\nimport {PlatformContext} from \"./PlatformContext\";\n\n/**\n * @ignore\n */\nexport interface HandlerContextOptions {\n $ctx: PlatformContext;\n err?: any;\n}\n\nexport class AnyToPromiseWithCtx extends AnyToPromise {\n public $ctx: PlatformContext;\n public err: unknown;\n\n constructor({$ctx, err}: HandlerContextOptions) {\n super();\n this.$ctx = $ctx;\n this.err = err;\n }\n\n isDone(): boolean {\n const {$ctx} = this;\n\n return $ctx?.isDone() || super.isDone();\n }\n\n async call(cb: Function): Promise<AnyPromiseResult<any>> {\n return super.call(() => cb(this));\n }\n\n destroy() {\n // @ts-ignore\n delete this.$ctx;\n }\n\n isCanceledResponse(process: any) {\n return process === this.$ctx.getResponse();\n }\n}\n"]}