@tsed/common 7.0.0-beta.12 → 7.0.0-beta.15

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 (228) hide show
  1. package/jest.config.js +14 -0
  2. package/lib/cjs/builder/PlatformBuilder.js +83 -63
  3. package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
  4. package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -1
  5. package/lib/cjs/config/services/PlatformConfiguration.js +0 -70
  6. package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -1
  7. package/lib/cjs/decorators/params/error.js +1 -1
  8. package/lib/cjs/decorators/params/error.js.map +1 -1
  9. package/lib/cjs/domain/AnyToPromiseWithCtx.js +4 -5
  10. package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -1
  11. package/lib/cjs/domain/PlatformContext.js +82 -32
  12. package/lib/cjs/domain/PlatformContext.js.map +1 -1
  13. package/lib/cjs/domain/PlatformRouteDetails.js +0 -21
  14. package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -1
  15. package/lib/cjs/exports.js +1 -0
  16. package/lib/cjs/exports.js.map +1 -1
  17. package/lib/cjs/index.js +1 -7
  18. package/lib/cjs/index.js.map +1 -1
  19. package/lib/cjs/interfaces/Route.js.map +1 -1
  20. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +2 -1
  21. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  22. package/lib/cjs/middlewares/PlatformMulterMiddleware.js +2 -0
  23. package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -1
  24. package/lib/cjs/services/FakeAdapter.js +6 -12
  25. package/lib/cjs/services/FakeAdapter.js.map +1 -1
  26. package/lib/cjs/services/Platform.js +43 -85
  27. package/lib/cjs/services/Platform.js.map +1 -1
  28. package/lib/cjs/services/PlatformAdapter.js +10 -0
  29. package/lib/cjs/services/PlatformAdapter.js.map +1 -1
  30. package/lib/cjs/services/PlatformApplication.js +23 -9
  31. package/lib/cjs/services/PlatformApplication.js.map +1 -1
  32. package/lib/cjs/services/PlatformHandler.js +88 -161
  33. package/lib/cjs/services/PlatformHandler.js.map +1 -1
  34. package/lib/cjs/services/PlatformMiddlewaresChain.js +5 -19
  35. package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
  36. package/lib/cjs/services/PlatformRequest.js +17 -12
  37. package/lib/cjs/services/PlatformRequest.js.map +1 -1
  38. package/lib/cjs/services/PlatformResponse.js +20 -20
  39. package/lib/cjs/services/PlatformResponse.js.map +1 -1
  40. package/lib/cjs/services/PlatformTest.js +20 -8
  41. package/lib/cjs/services/PlatformTest.js.map +1 -1
  42. package/lib/cjs/utils/createContext.js +30 -21
  43. package/lib/cjs/utils/createContext.js.map +1 -1
  44. package/lib/cjs/utils/createHttpServer.js +3 -3
  45. package/lib/cjs/utils/createHttpServer.js.map +1 -1
  46. package/lib/cjs/utils/createHttpsServer.js +3 -3
  47. package/lib/cjs/utils/createHttpsServer.js.map +1 -1
  48. package/lib/cjs/utils/createInjector.js +6 -8
  49. package/lib/cjs/utils/createInjector.js.map +1 -1
  50. package/lib/cjs/utils/ensureContext.js +16 -0
  51. package/lib/cjs/utils/ensureContext.js.map +1 -0
  52. package/lib/cjs/utils/getConfiguration.js +2 -12
  53. package/lib/cjs/utils/getConfiguration.js.map +1 -1
  54. package/lib/cjs/utils/printRoutes.js +10 -8
  55. package/lib/cjs/utils/printRoutes.js.map +1 -1
  56. package/lib/cjs/utils/setResponseHeaders.js +7 -13
  57. package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
  58. package/lib/esm/builder/PlatformBuilder.js +60 -63
  59. package/lib/esm/builder/PlatformBuilder.js.map +1 -1
  60. package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -1
  61. package/lib/esm/config/services/PlatformConfiguration.js +0 -70
  62. package/lib/esm/config/services/PlatformConfiguration.js.map +1 -1
  63. package/lib/esm/decorators/params/error.js +1 -1
  64. package/lib/esm/decorators/params/error.js.map +1 -1
  65. package/lib/esm/domain/AnyToPromiseWithCtx.js +4 -5
  66. package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -1
  67. package/lib/esm/domain/PlatformContext.js +82 -32
  68. package/lib/esm/domain/PlatformContext.js.map +1 -1
  69. package/lib/esm/domain/PlatformRouteDetails.js +1 -19
  70. package/lib/esm/domain/PlatformRouteDetails.js.map +1 -1
  71. package/lib/esm/exports.js +1 -0
  72. package/lib/esm/exports.js.map +1 -1
  73. package/lib/esm/index.js +1 -7
  74. package/lib/esm/index.js.map +1 -1
  75. package/lib/esm/interfaces/Route.js.map +1 -1
  76. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +2 -1
  77. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  78. package/lib/esm/middlewares/PlatformMulterMiddleware.js +2 -0
  79. package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -1
  80. package/lib/esm/services/FakeAdapter.js +6 -12
  81. package/lib/esm/services/FakeAdapter.js.map +1 -1
  82. package/lib/esm/services/Platform.js +44 -86
  83. package/lib/esm/services/Platform.js.map +1 -1
  84. package/lib/esm/services/PlatformAdapter.js +10 -0
  85. package/lib/esm/services/PlatformAdapter.js.map +1 -1
  86. package/lib/esm/services/PlatformApplication.js +23 -9
  87. package/lib/esm/services/PlatformApplication.js.map +1 -1
  88. package/lib/esm/services/PlatformHandler.js +90 -163
  89. package/lib/esm/services/PlatformHandler.js.map +1 -1
  90. package/lib/esm/services/PlatformMiddlewaresChain.js +5 -19
  91. package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
  92. package/lib/esm/services/PlatformRequest.js +17 -12
  93. package/lib/esm/services/PlatformRequest.js.map +1 -1
  94. package/lib/esm/services/PlatformResponse.js +20 -20
  95. package/lib/esm/services/PlatformResponse.js.map +1 -1
  96. package/lib/esm/services/PlatformTest.js +20 -8
  97. package/lib/esm/services/PlatformTest.js.map +1 -1
  98. package/lib/esm/utils/createContext.js +28 -20
  99. package/lib/esm/utils/createContext.js.map +1 -1
  100. package/lib/esm/utils/createHttpServer.js +3 -3
  101. package/lib/esm/utils/createHttpServer.js.map +1 -1
  102. package/lib/esm/utils/createHttpsServer.js +3 -3
  103. package/lib/esm/utils/createHttpsServer.js.map +1 -1
  104. package/lib/esm/utils/createInjector.js +7 -9
  105. package/lib/esm/utils/createInjector.js.map +1 -1
  106. package/lib/esm/utils/ensureContext.js +12 -0
  107. package/lib/esm/utils/ensureContext.js.map +1 -0
  108. package/lib/esm/utils/getConfiguration.js +4 -14
  109. package/lib/esm/utils/getConfiguration.js.map +1 -1
  110. package/lib/esm/utils/printRoutes.js +10 -8
  111. package/lib/esm/utils/printRoutes.js.map +1 -1
  112. package/lib/esm/utils/setResponseHeaders.js +7 -13
  113. package/lib/esm/utils/setResponseHeaders.js.map +1 -1
  114. package/lib/types/builder/PlatformBuilder.d.ts +17 -16
  115. package/lib/types/config/interfaces/PlatformLoggerSettings.d.ts +2 -43
  116. package/lib/types/config/services/PlatformConfiguration.d.ts +1 -22
  117. package/lib/types/domain/AnyToPromiseWithCtx.d.ts +1 -9
  118. package/lib/types/domain/PlatformContext.d.ts +36 -15
  119. package/lib/types/domain/PlatformRouteDetails.d.ts +4 -19
  120. package/lib/types/exports.d.ts +1 -0
  121. package/lib/types/index.d.ts +1 -7
  122. package/lib/types/interfaces/Route.d.ts +2 -3
  123. package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +1 -1
  124. package/lib/types/services/FakeAdapter.d.ts +7 -6
  125. package/lib/types/services/Platform.d.ts +11 -28
  126. package/lib/types/services/PlatformAdapter.d.ts +19 -10
  127. package/lib/types/services/PlatformApplication.d.ts +14 -6
  128. package/lib/types/services/PlatformHandler.d.ts +19 -55
  129. package/lib/types/services/PlatformMiddlewaresChain.d.ts +1 -2
  130. package/lib/types/services/PlatformRequest.d.ts +8 -9
  131. package/lib/types/services/PlatformResponse.d.ts +10 -13
  132. package/lib/types/services/PlatformTest.d.ts +4 -3
  133. package/lib/types/utils/createContext.d.ts +4 -1
  134. package/lib/types/utils/createHttpsServer.d.ts +1 -0
  135. package/lib/types/utils/createInjector.d.ts +2 -2
  136. package/lib/types/utils/ensureContext.d.ts +2 -0
  137. package/lib/types/utils/listenServer.d.ts +2 -0
  138. package/package.json +23 -21
  139. package/lib/cjs/builder/PlatformControllerBuilder.js +0 -82
  140. package/lib/cjs/builder/PlatformControllerBuilder.js.map +0 -1
  141. package/lib/cjs/domain/ControllerProvider.js +0 -51
  142. package/lib/cjs/domain/ControllerProvider.js.map +0 -1
  143. package/lib/cjs/domain/HandlerMetadata.js +0 -57
  144. package/lib/cjs/domain/HandlerMetadata.js.map +0 -1
  145. package/lib/cjs/middlewares/__mock__/FakeCtrl.js +0 -12
  146. package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +0 -1
  147. package/lib/cjs/middlewares/bindEndpointMiddleware.js +0 -13
  148. package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +0 -1
  149. package/lib/cjs/services/PlatformRouter.js +0 -108
  150. package/lib/cjs/services/PlatformRouter.js.map +0 -1
  151. package/lib/cjs/utils/__mock__/Test1.js +0 -8
  152. package/lib/cjs/utils/__mock__/Test1.js.map +0 -1
  153. package/lib/cjs/utils/__mock__/Test2.js +0 -8
  154. package/lib/cjs/utils/__mock__/Test2.js.map +0 -1
  155. package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js +0 -12
  156. package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js.map +0 -1
  157. package/lib/cjs/utils/__mock__/module1/Module1.js +0 -19
  158. package/lib/cjs/utils/__mock__/module1/Module1.js.map +0 -1
  159. package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js +0 -17
  160. package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js.map +0 -1
  161. package/lib/cjs/utils/__mock__/module1/services/M1Service.js +0 -17
  162. package/lib/cjs/utils/__mock__/module1/services/M1Service.js.map +0 -1
  163. package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js +0 -15
  164. package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js.map +0 -1
  165. package/lib/cjs/utils/__mock__/module1/submodule/SubService.js +0 -12
  166. package/lib/cjs/utils/__mock__/module1/submodule/SubService.js.map +0 -1
  167. package/lib/cjs/utils/__mock__/module2/Module2.js +0 -18
  168. package/lib/cjs/utils/__mock__/module2/Module2.js.map +0 -1
  169. package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js +0 -12
  170. package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js.map +0 -1
  171. package/lib/cjs/utils/createHandlerMetadata.js +0 -49
  172. package/lib/cjs/utils/createHandlerMetadata.js.map +0 -1
  173. package/lib/cjs/utils/useCtxHandler.js +0 -15
  174. package/lib/cjs/utils/useCtxHandler.js.map +0 -1
  175. package/lib/esm/builder/PlatformControllerBuilder.js +0 -76
  176. package/lib/esm/builder/PlatformControllerBuilder.js.map +0 -1
  177. package/lib/esm/domain/ControllerProvider.js +0 -47
  178. package/lib/esm/domain/ControllerProvider.js.map +0 -1
  179. package/lib/esm/domain/HandlerMetadata.js +0 -53
  180. package/lib/esm/domain/HandlerMetadata.js.map +0 -1
  181. package/lib/esm/middlewares/__mock__/FakeCtrl.js +0 -9
  182. package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +0 -1
  183. package/lib/esm/middlewares/bindEndpointMiddleware.js +0 -9
  184. package/lib/esm/middlewares/bindEndpointMiddleware.js.map +0 -1
  185. package/lib/esm/services/PlatformRouter.js +0 -105
  186. package/lib/esm/services/PlatformRouter.js.map +0 -1
  187. package/lib/esm/utils/__mock__/Test1.js +0 -4
  188. package/lib/esm/utils/__mock__/Test1.js.map +0 -1
  189. package/lib/esm/utils/__mock__/Test2.js +0 -4
  190. package/lib/esm/utils/__mock__/Test2.js.map +0 -1
  191. package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js +0 -9
  192. package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js.map +0 -1
  193. package/lib/esm/utils/__mock__/module1/Module1.js +0 -16
  194. package/lib/esm/utils/__mock__/module1/Module1.js.map +0 -1
  195. package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js +0 -14
  196. package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js.map +0 -1
  197. package/lib/esm/utils/__mock__/module1/services/M1Service.js +0 -14
  198. package/lib/esm/utils/__mock__/module1/services/M1Service.js.map +0 -1
  199. package/lib/esm/utils/__mock__/module1/submodule/SubModule.js +0 -12
  200. package/lib/esm/utils/__mock__/module1/submodule/SubModule.js.map +0 -1
  201. package/lib/esm/utils/__mock__/module1/submodule/SubService.js +0 -9
  202. package/lib/esm/utils/__mock__/module1/submodule/SubService.js.map +0 -1
  203. package/lib/esm/utils/__mock__/module2/Module2.js +0 -15
  204. package/lib/esm/utils/__mock__/module2/Module2.js.map +0 -1
  205. package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js +0 -9
  206. package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js.map +0 -1
  207. package/lib/esm/utils/createHandlerMetadata.js +0 -45
  208. package/lib/esm/utils/createHandlerMetadata.js.map +0 -1
  209. package/lib/esm/utils/useCtxHandler.js +0 -11
  210. package/lib/esm/utils/useCtxHandler.js.map +0 -1
  211. package/lib/types/builder/PlatformControllerBuilder.d.ts +0 -18
  212. package/lib/types/domain/ControllerProvider.d.ts +0 -24
  213. package/lib/types/domain/HandlerMetadata.d.ts +0 -32
  214. package/lib/types/middlewares/__mock__/FakeCtrl.d.ts +0 -2
  215. package/lib/types/middlewares/bindEndpointMiddleware.d.ts +0 -6
  216. package/lib/types/services/PlatformRouter.d.ts +0 -51
  217. package/lib/types/utils/__mock__/Test1.d.ts +0 -3
  218. package/lib/types/utils/__mock__/Test2.d.ts +0 -3
  219. package/lib/types/utils/__mock__/controllers/rest/TestCtrl.d.ts +0 -2
  220. package/lib/types/utils/__mock__/module1/Module1.d.ts +0 -2
  221. package/lib/types/utils/__mock__/module1/controllers/M1Ctrl1.d.ts +0 -5
  222. package/lib/types/utils/__mock__/module1/services/M1Service.d.ts +0 -5
  223. package/lib/types/utils/__mock__/module1/submodule/SubModule.d.ts +0 -2
  224. package/lib/types/utils/__mock__/module1/submodule/SubService.d.ts +0 -2
  225. package/lib/types/utils/__mock__/module2/Module2.d.ts +0 -2
  226. package/lib/types/utils/__mock__/module2/controllers/M2Ctrl.d.ts +0 -2
  227. package/lib/types/utils/createHandlerMetadata.d.ts +0 -8
  228. package/lib/types/utils/useCtxHandler.d.ts +0 -13
@@ -1 +1 @@
1
- {"version":3,"file":"createHttpServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAC,MAAM,UAAU,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,gBAAgB,CAAC,QAAyB,EAAE,eAAqC;IAC/F,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAEnD,MAAM,MAAM,GAAG,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3F,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE;QAChC,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE7B,IAAI,MAAM,EAAE;QACV,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEvD,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,MAAqB,EAAE,QAAQ,CAAC,CAAC;YACvF,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,gBAAgB,CAAC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;YACpF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH;AACH,CAAC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Http from \"http\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpServer(injector: InjectorService, requestListener: Http.RequestListener) {\n const {settings} = injector;\n const httpPort = settings.getRaw(\"httpPort\");\n const httpOptions = settings.getRaw(\"httpOptions\");\n\n const server = httpPort !== false ? Http.createServer(httpOptions, requestListener) : null;\n\n injector.addProvider(Http.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(Http.Server);\n\n if (server) {\n const hostInfo = getHostInfoFromPort(\"http\", httpPort);\n\n return async () => {\n const resolvedHostInfo = await listenServer(injector, server as Http.Server, hostInfo);\n settings.setRaw(\"httpPort\", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);\n return server;\n };\n }\n}\n"]}
1
+ {"version":3,"file":"createHttpServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAC,MAAM,UAAU,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,gBAAgB,CAAC,QAAyB,EAAE,eAAqC;IAC/F,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAEhD,MAAM,MAAM,GAAG,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3F,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE;QAChC,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE7B,IAAI,MAAM,EAAE;QACV,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEvD,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,MAAqB,EAAE,QAAQ,CAAC,CAAC;YACvF,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,gBAAgB,CAAC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;YACjF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH;AACH,CAAC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Http from \"http\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpServer(injector: InjectorService, requestListener: Http.RequestListener) {\n const {settings} = injector;\n const httpPort = settings.get(\"httpPort\");\n const httpOptions = settings.get(\"httpOptions\");\n\n const server = httpPort !== false ? Http.createServer(httpOptions, requestListener) : null;\n\n injector.addProvider(Http.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(Http.Server);\n\n if (server) {\n const hostInfo = getHostInfoFromPort(\"http\", httpPort);\n\n return async () => {\n const resolvedHostInfo = await listenServer(injector, server as Http.Server, hostInfo);\n settings.set(\"httpPort\", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);\n return server;\n };\n }\n}\n"]}
@@ -4,8 +4,8 @@ import Https from "https";
4
4
  import { listenServer } from "./listenServer.js";
5
5
  export function createHttpsServer(injector, requestListener) {
6
6
  const { settings } = injector;
7
- const httpsPort = settings.getRaw("httpsPort");
8
- const httpsOptions = settings.getRaw("httpsOptions");
7
+ const httpsPort = settings.get("httpsPort");
8
+ const httpsOptions = settings.get("httpsOptions");
9
9
  const server = httpsPort !== false ? Https.createServer(httpsOptions, requestListener) : null;
10
10
  injector.addProvider(Https.Server, {
11
11
  scope: ProviderScope.SINGLETON,
@@ -16,7 +16,7 @@ export function createHttpsServer(injector, requestListener) {
16
16
  const hostInfo = getHostInfoFromPort("https", httpsPort);
17
17
  return async () => {
18
18
  const resolvedHostInfo = await listenServer(injector, server, hostInfo);
19
- settings.setRaw("httpsPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
19
+ settings.set("httpsPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
20
20
  return server;
21
21
  };
22
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createHttpsServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpsServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAC,MAAM,UAAU,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,iBAAiB,CAAC,QAAyB,EAAE,eAAsC;IACjG,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC/C,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAErD,MAAM,MAAM,GAAG,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE9F,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE;QACjC,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B,IAAI,MAAM,EAAE;QACV,MAAM,QAAQ,GAAG,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAEzD,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,MAAsB,EAAE,QAAQ,CAAC,CAAC;YACxF,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,gBAAgB,CAAC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;YACrF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH;AACH,CAAC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Https from \"https\";\nimport Http from \"http\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpsServer(injector: InjectorService, requestListener?: Http.RequestListener) {\n const {settings} = injector;\n const httpsPort = settings.getRaw(\"httpsPort\");\n const httpsOptions = settings.getRaw(\"httpsOptions\");\n\n const server = httpsPort !== false ? Https.createServer(httpsOptions, requestListener) : null;\n\n injector.addProvider(Https.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(Https.Server);\n\n if (server) {\n const hostInfo = getHostInfoFromPort(\"https\", httpsPort);\n\n return async () => {\n const resolvedHostInfo = await listenServer(injector, server as Https.Server, hostInfo);\n settings.setRaw(\"httpsPort\", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);\n return server;\n };\n }\n}\n"]}
1
+ {"version":3,"file":"createHttpsServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpsServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAC,MAAM,UAAU,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,iBAAiB,CAAC,QAAyB,EAAE,eAAsC;IACjG,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC5C,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAElD,MAAM,MAAM,GAAG,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE9F,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE;QACjC,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B,IAAI,MAAM,EAAE;QACV,MAAM,QAAQ,GAAG,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAEzD,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,MAAsB,EAAE,QAAQ,CAAC,CAAC;YACxF,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,gBAAgB,CAAC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;YAClF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH;AACH,CAAC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Https from \"https\";\nimport Http from \"http\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpsServer(injector: InjectorService, requestListener?: Http.RequestListener) {\n const {settings} = injector;\n const httpsPort = settings.get(\"httpsPort\");\n const httpsOptions = settings.get(\"httpsOptions\");\n\n const server = httpsPort !== false ? Https.createServer(httpsOptions, requestListener) : null;\n\n injector.addProvider(Https.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(Https.Server);\n\n if (server) {\n const hostInfo = getHostInfoFromPort(\"https\", httpsPort);\n\n return async () => {\n const resolvedHostInfo = await listenServer(injector, server as Https.Server, hostInfo);\n settings.set(\"httpsPort\", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);\n return server;\n };\n }\n}\n"]}
@@ -1,20 +1,18 @@
1
- import { InjectorService, setLoggerLevel } from "@tsed/di";
2
- import { $log } from "@tsed/logger";
3
1
  import { toMap } from "@tsed/core";
2
+ import { InjectorService, setLoggerConfiguration } from "@tsed/di";
3
+ import { $log } from "@tsed/logger";
4
4
  import { PlatformConfiguration } from "../config/services/PlatformConfiguration.js";
5
- import { PlatformHandler } from "../services/PlatformHandler.js";
6
- import { PlatformResponse } from "../services/PlatformResponse.js";
7
- import { PlatformRouter } from "../services/PlatformRouter.js";
8
- import { PlatformApplication } from "../services/PlatformApplication.js";
9
5
  import { Platform } from "../services/Platform.js";
10
- import { PlatformRequest } from "../services/PlatformRequest.js";
11
6
  import { PlatformAdapter } from "../services/PlatformAdapter.js";
7
+ import { PlatformApplication } from "../services/PlatformApplication.js";
8
+ import { PlatformHandler } from "../services/PlatformHandler.js";
9
+ import { PlatformRequest } from "../services/PlatformRequest.js";
10
+ import { PlatformResponse } from "../services/PlatformResponse.js";
12
11
  $log.name = "TSED";
13
12
  const DEFAULT_PROVIDERS = [
14
13
  { provide: PlatformHandler },
15
14
  { provide: PlatformResponse },
16
15
  { provide: PlatformRequest },
17
- { provide: PlatformRouter },
18
16
  { provide: PlatformApplication },
19
17
  { provide: Platform }
20
18
  ];
@@ -30,7 +28,7 @@ export function createInjector({ adapter, settings = {} }) {
30
28
  });
31
29
  }
32
30
  injector.invoke(PlatformAdapter);
33
- setLoggerLevel(injector);
31
+ setLoggerConfiguration(injector);
34
32
  const instance = injector.get(PlatformAdapter);
35
33
  instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];
36
34
  toMap(instance.providers, "provide").forEach((provider, token) => {
@@ -1 +1 @@
1
- {"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../src/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAgB,cAAc,EAAC,MAAM,UAAU,CAAC;AACvE,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAC,KAAK,EAAO,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,qBAAqB,EAAC,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAE5D,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;AAEnB,MAAM,iBAAiB,GAAG;IACxB,EAAC,OAAO,EAAE,eAAe,EAAC;IAC1B,EAAC,OAAO,EAAE,gBAAgB,EAAC;IAC3B,EAAC,OAAO,EAAE,eAAe,EAAC;IAC1B,EAAC,OAAO,EAAE,cAAc,EAAC;IACzB,EAAC,OAAO,EAAE,mBAAmB,EAAC;IAC9B,EAAC,OAAO,EAAE,QAAQ,EAAC;CACpB,CAAC;AAOF,MAAM,UAAU,cAAc,CAAC,EAAC,OAAO,EAAE,QAAQ,GAAG,EAAE,EAAwB;IAC5E,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAE5C,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAC3D,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEhC,IAAI,OAAO,EAAE;QACX,QAAQ,CAAC,WAAW,CAAC,eAAe,EAAE;YACpC,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;KACJ;IAED,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAEjC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEzB,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAkB,eAAe,CAAE,CAAC;IAEjE,QAAQ,CAAC,SAAS,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAEnE,KAAK,CAAoB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QAClF,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAErC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {InjectorService, ProviderOpts, setLoggerLevel} from \"@tsed/di\";\nimport {$log} from \"@tsed/logger\";\nimport {toMap, Type} from \"@tsed/core\";\nimport {PlatformConfiguration} from \"../config/services/PlatformConfiguration\";\nimport {PlatformHandler} from \"../services/PlatformHandler\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\nimport {PlatformRouter} from \"../services/PlatformRouter\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformAdapter} from \"../services/PlatformAdapter\";\n\n$log.name = \"TSED\";\n\nconst DEFAULT_PROVIDERS = [\n {provide: PlatformHandler},\n {provide: PlatformResponse},\n {provide: PlatformRequest},\n {provide: PlatformRouter},\n {provide: PlatformApplication},\n {provide: Platform}\n];\n\ninterface CreateInjectorOptions {\n adapter?: Type<PlatformAdapter<any, any>>;\n settings?: Partial<TsED.Configuration>;\n}\n\nexport function createInjector({adapter, settings = {}}: CreateInjectorOptions) {\n const injector = new InjectorService();\n injector.addProvider(PlatformConfiguration);\n\n injector.settings = injector.invoke(PlatformConfiguration);\n injector.logger = $log;\n injector.settings.set(settings);\n\n if (adapter) {\n injector.addProvider(PlatformAdapter, {\n useClass: adapter\n });\n }\n\n injector.invoke(PlatformAdapter);\n\n setLoggerLevel(injector);\n\n const instance = injector.get<PlatformAdapter>(PlatformAdapter)!;\n\n instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];\n\n toMap<any, ProviderOpts>(instance.providers, \"provide\").forEach((provider, token) => {\n injector.addProvider(token, provider);\n });\n\n injector.invoke(PlatformApplication);\n\n return injector;\n}\n"]}
1
+ {"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../src/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAO,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,eAAe,EAAgB,sBAAsB,EAAC,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAC,qBAAqB,EAAC,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAE9D,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;AAEnB,MAAM,iBAAiB,GAAG;IACxB,EAAC,OAAO,EAAE,eAAe,EAAC;IAC1B,EAAC,OAAO,EAAE,gBAAgB,EAAC;IAC3B,EAAC,OAAO,EAAE,eAAe,EAAC;IAC1B,EAAC,OAAO,EAAE,mBAAmB,EAAC;IAC9B,EAAC,OAAO,EAAE,QAAQ,EAAC;CACpB,CAAC;AAOF,MAAM,UAAU,cAAc,CAAC,EAAC,OAAO,EAAE,QAAQ,GAAG,EAAE,EAAwB;IAC5E,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAE5C,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAC3D,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEhC,IAAI,OAAO,EAAE;QACX,QAAQ,CAAC,WAAW,CAAC,eAAe,EAAE;YACpC,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;KACJ;IAED,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAEjC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAEjC,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAkB,eAAe,CAAE,CAAC;IAEjE,QAAQ,CAAC,SAAS,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAEnE,KAAK,CAAoB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QAClF,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAErC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {toMap, Type} from \"@tsed/core\";\nimport {InjectorService, ProviderOpts, setLoggerConfiguration} from \"@tsed/di\";\nimport {$log} from \"@tsed/logger\";\nimport {PlatformConfiguration} from \"../config/services/PlatformConfiguration\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformAdapter} from \"../services/PlatformAdapter\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformHandler} from \"../services/PlatformHandler\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\n$log.name = \"TSED\";\n\nconst DEFAULT_PROVIDERS = [\n {provide: PlatformHandler},\n {provide: PlatformResponse},\n {provide: PlatformRequest},\n {provide: PlatformApplication},\n {provide: Platform}\n];\n\ninterface CreateInjectorOptions {\n adapter?: Type<PlatformAdapter<any>>;\n settings?: Partial<TsED.Configuration>;\n}\n\nexport function createInjector({adapter, settings = {}}: CreateInjectorOptions) {\n const injector = new InjectorService();\n injector.addProvider(PlatformConfiguration);\n\n injector.settings = injector.invoke(PlatformConfiguration);\n injector.logger = $log;\n injector.settings.set(settings);\n\n if (adapter) {\n injector.addProvider(PlatformAdapter, {\n useClass: adapter\n });\n }\n\n injector.invoke(PlatformAdapter);\n\n setLoggerConfiguration(injector);\n\n const instance = injector.get<PlatformAdapter>(PlatformAdapter)!;\n\n instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];\n\n toMap<any, ProviderOpts>(instance.providers, \"provide\").forEach((provider, token) => {\n injector.addProvider(token, provider);\n });\n\n injector.invoke(PlatformApplication);\n\n return injector;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { getContext } from "@tsed/di";
2
+ export function ensureContext(request, cb, fallback) {
3
+ const $ctx = getContext();
4
+ if ($ctx) {
5
+ return cb($ctx);
6
+ }
7
+ if (!request?.$ctx && fallback) {
8
+ return fallback();
9
+ }
10
+ return request.$ctx.runInContext(() => cb(request.$ctx));
11
+ }
12
+ //# sourceMappingURL=ensureContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureContext.js","sourceRoot":"","sources":["../../../src/utils/ensureContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,MAAM,UAAU,aAAa,CAAC,OAAY,EAAE,EAAkC,EAAE,QAAqB;IACnG,MAAM,IAAI,GAAG,UAAU,EAAmB,CAAC;IAE3C,IAAI,IAAI,EAAE;QACR,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;KACjB;IAED,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE;QAC9B,OAAO,QAAQ,EAAE,CAAC;KACnB;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import {getContext} from \"@tsed/di\";\nimport {PlatformContext} from \"../domain/PlatformContext\";\n\nexport function ensureContext(request: any, cb: ($ctx: PlatformContext) => any, fallback?: () => void) {\n const $ctx = getContext<PlatformContext>();\n\n if ($ctx) {\n return cb($ctx);\n }\n\n if (!request?.$ctx && fallback) {\n return fallback();\n }\n\n return request.$ctx.runInContext(() => cb(request.$ctx));\n}\n"]}
@@ -1,15 +1,13 @@
1
- import { deepMerge, Env, Store } from "@tsed/core";
2
- import { ProviderScope, ProviderType } from "@tsed/di";
1
+ import { Env, Store } from "@tsed/core";
2
+ import { mergeMount, ProviderScope, ProviderType } from "@tsed/di";
3
3
  export function getConfiguration(configuration = {}, module = null) {
4
4
  if (configuration.$$resolved) {
5
5
  return configuration;
6
6
  }
7
7
  const store = module ? Store.from(module).get("configuration") || {} : {};
8
8
  const env = configuration.env || store.env || process.env.NODE_ENV || Env.DEV;
9
- const config = {
9
+ return {
10
10
  $$resolved: true,
11
- exclude: ["**/*.spec.ts", "**/*.spec.js"],
12
- componentsScan: ["${rootDir}/mvc/**/*.ts", "${rootDir}/services/**/*.ts", "${rootDir}/middlewares/**/*.ts"],
13
11
  env,
14
12
  httpPort: 8080,
15
13
  httpsPort: false,
@@ -20,11 +18,7 @@ export function getConfiguration(configuration = {}, module = null) {
20
18
  ...store.scopes,
21
19
  ...configuration.scopes
22
20
  },
23
- mount: store.mount || configuration.mount
24
- ? deepMerge(store.mount || {}, configuration.mount || {})
25
- : {
26
- "/rest": "${rootDir}/controllers/**/*.ts"
27
- },
21
+ mount: mergeMount(store.mount, configuration.mount),
28
22
  logger: {
29
23
  debug: false,
30
24
  level: env === Env.TEST ? "off" : "info",
@@ -34,9 +28,5 @@ export function getConfiguration(configuration = {}, module = null) {
34
28
  jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2
35
29
  }
36
30
  };
37
- if (!configuration.disableComponentsScan && store.componentsScan && configuration.componentsScan) {
38
- config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];
39
- }
40
- return config;
41
31
  }
42
32
  //# sourceMappingURL=getConfiguration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getConfiguration.js","sourceRoot":"","sources":["../../../src/utils/getConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,GAAG,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AACvD,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AAErD,MAAM,UAAU,gBAAgB,CAAC,gBAAqB,EAAE,EAAE,SAA2B,IAAI;IACvF,IAAI,aAAa,CAAC,UAAU,EAAE;QAC5B,OAAO,aAAa,CAAC;KACtB;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAK,OAAO,CAAC,GAAG,CAAC,QAAgB,IAAI,GAAG,CAAC,GAAG,CAAC;IAEvF,MAAM,MAAM,GAAG;QACb,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC;QACzC,cAAc,EAAE,CAAC,wBAAwB,EAAE,6BAA6B,EAAE,gCAAgC,CAAC;QAC3G,GAAG;QACH,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,KAAK;QAChB,GAAG,KAAK;QACR,GAAG,aAAa;QAChB,MAAM,EAAE;YACN,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,SAAS;YAClD,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;SACxB;QACD,KAAK,EACH,KAAK,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK;YAChC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,aAAa,CAAC,KAAK,IAAI,EAAE,CAAC;YACzD,CAAC,CAAC;gBACE,OAAO,EAAE,gCAAgC;aAC1C;QACP,MAAM,EAAE;YACN,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;YACxC,UAAU,EAAE,IAAI;YAChB,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;YACvB,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3D;KACF,CAAC;IAEF,IAAI,CAAC,aAAa,CAAC,qBAAqB,IAAI,KAAK,CAAC,cAAc,IAAI,aAAa,CAAC,cAAc,EAAE;QAChG,MAAM,CAAC,cAAc,GAAG,CAAC,GAAG,KAAK,CAAC,cAAc,EAAE,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;KACpF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import {deepMerge, Env, Store, Type} from \"@tsed/core\";\nimport {ProviderScope, ProviderType} from \"@tsed/di\";\n\nexport function getConfiguration(configuration: any = {}, module: Type<any> | null = null) {\n if (configuration.$$resolved) {\n return configuration;\n }\n\n const store = module ? Store.from(module).get(\"configuration\") || {} : {};\n const env = configuration.env || store.env || (process.env.NODE_ENV as Env) || Env.DEV;\n\n const config = {\n $$resolved: true,\n exclude: [\"**/*.spec.ts\", \"**/*.spec.js\"],\n componentsScan: [\"${rootDir}/mvc/**/*.ts\", \"${rootDir}/services/**/*.ts\", \"${rootDir}/middlewares/**/*.ts\"],\n env,\n httpPort: 8080,\n httpsPort: false,\n ...store,\n ...configuration,\n scopes: {\n [ProviderType.CONTROLLER]: ProviderScope.SINGLETON,\n ...store.scopes,\n ...configuration.scopes\n },\n mount:\n store.mount || configuration.mount\n ? deepMerge(store.mount || {}, configuration.mount || {})\n : {\n \"/rest\": \"${rootDir}/controllers/**/*.ts\"\n },\n logger: {\n debug: false,\n level: env === Env.TEST ? \"off\" : \"info\",\n logRequest: true,\n ...store.logger,\n ...configuration.logger,\n jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2\n }\n };\n\n if (!configuration.disableComponentsScan && store.componentsScan && configuration.componentsScan) {\n config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];\n }\n\n return config;\n}\n"]}
1
+ {"version":3,"file":"getConfiguration.js","sourceRoot":"","sources":["../../../src/utils/getConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAE,aAAa,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AAEjE,MAAM,UAAU,gBAAgB,CAAC,gBAAqB,EAAE,EAAE,SAA2B,IAAI;IACvF,IAAI,aAAa,CAAC,UAAU,EAAE;QAC5B,OAAO,aAAa,CAAC;KACtB;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAK,OAAO,CAAC,GAAG,CAAC,QAAgB,IAAI,GAAG,CAAC,GAAG,CAAC;IAEvF,OAAO;QACL,UAAU,EAAE,IAAI;QAChB,GAAG;QACH,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,KAAK;QAChB,GAAG,KAAK;QACR,GAAG,aAAa;QAChB,MAAM,EAAE;YACN,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,SAAS;YAClD,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;SACxB;QACD,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC;QACnD,MAAM,EAAE;YACN,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;YACxC,UAAU,EAAE,IAAI;YAChB,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;YACvB,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3D;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {Env, Store, Type} from \"@tsed/core\";\nimport {mergeMount, ProviderScope, ProviderType} from \"@tsed/di\";\n\nexport function getConfiguration(configuration: any = {}, module: Type<any> | null = null) {\n if (configuration.$$resolved) {\n return configuration;\n }\n\n const store = module ? Store.from(module).get(\"configuration\") || {} : {};\n const env = configuration.env || store.env || (process.env.NODE_ENV as Env) || Env.DEV;\n\n return {\n $$resolved: true,\n env,\n httpPort: 8080,\n httpsPort: false,\n ...store,\n ...configuration,\n scopes: {\n [ProviderType.CONTROLLER]: ProviderScope.SINGLETON,\n ...store.scopes,\n ...configuration.scopes\n },\n mount: mergeMount(store.mount, configuration.mount),\n logger: {\n debug: false,\n level: env === Env.TEST ? \"off\" : \"info\",\n logRequest: true,\n ...store.logger,\n ...configuration.logger,\n jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2\n }\n };\n}\n"]}
@@ -6,18 +6,20 @@ export function printRoutes(routes) {
6
6
  PUT: "blue",
7
7
  DELETE: "red",
8
8
  PATCH: "magenta",
9
- ALL: "cyan"
9
+ ALL: "cyan",
10
+ STATICS: "white"
10
11
  };
11
12
  const list = routes.map((route) => {
12
- const obj = route.toJSON();
13
- const method = obj.method.toUpperCase();
14
- obj.method = {
15
- length: method.length,
16
- toString: () => {
17
- return colorize(method, mapColor[method]);
13
+ const method = route.method.toUpperCase();
14
+ return {
15
+ ...route,
16
+ method: {
17
+ length: method.length,
18
+ toString: () => {
19
+ return colorize(method, mapColor[method]);
20
+ }
18
21
  }
19
22
  };
20
- return obj;
21
23
  });
22
24
  const str = $log.drawTable(list, {
23
25
  padding: 1,
@@ -1 +1 @@
1
- {"version":3,"file":"printRoutes.js","sourceRoot":"","sources":["../../../src/utils/printRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAG5C,MAAM,UAAU,WAAW,CAAC,MAA8B;IACxD,MAAM,QAAQ,GAA4B;QACxC,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,MAAM;QACX,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,MAAM;KACZ,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAChC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAExC,GAAG,CAAC,MAAM,GAAG;YACX,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,GAAG,EAAE;gBACb,OAAO,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YAC5C,CAAC;SACK,CAAC;QAET,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;QAC/B,OAAO,EAAE,CAAC;QACV,MAAM,EAAE;YACN,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,UAAU;YACf,IAAI,EAAE,cAAc;SACrB;KACF,CAAC,CAAC;IAEH,OAAO,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["import {$log, colorize} from \"@tsed/logger\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\n\nexport function printRoutes(routes: PlatformRouteDetails[]) {\n const mapColor: {[key: string]: string} = {\n GET: \"green\",\n POST: \"yellow\",\n PUT: \"blue\",\n DELETE: \"red\",\n PATCH: \"magenta\",\n ALL: \"cyan\"\n };\n\n const list = routes.map((route) => {\n const obj = route.toJSON();\n const method = obj.method.toUpperCase();\n\n obj.method = {\n length: method.length,\n toString: () => {\n return colorize(method, mapColor[method]);\n }\n } as any;\n\n return obj;\n });\n\n const str = $log.drawTable(list, {\n padding: 1,\n header: {\n method: \"Method\",\n url: \"Endpoint\",\n name: \"Class method\"\n }\n });\n\n return \"\\n\" + str.trim();\n}\n"]}
1
+ {"version":3,"file":"printRoutes.js","sourceRoot":"","sources":["../../../src/utils/printRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAG5C,MAAM,UAAU,WAAW,CAAC,MAA8B;IACxD,MAAM,QAAQ,GAA4B;QACxC,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,MAAM;QACX,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,MAAM;QACX,OAAO,EAAE,OAAO;KACjB,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAChC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAE1C,OAAO;YACL,GAAG,KAAK;YACR,MAAM,EAAE;gBACN,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,QAAQ,EAAE,GAAG,EAAE;oBACb,OAAO,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC5C,CAAC;aACF;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;QAC/B,OAAO,EAAE,CAAC;QACV,MAAM,EAAE;YACN,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,UAAU;YACf,IAAI,EAAE,cAAc;SACrB;KACF,CAAC,CAAC;IAEH,OAAO,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["import {$log, colorize} from \"@tsed/logger\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\n\nexport function printRoutes(routes: PlatformRouteDetails[]) {\n const mapColor: {[key: string]: string} = {\n GET: \"green\",\n POST: \"yellow\",\n PUT: \"blue\",\n DELETE: \"red\",\n PATCH: \"magenta\",\n ALL: \"cyan\",\n STATICS: \"white\"\n };\n\n const list = routes.map((route) => {\n const method = route.method.toUpperCase();\n\n return {\n ...route,\n method: {\n length: method.length,\n toString: () => {\n return colorize(method, mapColor[method]);\n }\n }\n };\n });\n\n const str = $log.drawTable(list, {\n padding: 1,\n header: {\n method: \"Method\",\n url: \"Endpoint\",\n name: \"Class method\"\n }\n });\n\n return \"\\n\" + str.trim();\n}\n"]}
@@ -1,12 +1,3 @@
1
- function mergeHeaders(specHeaders, headers) {
2
- return Object.entries(specHeaders).reduce((headers, [key, item]) => {
3
- key = key.toLowerCase();
4
- return {
5
- ...headers,
6
- [key]: headers[key] === undefined ? String(item.example) : headers[key]
7
- };
8
- }, headers);
9
- }
10
1
  /**
11
2
  * @ignore
12
3
  */
@@ -21,11 +12,14 @@ export function setResponseHeaders(ctx) {
21
12
  response.status(operation.getStatus());
22
13
  }
23
14
  const statusCode = response.statusCode;
24
- const headers = operation.getHeadersOf(response.statusCode);
25
- const mergedHeaders = mergeHeaders(headers, response.getHeaders());
26
- response.setHeaders(mergedHeaders);
15
+ const headers = operation.getHeadersOf(statusCode);
16
+ Object.entries(headers).forEach(([key, item]) => {
17
+ if (!response.get(key)) {
18
+ response.setHeader(key, String(item.example));
19
+ }
20
+ });
27
21
  if (operation.isRedirection(statusCode)) {
28
- response.redirect(statusCode, String(mergedHeaders["location"]));
22
+ response.redirect(statusCode, response.get("location"));
29
23
  }
30
24
  }
31
25
  //# sourceMappingURL=setResponseHeaders.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setResponseHeaders.js","sourceRoot":"","sources":["../../../src/utils/setResponseHeaders.ts"],"names":[],"mappings":"AAIA,SAAS,YAAY,CAAC,WAA2D,EAAE,OAA4B;IAC7G,OAAO,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;QACjE,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACxB,OAAO;YACL,GAAG,OAAO;YACV,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;SACxE,CAAC;IACJ,CAAC,EAAE,OAAO,CAAC,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAoB;IACrD,MAAM,EAAC,QAAQ,EAAE,QAAQ,EAAC,GAAG,GAAG,CAAC;IACjC,MAAM,EAAC,SAAS,EAAC,GAAG,QAAQ,CAAC;IAE7B,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE;QACrB,OAAO;KACR;IAED,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;QACzB,kDAAkD;QAClD,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;KACxC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;IACvC,MAAM,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAEnE,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAEnC,IAAI,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE;QACvC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;KAClE;AACH,CAAC","sourcesContent":["import {JsonHeader} from \"@tsed/schema\";\nimport {OutgoingHttpHeaders} from \"http\";\nimport {PlatformContext} from \"../domain/PlatformContext\";\n\nfunction mergeHeaders(specHeaders: Record<string, JsonHeader & {example: string}>, headers: OutgoingHttpHeaders) {\n return Object.entries(specHeaders).reduce((headers, [key, item]) => {\n key = key.toLowerCase();\n return {\n ...headers,\n [key]: headers[key] === undefined ? String(item.example) : headers[key]\n };\n }, headers);\n}\n\n/**\n * @ignore\n */\nexport function setResponseHeaders(ctx: PlatformContext) {\n const {response, endpoint} = ctx;\n const {operation} = endpoint;\n\n if (response.isDone()) {\n return;\n }\n\n if (!response.hasStatus()) {\n // apply status only if the isn't already modified\n response.status(operation.getStatus());\n }\n\n const statusCode = response.statusCode;\n const headers = operation.getHeadersOf(response.statusCode);\n const mergedHeaders = mergeHeaders(headers, response.getHeaders());\n\n response.setHeaders(mergedHeaders);\n\n if (operation.isRedirection(statusCode)) {\n response.redirect(statusCode, String(mergedHeaders[\"location\"]));\n }\n}\n"]}
1
+ {"version":3,"file":"setResponseHeaders.js","sourceRoot":"","sources":["../../../src/utils/setResponseHeaders.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAoB;IACrD,MAAM,EAAC,QAAQ,EAAE,QAAQ,EAAC,GAAG,GAAG,CAAC;IACjC,MAAM,EAAC,SAAS,EAAC,GAAG,QAAQ,CAAC;IAE7B,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE;QACrB,OAAO;KACR;IAED,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;QACzB,kDAAkD;QAClD,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;KACxC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;IACvC,MAAM,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAEnD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAQ,EAAE,EAAE;QACrD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACtB,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;SAC/C;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE;QACvC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;KACzD;AACH,CAAC","sourcesContent":["import {PlatformContext} from \"../domain/PlatformContext\";\n\n/**\n * @ignore\n */\nexport function setResponseHeaders(ctx: PlatformContext) {\n const {response, endpoint} = ctx;\n const {operation} = endpoint;\n\n if (response.isDone()) {\n return;\n }\n\n if (!response.hasStatus()) {\n // apply status only if the isn't already modified\n response.status(operation.getStatus());\n }\n\n const statusCode = response.statusCode;\n const headers = operation.getHeadersOf(statusCode);\n\n Object.entries(headers).forEach(([key, item]: any[]) => {\n if (!response.get(key)) {\n response.setHeader(key, String(item.example));\n }\n });\n\n if (operation.isRedirection(statusCode)) {\n response.redirect(statusCode, response.get(\"location\"));\n }\n}\n"]}
@@ -1,25 +1,26 @@
1
1
  /// <reference types="node" />
2
2
  import { Type } from "@tsed/core";
3
3
  import { InjectorService, ProviderOpts, TokenProvider } from "@tsed/di";
4
- import { Platform } from "../services/Platform";
5
- import { PlatformApplication } from "../services/PlatformApplication";
4
+ import { PlatformLayer } from "@tsed/platform-router";
6
5
  import type { IncomingMessage, ServerResponse } from "http";
6
+ import { Platform } from "../services/Platform";
7
7
  import { PlatformAdapter, PlatformBuilderSettings } from "../services/PlatformAdapter";
8
+ import { PlatformApplication } from "../services/PlatformApplication";
8
9
  /**
9
10
  * @platform
10
11
  */
11
- export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Router> {
12
+ export declare class PlatformBuilder<App = TsED.Application> {
12
13
  #private;
13
- static adapter: Type<PlatformAdapter<any, any>>;
14
+ static adapter: Type<PlatformAdapter<any>>;
14
15
  readonly name: string;
15
16
  protected startedAt: Date;
16
17
  protected current: Date;
17
- protected constructor(adapter: Type<PlatformAdapter<App, Router>> | undefined, module: Type, settings: Partial<TsED.Configuration>);
18
+ protected constructor(adapter: Type<PlatformAdapter<App>> | undefined, module: Type, settings: Partial<TsED.Configuration>);
18
19
  get injector(): InjectorService;
19
20
  get rootModule(): any;
20
- get app(): PlatformApplication<App, Router>;
21
+ get app(): PlatformApplication<App>;
21
22
  get platform(): Platform;
22
- get adapter(): PlatformAdapter<App, Router>;
23
+ get adapter(): PlatformAdapter<App>;
23
24
  /**
24
25
  * Return the settings configured by the decorator @@Configuration@@.
25
26
  *
@@ -41,26 +42,25 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
41
42
  *
42
43
  * @returns {PlatformConfiguration}
43
44
  */
44
- get settings(): TsED.Configuration & import("@tsed/di").DIConfiguration;
45
+ get settings(): import("@tsed/di").DIConfiguration;
45
46
  get logger(): import("@tsed/di").DILogger;
46
47
  get disableBootstrapLog(): any;
47
- static create<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>): PlatformBuilder<App, Router>;
48
- static build<App = TsED.Application, Router = TsED.Router>(module: Type<any>, { adapter, ...settings }: PlatformBuilderSettings<App, Router>): PlatformBuilder<App, Router>;
48
+ static create<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>): PlatformBuilder<App>;
49
+ static build<App = TsED.Application>(module: Type<any>, { adapter, ...settings }: PlatformBuilderSettings<App>): PlatformBuilder<App>;
49
50
  /**
50
51
  * Bootstrap a server application
51
52
  * @param module
52
53
  * @param settings
53
54
  */
54
- static bootstrap<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>): Promise<PlatformBuilder<App, Router>>;
55
- callback(): (req: IncomingMessage, res: ServerResponse) => void;
56
- callback(req: IncomingMessage, res: ServerResponse): void;
55
+ static bootstrap<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>): Promise<PlatformBuilder<App>>;
56
+ callback(): (req: IncomingMessage, res: ServerResponse) => any;
57
+ callback(req: IncomingMessage, res: ServerResponse): any;
57
58
  log(...data: any[]): any;
58
59
  /**
59
60
  * Add classes to the components list
60
61
  * @param classes
61
- * @deprecated
62
62
  */
63
- addComponents(classes: any | any[]): this;
63
+ addComponents(classes: Type | Type[]): this;
64
64
  /**
65
65
  * Add classes decorated by @@Controller@@ to components container.
66
66
  *
@@ -92,6 +92,7 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
92
92
  useProvider(token: Type<any>, settings?: Partial<ProviderOpts>): this;
93
93
  bootstrap(): Promise<this>;
94
94
  protected loadRoutes(): Promise<void>;
95
+ protected mapRouters(): Promise<void>;
95
96
  protected diff(): string;
96
97
  /**
97
98
  * Load middlewares from configuration for the given hook
@@ -101,5 +102,5 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
101
102
  protected loadMiddlewaresFor(hook: string): void;
102
103
  protected createHttpServers(): void;
103
104
  protected listenServers(): Promise<void>;
104
- protected logRoutes(): Promise<void>;
105
+ protected logRoutes(layers: PlatformLayer[]): Promise<void>;
105
106
  }
@@ -1,44 +1,3 @@
1
- export interface PlatformLoggerSettings {
2
- /**
3
- * Enable debug mode. By default debug is false.
4
- */
5
- debug?: boolean;
6
- /**
7
- * Enable info mode. By default debug is false.
8
- */
9
- level?: "debug" | "info" | "warn" | "error" | "off";
10
- /**
11
- * Enable log performance tracker and disable log server.
12
- */
13
- perf?: boolean;
14
- /**
15
- * List of regexp to ignore log.
16
- */
17
- ignoreUrlPatterns?: string[];
18
- /**
19
- * The number of space characters to use as white space in JSON output. Default is 2 (0 in production).
20
- */
21
- jsonIndentation?: number;
22
- /**
23
- * A function called for each incoming request to create a request id.
24
- * @returns {number}
25
- */
26
- reqIdBuilder?: (req: TsED.Request) => string;
27
- /**
28
- * Disable routes table displayed in the logger. By default debug is `false`.
29
- */
30
- disableRoutesSummary?: boolean;
31
- /**
32
- * Disable bootstrap log displayed in the logger. By default debug is `false`.
33
- */
34
- disableBootstrapLog?: boolean;
35
- /**
36
- * Specify log format. Example: `%[%d{[yyyy-MM-dd hh:mm:ss,SSS}] %p%] %m`. See [@tsed/logger configuration](https://tsedio.github.io/logger/).
37
- */
38
- format?: string;
39
- /**
40
- * Specify the log stack size for the context.logger. When the stack.length is reach, the logger is flushed during the request.
41
- * Default size is set to 30.
42
- */
43
- maxStackSize?: number;
1
+ import { DILoggerOptions } from "@tsed/di";
2
+ export interface PlatformLoggerSettings extends DILoggerOptions {
44
3
  }
@@ -1,18 +1,13 @@
1
1
  /// <reference types="node" />
2
- import { Env, getHostInfoFromPort } from "@tsed/core";
2
+ import { getHostInfoFromPort } from "@tsed/core";
3
3
  import { DIConfiguration, TokenProvider } from "@tsed/di";
4
4
  import Https from "https";
5
5
  import { ConverterSettings } from "../interfaces/ConverterSettings";
6
- import { PlatformLoggerSettings } from "../interfaces/PlatformLoggerSettings";
7
6
  /**
8
7
  * `PlatformConfiguration` contains all information about your Server configuration.
9
8
  */
10
9
  export declare class PlatformConfiguration extends DIConfiguration {
11
10
  constructor();
12
- get version(): string;
13
- set version(v: string);
14
- get rootDir(): string;
15
- set rootDir(value: string);
16
11
  get port(): string | number | false;
17
12
  set port(value: string | number | false);
18
13
  get httpsOptions(): Https.ServerOptions;
@@ -21,30 +16,14 @@ export declare class PlatformConfiguration extends DIConfiguration {
21
16
  set httpPort(value: string | number | false);
22
17
  get httpsPort(): string | number | false;
23
18
  set httpsPort(value: string | number | false);
24
- get env(): Env;
25
- set env(value: Env);
26
19
  get mount(): Record<string, TokenProvider[]>;
27
20
  set mount(value: Record<string, TokenProvider[]>);
28
- /**
29
- * @deprecated
30
- */
31
- get componentsScan(): string[];
32
- /**
33
- * @deprecated
34
- */
35
- set componentsScan(value: string[]);
36
21
  get statics(): Record<string, (any | string)[]>;
37
22
  set statics(value: Record<string, (any | string)[]>);
38
23
  get acceptMimes(): string[];
39
24
  set acceptMimes(value: string[]);
40
- get debug(): boolean;
41
- set debug(debug: boolean);
42
25
  get converter(): Partial<ConverterSettings>;
43
26
  set converter(options: Partial<ConverterSettings>);
44
- get logger(): Partial<PlatformLoggerSettings>;
45
- set logger(value: Partial<PlatformLoggerSettings>);
46
- get exclude(): string[];
47
- set exclude(exclude: string[]);
48
27
  get additionalProperties(): boolean;
49
28
  /**
50
29
  *
@@ -1,16 +1,8 @@
1
1
  import { AnyPromiseResult, AnyToPromise } from "@tsed/core";
2
2
  import { PlatformContext } from "./PlatformContext";
3
- /**
4
- * @ignore
5
- */
6
- export interface HandlerContextOptions {
7
- $ctx: PlatformContext;
8
- err?: any;
9
- }
10
3
  export declare class AnyToPromiseWithCtx extends AnyToPromise {
11
4
  $ctx: PlatformContext;
12
- err: unknown;
13
- constructor({ $ctx, err }: HandlerContextOptions);
5
+ constructor($ctx: PlatformContext);
14
6
  isDone(): boolean;
15
7
  call(cb: Function): Promise<AnyPromiseResult<any>>;
16
8
  destroy(): void;
@@ -1,7 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  import { ContextMethods, DIContext, DIContextOptions } from "@tsed/di";
3
- import { IncomingMessage, ServerResponse } from "http";
3
+ import { PlatformHandlerMetadata } from "@tsed/platform-router";
4
4
  import { EndpointMetadata } from "@tsed/schema";
5
+ import { IncomingMessage, ServerResponse } from "http";
6
+ import { IncomingEvent } from "../interfaces/IncomingEvent";
5
7
  import { PlatformApplication } from "../services/PlatformApplication";
6
8
  import { PlatformRequest } from "../services/PlatformRequest";
7
9
  import { PlatformResponse } from "../services/PlatformResponse";
@@ -12,36 +14,54 @@ declare global {
12
14
  }
13
15
  }
14
16
  export interface PlatformContextOptions extends DIContextOptions {
15
- event: {
16
- response?: ServerResponse;
17
- request?: IncomingMessage;
18
- };
17
+ event: IncomingEvent;
19
18
  ignoreUrlPatterns?: any[];
20
19
  endpoint?: EndpointMetadata;
21
20
  }
22
- export declare class PlatformContext extends DIContext implements ContextMethods {
23
- /**
24
- * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
25
- */
26
- endpoint: EndpointMetadata;
21
+ export declare class PlatformContext<PReq extends PlatformRequest = PlatformRequest, PRes extends PlatformResponse = PlatformResponse> extends DIContext implements ContextMethods {
22
+ #private;
23
+ event: IncomingEvent;
27
24
  /**
28
25
  * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.
29
26
  */
30
27
  data: any;
28
+ /**
29
+ * The error caught by the current handler
30
+ */
31
+ error?: unknown;
32
+ /**
33
+ *
34
+ */
35
+ next?: any;
31
36
  /**
32
37
  * The current @@PlatformResponse@@.
33
38
  */
34
- response: PlatformResponse;
39
+ readonly response: PRes;
35
40
  /**
36
41
  * The current @@PlatformRequest@@.
37
42
  */
38
- request: PlatformRequest;
43
+ readonly request: PReq;
39
44
  private ignoreUrlPatterns;
40
- constructor({ event, endpoint, ignoreUrlPatterns, ResponseKlass, RequestKlass, ...options }: PlatformContextOptions);
45
+ constructor(options: PlatformContextOptions);
46
+ /**
47
+ * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
48
+ */
49
+ get endpoint(): EndpointMetadata;
50
+ set endpoint(endpoint: EndpointMetadata);
51
+ /**
52
+ * The current @@PlatformHandlerMetadata@@ resolved by Ts.ED during the request.
53
+ */
54
+ get handlerMetadata(): PlatformHandlerMetadata;
55
+ /**
56
+ * The current @@PlatformHandlerMetadata@@ resolved by Ts.ED during the request.
57
+ */
58
+ set handlerMetadata(metadata: PlatformHandlerMetadata);
41
59
  get url(): string;
42
- get app(): PlatformApplication<TsED.Application, TsED.Router>;
60
+ get app(): PlatformApplication<TsED.Application>;
61
+ start(): Promise<void>;
62
+ finish(): Promise<void>;
43
63
  destroy(): Promise<void>;
44
- isDone(): boolean;
64
+ isDone(): any;
45
65
  /**
46
66
  * Return the framework request instance (Express, Koa, etc...)
47
67
  */
@@ -62,4 +82,5 @@ export declare class PlatformContext extends DIContext implements ContextMethods
62
82
  * Return the original application instance.
63
83
  */
64
84
  getApp<T = any>(): T;
85
+ upgrade(event: IncomingEvent): void;
65
86
  }
@@ -1,22 +1,7 @@
1
- import { EndpointMetadata, JsonOperationRoute } from "@tsed/schema";
2
- import { ControllerProvider } from "./ControllerProvider";
3
- export interface PlatformRouterDetailsOptions {
4
- provider: ControllerProvider;
5
- endpoint: EndpointMetadata;
1
+ export interface PlatformRouteDetails {
6
2
  method: string;
3
+ name: string;
7
4
  url: string;
8
- }
9
- export declare class PlatformRouteDetails extends JsonOperationRoute<EndpointMetadata> {
10
- readonly rawBody: boolean;
11
- readonly provider: ControllerProvider;
12
- constructor(options?: Partial<PlatformRouteDetails>);
13
- toJSON(): {
14
- method: string;
15
- name: string;
16
- url: string;
17
- className: string;
18
- methodClassName: string;
19
- parameters: import("@tsed/schema").JsonParameterStore[];
20
- rawBody: boolean;
21
- };
5
+ className: string;
6
+ methodClassName: string;
22
7
  }
@@ -8,5 +8,6 @@ export * from "@tsed/platform-cache";
8
8
  export * from "@tsed/platform-middlewares";
9
9
  export * from "@tsed/components-scan";
10
10
  export * from "@tsed/platform-log-middleware";
11
+ export * from "@tsed/platform-router";
11
12
  export { $log, Logger } from "@tsed/logger";
12
13
  export { AcceptMime, Location, Redirect, View, Get, Post, Put, Patch, Delete, Head, Options, All } from "@tsed/schema";