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

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 (175) hide show
  1. package/jest.config.js +14 -0
  2. package/lib/cjs/builder/PlatformBuilder.js +65 -55
  3. package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
  4. package/lib/cjs/builder/PlatformControllerBuilder.js +1 -1
  5. package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -1
  6. package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -1
  7. package/lib/cjs/config/services/PlatformConfiguration.js +0 -70
  8. package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -1
  9. package/lib/cjs/domain/AnyToPromiseWithCtx.js +4 -3
  10. package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -1
  11. package/lib/cjs/domain/ControllerProvider.js +1 -0
  12. package/lib/cjs/domain/ControllerProvider.js.map +1 -1
  13. package/lib/cjs/domain/HandlerMetadata.js +10 -5
  14. package/lib/cjs/domain/HandlerMetadata.js.map +1 -1
  15. package/lib/cjs/domain/PlatformContext.js +54 -31
  16. package/lib/cjs/domain/PlatformContext.js.map +1 -1
  17. package/lib/cjs/domain/PlatformRouteDetails.js +5 -1
  18. package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -1
  19. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +2 -1
  20. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  21. package/lib/cjs/middlewares/PlatformMulterMiddleware.js +2 -0
  22. package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -1
  23. package/lib/cjs/services/FakeAdapter.js +1 -3
  24. package/lib/cjs/services/FakeAdapter.js.map +1 -1
  25. package/lib/cjs/services/Platform.js +4 -2
  26. package/lib/cjs/services/Platform.js.map +1 -1
  27. package/lib/cjs/services/PlatformAdapter.js +12 -0
  28. package/lib/cjs/services/PlatformAdapter.js.map +1 -1
  29. package/lib/cjs/services/PlatformApplication.js +2 -0
  30. package/lib/cjs/services/PlatformApplication.js.map +1 -1
  31. package/lib/cjs/services/PlatformHandler.js +7 -4
  32. package/lib/cjs/services/PlatformHandler.js.map +1 -1
  33. package/lib/cjs/services/PlatformMiddlewaresChain.js +3 -1
  34. package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
  35. package/lib/cjs/services/PlatformRequest.js +16 -11
  36. package/lib/cjs/services/PlatformRequest.js.map +1 -1
  37. package/lib/cjs/services/PlatformResponse.js +15 -11
  38. package/lib/cjs/services/PlatformResponse.js.map +1 -1
  39. package/lib/cjs/services/PlatformRouter.js +7 -1
  40. package/lib/cjs/services/PlatformRouter.js.map +1 -1
  41. package/lib/cjs/services/PlatformTest.js +20 -8
  42. package/lib/cjs/services/PlatformTest.js.map +1 -1
  43. package/lib/cjs/utils/createContext.js +28 -13
  44. package/lib/cjs/utils/createContext.js.map +1 -1
  45. package/lib/cjs/utils/createHttpServer.js +3 -3
  46. package/lib/cjs/utils/createHttpServer.js.map +1 -1
  47. package/lib/cjs/utils/createHttpsServer.js +3 -3
  48. package/lib/cjs/utils/createHttpsServer.js.map +1 -1
  49. package/lib/cjs/utils/createInjector.js +6 -6
  50. package/lib/cjs/utils/createInjector.js.map +1 -1
  51. package/lib/cjs/utils/getConfiguration.js +2 -12
  52. package/lib/cjs/utils/getConfiguration.js.map +1 -1
  53. package/lib/cjs/utils/setResponseHeaders.js +7 -13
  54. package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
  55. package/lib/esm/builder/PlatformBuilder.js +42 -55
  56. package/lib/esm/builder/PlatformBuilder.js.map +1 -1
  57. package/lib/esm/builder/PlatformControllerBuilder.js +1 -1
  58. package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -1
  59. package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -1
  60. package/lib/esm/config/services/PlatformConfiguration.js +0 -70
  61. package/lib/esm/config/services/PlatformConfiguration.js.map +1 -1
  62. package/lib/esm/domain/AnyToPromiseWithCtx.js +4 -3
  63. package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -1
  64. package/lib/esm/domain/ControllerProvider.js +1 -0
  65. package/lib/esm/domain/ControllerProvider.js.map +1 -1
  66. package/lib/esm/domain/HandlerMetadata.js +10 -5
  67. package/lib/esm/domain/HandlerMetadata.js.map +1 -1
  68. package/lib/esm/domain/PlatformContext.js +54 -31
  69. package/lib/esm/domain/PlatformContext.js.map +1 -1
  70. package/lib/esm/domain/PlatformRouteDetails.js +5 -1
  71. package/lib/esm/domain/PlatformRouteDetails.js.map +1 -1
  72. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +2 -1
  73. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  74. package/lib/esm/middlewares/PlatformMulterMiddleware.js +2 -0
  75. package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -1
  76. package/lib/esm/services/FakeAdapter.js +1 -3
  77. package/lib/esm/services/FakeAdapter.js.map +1 -1
  78. package/lib/esm/services/Platform.js +4 -2
  79. package/lib/esm/services/Platform.js.map +1 -1
  80. package/lib/esm/services/PlatformAdapter.js +12 -0
  81. package/lib/esm/services/PlatformAdapter.js.map +1 -1
  82. package/lib/esm/services/PlatformApplication.js +2 -0
  83. package/lib/esm/services/PlatformApplication.js.map +1 -1
  84. package/lib/esm/services/PlatformHandler.js +8 -5
  85. package/lib/esm/services/PlatformHandler.js.map +1 -1
  86. package/lib/esm/services/PlatformMiddlewaresChain.js +3 -1
  87. package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
  88. package/lib/esm/services/PlatformRequest.js +16 -11
  89. package/lib/esm/services/PlatformRequest.js.map +1 -1
  90. package/lib/esm/services/PlatformResponse.js +15 -11
  91. package/lib/esm/services/PlatformResponse.js.map +1 -1
  92. package/lib/esm/services/PlatformRouter.js +7 -1
  93. package/lib/esm/services/PlatformRouter.js.map +1 -1
  94. package/lib/esm/services/PlatformTest.js +20 -8
  95. package/lib/esm/services/PlatformTest.js.map +1 -1
  96. package/lib/esm/utils/createContext.js +26 -12
  97. package/lib/esm/utils/createContext.js.map +1 -1
  98. package/lib/esm/utils/createHttpServer.js +3 -3
  99. package/lib/esm/utils/createHttpServer.js.map +1 -1
  100. package/lib/esm/utils/createHttpsServer.js +3 -3
  101. package/lib/esm/utils/createHttpsServer.js.map +1 -1
  102. package/lib/esm/utils/createInjector.js +7 -7
  103. package/lib/esm/utils/createInjector.js.map +1 -1
  104. package/lib/esm/utils/getConfiguration.js +4 -14
  105. package/lib/esm/utils/getConfiguration.js.map +1 -1
  106. package/lib/esm/utils/setResponseHeaders.js +7 -13
  107. package/lib/esm/utils/setResponseHeaders.js.map +1 -1
  108. package/lib/types/builder/PlatformBuilder.d.ts +4 -5
  109. package/lib/types/config/interfaces/PlatformLoggerSettings.d.ts +2 -43
  110. package/lib/types/config/services/PlatformConfiguration.d.ts +1 -22
  111. package/lib/types/domain/PlatformContext.d.ts +20 -14
  112. package/lib/types/domain/PlatformRouteDetails.d.ts +1 -7
  113. package/lib/types/services/PlatformRequest.d.ts +11 -8
  114. package/lib/types/services/PlatformResponse.d.ts +8 -9
  115. package/lib/types/services/PlatformTest.d.ts +2 -2
  116. package/lib/types/utils/createContext.d.ts +4 -1
  117. package/lib/types/utils/createHttpsServer.d.ts +1 -0
  118. package/lib/types/utils/createInjector.d.ts +1 -1
  119. package/lib/types/utils/listenServer.d.ts +2 -0
  120. package/package.json +22 -21
  121. package/lib/cjs/middlewares/__mock__/FakeCtrl.js +0 -12
  122. package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +0 -1
  123. package/lib/cjs/utils/__mock__/Test1.js +0 -8
  124. package/lib/cjs/utils/__mock__/Test1.js.map +0 -1
  125. package/lib/cjs/utils/__mock__/Test2.js +0 -8
  126. package/lib/cjs/utils/__mock__/Test2.js.map +0 -1
  127. package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js +0 -12
  128. package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js.map +0 -1
  129. package/lib/cjs/utils/__mock__/module1/Module1.js +0 -19
  130. package/lib/cjs/utils/__mock__/module1/Module1.js.map +0 -1
  131. package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js +0 -17
  132. package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js.map +0 -1
  133. package/lib/cjs/utils/__mock__/module1/services/M1Service.js +0 -17
  134. package/lib/cjs/utils/__mock__/module1/services/M1Service.js.map +0 -1
  135. package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js +0 -15
  136. package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js.map +0 -1
  137. package/lib/cjs/utils/__mock__/module1/submodule/SubService.js +0 -12
  138. package/lib/cjs/utils/__mock__/module1/submodule/SubService.js.map +0 -1
  139. package/lib/cjs/utils/__mock__/module2/Module2.js +0 -18
  140. package/lib/cjs/utils/__mock__/module2/Module2.js.map +0 -1
  141. package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js +0 -12
  142. package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js.map +0 -1
  143. package/lib/esm/middlewares/__mock__/FakeCtrl.js +0 -9
  144. package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +0 -1
  145. package/lib/esm/utils/__mock__/Test1.js +0 -4
  146. package/lib/esm/utils/__mock__/Test1.js.map +0 -1
  147. package/lib/esm/utils/__mock__/Test2.js +0 -4
  148. package/lib/esm/utils/__mock__/Test2.js.map +0 -1
  149. package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js +0 -9
  150. package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js.map +0 -1
  151. package/lib/esm/utils/__mock__/module1/Module1.js +0 -16
  152. package/lib/esm/utils/__mock__/module1/Module1.js.map +0 -1
  153. package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js +0 -14
  154. package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js.map +0 -1
  155. package/lib/esm/utils/__mock__/module1/services/M1Service.js +0 -14
  156. package/lib/esm/utils/__mock__/module1/services/M1Service.js.map +0 -1
  157. package/lib/esm/utils/__mock__/module1/submodule/SubModule.js +0 -12
  158. package/lib/esm/utils/__mock__/module1/submodule/SubModule.js.map +0 -1
  159. package/lib/esm/utils/__mock__/module1/submodule/SubService.js +0 -9
  160. package/lib/esm/utils/__mock__/module1/submodule/SubService.js.map +0 -1
  161. package/lib/esm/utils/__mock__/module2/Module2.js +0 -15
  162. package/lib/esm/utils/__mock__/module2/Module2.js.map +0 -1
  163. package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js +0 -9
  164. package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js.map +0 -1
  165. package/lib/types/middlewares/__mock__/FakeCtrl.d.ts +0 -2
  166. package/lib/types/utils/__mock__/Test1.d.ts +0 -3
  167. package/lib/types/utils/__mock__/Test2.d.ts +0 -3
  168. package/lib/types/utils/__mock__/controllers/rest/TestCtrl.d.ts +0 -2
  169. package/lib/types/utils/__mock__/module1/Module1.d.ts +0 -2
  170. package/lib/types/utils/__mock__/module1/controllers/M1Ctrl1.d.ts +0 -5
  171. package/lib/types/utils/__mock__/module1/services/M1Service.d.ts +0 -5
  172. package/lib/types/utils/__mock__/module1/submodule/SubModule.d.ts +0 -2
  173. package/lib/types/utils/__mock__/module1/submodule/SubService.d.ts +0 -2
  174. package/lib/types/utils/__mock__/module2/Module2.d.ts +0 -2
  175. package/lib/types/utils/__mock__/module2/controllers/M2Ctrl.d.ts +0 -2
@@ -1,5 +1,7 @@
1
1
  import { AnyToPromise } from "@tsed/core";
2
2
  export class AnyToPromiseWithCtx extends AnyToPromise {
3
+ $ctx;
4
+ err;
3
5
  constructor({ $ctx, err }) {
4
6
  super();
5
7
  this.$ctx = $ctx;
@@ -7,14 +9,13 @@ export class AnyToPromiseWithCtx extends AnyToPromise {
7
9
  }
8
10
  isDone() {
9
11
  const { $ctx } = this;
10
- return ($ctx === null || $ctx === void 0 ? void 0 : $ctx.isDone()) || super.isDone();
12
+ return $ctx?.isDone() || super.isDone();
11
13
  }
12
14
  async call(cb) {
13
15
  return super.call(() => cb(this));
14
16
  }
15
17
  destroy() {
16
- // @ts-ignore
17
- delete this.$ctx;
18
+ this.$ctx = null;
18
19
  }
19
20
  isCanceledResponse(process) {
20
21
  return process === this.$ctx.getResponse();
@@ -1 +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"]}
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;IAC5C,IAAI,CAAkB;IACtB,GAAG,CAAU;IAEpB,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,IAAI,EAAE,MAAM,EAAE,IAAI,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,IAAI,CAAC,IAAI,GAAG,IAAW,CAAC;IAC1B,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 this.$ctx = null as any;\n }\n\n isCanceledResponse(process: any) {\n return process === this.$ctx.getResponse();\n }\n}\n"]}
@@ -2,6 +2,7 @@ import { Provider, ProviderType } from "@tsed/di";
2
2
  import { ROUTER_OPTIONS } from "../constants/routerOptions.js";
3
3
  let AUTO_INC = 0;
4
4
  export class ControllerProvider extends Provider {
5
+ tokenRouter;
5
6
  constructor(provide, options = {}) {
6
7
  super(provide, options);
7
8
  this.type = ProviderType.CONTROLLER;
@@ -1 +1 @@
1
- {"version":3,"file":"ControllerProvider.js","sourceRoot":"","sources":["../../../src/domain/ControllerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,QAAQ,EAAE,YAAY,EAAgB,MAAM,UAAU,CAAC;AACtF,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAE1D,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB,MAAM,OAAO,kBAA4B,SAAQ,QAAW;IAG1D,YAAY,OAAsB,EAAE,UAA6B,EAAE;QACjE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,GAAG,IAAI,CAAC,IAAI,WAAW,QAAQ,EAAE,EAAE,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,IAAK,EAAU,CAAC;IACvD,CAAC;IAED;;;OAGG;IACH,IAAI,aAAa,CAAC,KAAU;QAC1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW;QACb,OAAO,MAAM,CAAC,MAAM,CAClB;YACE,GAAG,EAAE,EAAE;YACP,QAAQ,EAAE,EAAE;YACZ,SAAS,EAAE,EAAE;SACd,EACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,CAAC,CAClC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW,CAAC,WAAkC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;QAChC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEjF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;YAC/C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import {ControllerMiddlewares, Provider, ProviderType, TokenProvider} from \"@tsed/di\";\nimport {ROUTER_OPTIONS} from \"../constants/routerOptions\";\n\nlet AUTO_INC = 0;\n\nexport class ControllerProvider<T = any> extends Provider<T> {\n readonly tokenRouter: string;\n\n constructor(provide: TokenProvider, options: Partial<Provider> = {}) {\n super(provide, options);\n this.type = ProviderType.CONTROLLER;\n this.tokenRouter = `${this.name}_ROUTER_${AUTO_INC++}`;\n }\n\n /**\n *\n */\n get routerOptions(): any {\n return this.store.get(ROUTER_OPTIONS) || ({} as any);\n }\n\n /**\n *\n * @param value\n */\n set routerOptions(value: any) {\n this.store.set(ROUTER_OPTIONS, value);\n }\n\n /**\n *\n * @returns {any[]}\n */\n get middlewares(): ControllerMiddlewares {\n return Object.assign(\n {\n use: [],\n useAfter: [],\n useBefore: []\n },\n this.store.get(\"middlewares\", {})\n );\n }\n\n /**\n *\n * @param middlewares\n */\n set middlewares(middlewares: ControllerMiddlewares) {\n const mdlwrs = this.middlewares;\n const concat = (key: string, a: any, b: any) => (a[key] = a[key].concat(b[key]));\n\n Object.keys(middlewares).forEach((key: string) => {\n concat(key, mdlwrs, middlewares);\n });\n this.store.set(\"middlewares\", mdlwrs);\n }\n}\n"]}
1
+ {"version":3,"file":"ControllerProvider.js","sourceRoot":"","sources":["../../../src/domain/ControllerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,QAAQ,EAAE,YAAY,EAAgB,MAAM,UAAU,CAAC;AACtF,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAE1D,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB,MAAM,OAAO,kBAA4B,SAAQ,QAAW;IACjD,WAAW,CAAS;IAE7B,YAAY,OAAsB,EAAE,UAA6B,EAAE;QACjE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,GAAG,IAAI,CAAC,IAAI,WAAW,QAAQ,EAAE,EAAE,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,IAAK,EAAU,CAAC;IACvD,CAAC;IAED;;;OAGG;IACH,IAAI,aAAa,CAAC,KAAU;QAC1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW;QACb,OAAO,MAAM,CAAC,MAAM,CAClB;YACE,GAAG,EAAE,EAAE;YACP,QAAQ,EAAE,EAAE;YACZ,SAAS,EAAE,EAAE;SACd,EACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,CAAC,CAClC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW,CAAC,WAAkC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;QAChC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEjF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;YAC/C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import {ControllerMiddlewares, Provider, ProviderType, TokenProvider} from \"@tsed/di\";\nimport {ROUTER_OPTIONS} from \"../constants/routerOptions\";\n\nlet AUTO_INC = 0;\n\nexport class ControllerProvider<T = any> extends Provider<T> {\n readonly tokenRouter: string;\n\n constructor(provide: TokenProvider, options: Partial<Provider> = {}) {\n super(provide, options);\n this.type = ProviderType.CONTROLLER;\n this.tokenRouter = `${this.name}_ROUTER_${AUTO_INC++}`;\n }\n\n /**\n *\n */\n get routerOptions(): any {\n return this.store.get(ROUTER_OPTIONS) || ({} as any);\n }\n\n /**\n *\n * @param value\n */\n set routerOptions(value: any) {\n this.store.set(ROUTER_OPTIONS, value);\n }\n\n /**\n *\n * @returns {any[]}\n */\n get middlewares(): ControllerMiddlewares {\n return Object.assign(\n {\n use: [],\n useAfter: [],\n useBefore: []\n },\n this.store.get(\"middlewares\", {})\n );\n }\n\n /**\n *\n * @param middlewares\n */\n set middlewares(middlewares: ControllerMiddlewares) {\n const mdlwrs = this.middlewares;\n const concat = (key: string, a: any, b: any) => (a[key] = a[key].concat(b[key]));\n\n Object.keys(middlewares).forEach((key: string) => {\n concat(key, mdlwrs, middlewares);\n });\n this.store.set(\"middlewares\", mdlwrs);\n }\n}\n"]}
@@ -4,10 +4,16 @@ import { ParamTypes } from "@tsed/platform-params";
4
4
  import { JsonParameterStore } from "@tsed/schema";
5
5
  import { HandlerType } from "../interfaces/HandlerType.js";
6
6
  export class HandlerMetadata {
7
+ target;
8
+ token;
9
+ propertyKey;
10
+ injectable = false;
11
+ type = HandlerType.RAW_FN;
12
+ hasNextFunction = false;
13
+ routeOptions;
14
+ scope;
15
+ handler;
7
16
  constructor(options) {
8
- this.injectable = false;
9
- this.type = HandlerType.RAW_FN;
10
- this.hasNextFunction = false;
11
17
  const { target, token, propertyKey, type, scope, routeOptions } = options;
12
18
  this.type = type || target.type || HandlerType.RAW_FN;
13
19
  this.scope = scope || ProviderScope.SINGLETON;
@@ -43,8 +49,7 @@ export class HandlerMetadata {
43
49
  return this.getParams().findIndex((p) => p.paramType === paramType) > -1;
44
50
  }
45
51
  isFinal() {
46
- var _a;
47
- return ((_a = this.routeOptions) === null || _a === void 0 ? void 0 : _a.isFinal) || false;
52
+ return this.routeOptions?.isFinal || false;
48
53
  }
49
54
  toString() {
50
55
  return [this.target && nameOf(this.target), this.propertyKey].filter(Boolean).join(".");
@@ -1 +1 @@
1
- {"version":3,"file":"HandlerMetadata.js","sourceRoot":"","sources":["../../../src/domain/HandlerMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAO,MAAM,YAAY,CAAC;AACxC,OAAO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AAG,CAAC,CAAC;SACvF;aAAM;YACL,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;SACxB;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBACxB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,UAAU,CAAC;aACpC;YACD,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;SAC5C;IACH,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,IAAI,KAAK,WAAW,CAAC,cAAc,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,CAAC,UAAU,CAAC;IAC1F,CAAC;IAEM,SAAS;QACd,OAAO,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IAC3E,CAAC;IAEM,YAAY,CAAC,SAAc;QAChC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3E,CAAC;IAEM,OAAO;;QACZ,OAAO,CAAA,MAAA,IAAI,CAAC,YAAY,0CAAE,OAAO,KAAI,KAAK,CAAC;IAC7C,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1F,CAAC;CACF","sourcesContent":["import {nameOf, Type} from \"@tsed/core\";\nimport {ProviderScope} from \"@tsed/di\";\nimport {ParamTypes} from \"@tsed/platform-params\";\nimport {JsonParameterStore} from \"@tsed/schema\";\nimport {HandlerType} from \"../interfaces/HandlerType\";\nimport {PlatformRouteOptions, PlatformRouteWithoutHandlers} from \"../interfaces/PlatformRouteOptions\";\n\nexport interface HandlerMetadataOptions {\n target: (Type<any> | Function) & {type?: HandlerType};\n routeOptions?: PlatformRouteWithoutHandlers;\n token?: Type<any>;\n propertyKey?: string | symbol;\n scope?: ProviderScope;\n type?: HandlerType;\n}\n\nexport class HandlerMetadata {\n readonly target: any;\n readonly token: Type<any>;\n readonly propertyKey: string | symbol;\n readonly injectable: boolean = false;\n readonly type: HandlerType = HandlerType.RAW_FN;\n readonly hasNextFunction: boolean = false;\n readonly routeOptions: Partial<PlatformRouteOptions>;\n readonly scope: ProviderScope;\n\n handler: any;\n\n constructor(options: HandlerMetadataOptions) {\n const {target, token, propertyKey, type, scope, routeOptions} = options;\n\n this.type = type || target.type || HandlerType.RAW_FN;\n this.scope = scope || ProviderScope.SINGLETON;\n this.routeOptions = routeOptions || {};\n const handler = propertyKey ? target.prototype[propertyKey] : target;\n\n if (propertyKey) {\n this.target = target;\n this.token = token!;\n this.propertyKey = propertyKey;\n this.hasNextFunction = this.hasParamType(ParamTypes.NEXT_FN);\n\n if (this.hasParamType(ParamTypes.ERR)) {\n this.type = HandlerType.ERR_MIDDLEWARE;\n }\n\n this.injectable = JsonParameterStore.getParams(target as any, propertyKey).length > 0;\n } else {\n this.handler = handler;\n }\n\n if (!this.injectable) {\n if (handler.length === 4) {\n this.type = HandlerType.RAW_ERR_FN;\n }\n this.hasNextFunction = handler.length >= 3;\n }\n }\n\n get hasErrorParam() {\n return this.type === HandlerType.ERR_MIDDLEWARE || this.type === HandlerType.RAW_ERR_FN;\n }\n\n public getParams() {\n return JsonParameterStore.getParams(this.target, this.propertyKey) || [];\n }\n\n public hasParamType(paramType: any): boolean {\n return this.getParams().findIndex((p) => p.paramType === paramType) > -1;\n }\n\n public isFinal() {\n return this.routeOptions?.isFinal || false;\n }\n\n toString() {\n return [this.target && nameOf(this.target), this.propertyKey].filter(Boolean).join(\".\");\n }\n}\n"]}
1
+ {"version":3,"file":"Handl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IAAI,CAAC,GAAG,CAAC,CAAC;IAC1F,CAAC;CACF","sourcesContent":["import {nameOf, Type} from \"@tsed/core\";\nimport {ProviderScope} from \"@tsed/di\";\nimport {ParamTypes} from \"@tsed/platform-params\";\nimport {JsonParameterStore} from \"@tsed/schema\";\nimport {HandlerType} from \"../interfaces/HandlerType\";\nimport {PlatformRouteOptions, PlatformRouteWithoutHandlers} from \"../interfaces/PlatformRouteOptions\";\n\nexport interface HandlerMetadataOptions {\n target: (Type<any> | Function) & {type?: HandlerType};\n routeOptions?: PlatformRouteWithoutHandlers;\n token?: Type<any>;\n propertyKey?: string | symbol;\n scope?: ProviderScope;\n type?: HandlerType;\n}\n\nexport class HandlerMetadata {\n readonly target: any;\n readonly token: Type<any>;\n readonly propertyKey: string | symbol;\n readonly injectable: boolean = false;\n readonly type: HandlerType = HandlerType.RAW_FN;\n readonly hasNextFunction: boolean = false;\n readonly routeOptions: Partial<PlatformRouteOptions>;\n readonly scope: ProviderScope;\n\n handler: any;\n\n constructor(options: HandlerMetadataOptions) {\n const {target, token, propertyKey, type, scope, routeOptions} = options;\n\n this.type = type || target.type || HandlerType.RAW_FN;\n this.scope = scope || ProviderScope.SINGLETON;\n this.routeOptions = routeOptions || {};\n const handler = propertyKey ? target.prototype[propertyKey] : target;\n\n if (propertyKey) {\n this.target = target;\n this.token = token!;\n this.propertyKey = propertyKey;\n this.hasNextFunction = this.hasParamType(ParamTypes.NEXT_FN);\n\n if (this.hasParamType(ParamTypes.ERR)) {\n this.type = HandlerType.ERR_MIDDLEWARE;\n }\n\n this.injectable = JsonParameterStore.getParams(target as any, propertyKey).length > 0;\n } else {\n this.handler = handler;\n }\n\n if (!this.injectable) {\n if (handler.length === 4) {\n this.type = HandlerType.RAW_ERR_FN;\n }\n this.hasNextFunction = handler.length >= 3;\n }\n }\n\n get hasErrorParam() {\n return this.type === HandlerType.ERR_MIDDLEWARE || this.type === HandlerType.RAW_ERR_FN;\n }\n\n public getParams() {\n return JsonParameterStore.getParams(this.target, this.propertyKey) || [];\n }\n\n public hasParamType(paramType: any): boolean {\n return this.getParams().findIndex((p) => p.paramType === paramType) > -1;\n }\n\n public isFinal() {\n return this.routeOptions?.isFinal || false;\n }\n\n toString() {\n return [this.target && nameOf(this.target), this.propertyKey].filter(Boolean).join(\".\");\n }\n}\n"]}
@@ -1,30 +1,50 @@
1
1
  import { DIContext } from "@tsed/di";
2
+ import { EndpointMetadata } from "@tsed/schema";
2
3
  import { PlatformApplication } from "../services/PlatformApplication.js";
3
4
  import { PlatformRequest } from "../services/PlatformRequest.js";
4
5
  import { PlatformResponse } from "../services/PlatformResponse.js";
5
6
  export class PlatformContext extends DIContext {
6
- constructor({ event, endpoint, ignoreUrlPatterns = [], ResponseKlass = PlatformResponse, RequestKlass = PlatformRequest, ...options }) {
7
- super({
8
- ...options,
9
- ignoreLog: () => {
10
- return this.ignoreUrlPatterns.find((reg) => !!this.url.match(reg));
11
- }
12
- });
13
- this.ignoreUrlPatterns = [];
14
- endpoint && (this.endpoint = endpoint);
15
- this.ignoreUrlPatterns = ignoreUrlPatterns.map((pattern) => typeof pattern === "string" ? new RegExp(pattern, "gi") : pattern);
16
- this.response = new ResponseKlass(event, this);
17
- this.request = new RequestKlass(event, this);
18
- this.response.request = this.request;
19
- this.request.response = this.response;
7
+ event;
8
+ /**
9
+ * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.
10
+ */
11
+ data;
12
+ /**
13
+ * The error caught by the current handler
14
+ */
15
+ error;
16
+ /**
17
+ * The current @@PlatformResponse@@.
18
+ */
19
+ response;
20
+ /**
21
+ * The current @@PlatformRequest@@.
22
+ */
23
+ request;
24
+ ignoreUrlPatterns = [];
25
+ #isDestroyed = false;
26
+ constructor(options) {
27
+ super(options);
28
+ options.endpoint && (this.endpoint = options.endpoint);
29
+ this.event = options.event;
30
+ this.response = new (options.ResponseKlass || PlatformResponse)(this);
31
+ this.request = new (options.RequestKlass || PlatformRequest)(this);
20
32
  this.request.request.$ctx = this;
21
33
  this.request.request.id = this.id;
22
- this.logger.url = this.url;
23
34
  this.container.set(PlatformResponse, this.response);
24
35
  this.container.set(PlatformRequest, this.request);
25
36
  this.container.set(PlatformContext, this);
26
37
  this.response.setHeader("x-request-id", this.id);
27
38
  }
39
+ /**
40
+ * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
41
+ */
42
+ get endpoint() {
43
+ return this.get(EndpointMetadata);
44
+ }
45
+ set endpoint(endpoint) {
46
+ this.set(EndpointMetadata, endpoint);
47
+ }
28
48
  get url() {
29
49
  return this.request.url;
30
50
  }
@@ -32,27 +52,27 @@ export class PlatformContext extends DIContext {
32
52
  return this.injector.get(PlatformApplication);
33
53
  }
34
54
  async destroy() {
35
- var _a, _b;
36
55
  await super.destroy();
37
- (_b = (_a = this.request) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? true : delete _b.$ctx;
56
+ this.upgrade({
57
+ response: {
58
+ isDone: true,
59
+ statusCode: this.statusCode
60
+ },
61
+ request: {
62
+ method: this.method,
63
+ url: this.url,
64
+ headers: this.headers,
65
+ body: this.body,
66
+ query: this.query,
67
+ params: this.params
68
+ }
69
+ });
38
70
  this.response.destroy();
39
71
  this.request.destroy();
40
- // @ts-ignore
41
- delete this.endpoint;
42
- // @ts-ignore
43
- delete this.response;
44
- // @ts-ignore
45
- delete this.request;
72
+ this.#isDestroyed = true;
46
73
  }
47
74
  isDone() {
48
- var _a, _b;
49
- if (!this.request || !this.response) {
50
- return true;
51
- }
52
- if ((_a = this.request) === null || _a === void 0 ? void 0 : _a.isAborted()) {
53
- return true;
54
- }
55
- return (_b = this.response) === null || _b === void 0 ? void 0 : _b.isDone();
75
+ return this.request?.isAborted() || this.response?.isDone() || this.#isDestroyed;
56
76
  }
57
77
  /**
58
78
  * Return the framework request instance (Express, Koa, etc...)
@@ -84,5 +104,8 @@ export class PlatformContext extends DIContext {
84
104
  getApp() {
85
105
  return this.app.getApp();
86
106
  }
107
+ upgrade(event) {
108
+ this.event = event;
109
+ }
87
110
  }
88
111
  //# sourceMappingURL=PlatformContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAmB,MAAM,UAAU,CAAC;AAGrE,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAiB9D,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAoB5C,YAAY,EACV,KAAK,EACL,QAAQ,EACR,iBAAiB,GAAG,EAAE,EACtB,aAAa,GAAG,gBAAgB,EAChC,YAAY,GAAG,eAAe,EAC9B,GAAG,OAAO,EACa;QACvB,KAAK,CAAC;YACJ,GAAG,OAAO;YACV,SAAS,EAAE,GAAG,EAAE;gBACd,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;YACrE,CAAC;SACF,CAAC,CAAC;QAfG,sBAAiB,GAAa,EAAE,CAAC;QAiBvC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;QAEvC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,OAAwB,EAAE,EAAE,CAC1E,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAClE,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC,KAAK,EAAE,IA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AAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,MAAM;;QACJ,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACnC,OAAO,IAAI,CAAC;SACb;QAED,IAAI,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,EAAE,EAAE;YAC7B,OAAO,IAAI,CAAC;SACb;QAED,OAAO,MAAA,IAAI,CAAC,QAAQ,0CAAE,MAAM,EAAE,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAO,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAO,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAS,CAAC;IAClC,CAAC;CACF","sourcesContent":["import {ContextMethods, DIContext, DIContextOptions} from \"@tsed/di\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\ndeclare global {\n namespace TsED {\n export interface Context extends PlatformContext {}\n }\n}\n\nexport interface PlatformContextOptions extends DIContextOptions {\n event: {\n response?: ServerResponse;\n request?: IncomingMessage;\n };\n ignoreUrlPatterns?: any[];\n endpoint?: EndpointMetadata;\n}\n\nexport class PlatformContext extends DIContext implements ContextMethods {\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n public endpoint: EndpointMetadata;\n /**\n * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n */\n public data: any;\n /**\n * The current @@PlatformResponse@@.\n */\n public response: PlatformResponse;\n /**\n * The current @@PlatformRequest@@.\n */\n public request: PlatformRequest;\n\n private ignoreUrlPatterns: RegExp[] = [];\n\n constructor({\n event,\n endpoint,\n ignoreUrlPatterns = [],\n ResponseKlass = PlatformResponse,\n RequestKlass = PlatformRequest,\n ...options\n }: PlatformContextOptions) {\n super({\n ...options,\n ignoreLog: () => {\n return this.ignoreUrlPatterns.find((reg) => !!this.url.match(reg));\n }\n });\n\n endpoint && (this.endpoint = endpoint);\n\n this.ignoreUrlPatterns = ignoreUrlPatterns.map((pattern: string | RegExp) =>\n typeof pattern === \"string\" ? new RegExp(pattern, \"gi\") : pattern\n );\n\n this.response = new ResponseKlass(event, this);\n this.request = new RequestKlass(event, this);\n\n this.response.request = this.request;\n this.request.response = this.response;\n\n this.request.request.$ctx = this;\n this.request.request.id = this.id;\n this.logger.url = this.url;\n\n this.container.set(PlatformResponse, this.response);\n this.container.set(PlatformRequest, this.request);\n this.container.set(PlatformContext, this);\n\n this.response.setHeader(\"x-request-id\", this.id);\n }\n\n get url() {\n return this.request.url;\n }\n\n get app() {\n return this.injector.get<PlatformApplication>(PlatformApplication)!;\n }\n\n async destroy() {\n await super.destroy();\n\n delete this.request?.request?.$ctx;\n\n this.response.destroy();\n this.request.destroy();\n\n // @ts-ignore\n delete this.endpoint;\n // @ts-ignore\n delete this.response;\n // @ts-ignore\n delete this.request;\n }\n\n isDone() {\n if (!this.request || !this.response) {\n return true;\n }\n\n if (this.request?.isAborted()) {\n return true;\n }\n\n return this.response?.isDone();\n }\n\n /**\n * Return the framework request instance (Express, Koa, etc...)\n */\n getRequest<Req = any>(): Req {\n return this.request.getRequest<Req>();\n }\n\n /**\n * Return the framework response instance (Express, Koa, etc...)\n */\n getResponse<Res = any>(): Res {\n return this.response.getResponse<Res>();\n }\n\n /**\n * Get Node.js request\n */\n getReq(): IncomingMessage {\n return this.request.getReq();\n }\n\n /**\n * Get Node.js response\n */\n getRes(): ServerResponse {\n return this.response.getRes();\n }\n\n /**\n * Return the original application instance.\n */\n getApp<T = any>(): T {\n return this.app.getApp() as any;\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAmB,MAAM,UAAU,CAAC;AACrE,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAG9C,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAc9D,MAAM,OAAO,eACX,SAAQ,SAAS;IAGV,KAAK,CAAgB;IAC5B;;OAEG;IACI,IAAI,CAAM;IACjB;;OAEG;IACI,KAAK,CAAW;IACvB;;OAEG;IACM,QAAQ,CAAO;IACxB;;OAEG;IACM,OAAO,CAAO;IAEf,iBAAiB,GAAa,EAAE,CAAC;IACzC,YAAY,GAAY,KAAK,CAAC;IAE9B,YAAY,OAA+B;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEvD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC;QACtE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC;QAEnE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,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SACK,CAAC,CAAC;QAEV,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC;IACnF,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAO,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAO,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAS,CAAC;IAClC,CAAC;IAED,OAAO,CAAC,KAAoB;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF","sourcesContent":["import {ContextMethods, DIContext, DIContextOptions} from \"@tsed/di\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {IncomingEvent} from \"../interfaces/IncomingEvent\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\ndeclare global {\n namespace TsED {\n export interface Context extends PlatformContext {}\n }\n}\n\nexport interface PlatformContextOptions extends DIContextOptions {\n event: IncomingEvent;\n ignoreUrlPatterns?: any[];\n endpoint?: EndpointMetadata;\n}\n\nexport class PlatformContext<PReq extends PlatformRequest = PlatformRequest, PRes extends PlatformResponse = PlatformResponse>\n extends DIContext\n implements ContextMethods\n{\n public event: IncomingEvent;\n /**\n * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n */\n public data: any;\n /**\n * The error caught by the current handler\n */\n public error?: unknown;\n /**\n * The current @@PlatformResponse@@.\n */\n readonly response: PRes;\n /**\n * The current @@PlatformRequest@@.\n */\n readonly request: PReq;\n\n private ignoreUrlPatterns: RegExp[] = [];\n #isDestroyed: boolean = false;\n\n constructor(options: PlatformContextOptions) {\n super(options);\n\n options.endpoint && (this.endpoint = options.endpoint);\n\n this.event = options.event;\n this.response = new (options.ResponseKlass || PlatformResponse)(this);\n this.request = new (options.RequestKlass || PlatformRequest)(this);\n\n this.request.request.$ctx = this;\n this.request.request.id = this.id;\n this.container.set(PlatformResponse, this.response);\n this.container.set(PlatformRequest, this.request);\n this.container.set(PlatformContext, this);\n\n this.response.setHeader(\"x-request-id\", this.id);\n }\n\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n get endpoint(): EndpointMetadata {\n return this.get(EndpointMetadata);\n }\n\n set endpoint(endpoint: EndpointMetadata) {\n this.set(EndpointMetadata, endpoint);\n }\n\n get url() {\n return this.request.url;\n }\n\n get app() {\n return this.injector.get<PlatformApplication>(PlatformApplication)!;\n }\n\n async destroy() {\n await super.destroy();\n\n this.upgrade({\n response: {\n isDone: true,\n statusCode: this.statusCode\n },\n request: {\n method: this.method,\n url: this.url,\n headers: this.headers,\n body: this.body,\n query: this.query,\n params: this.params\n }\n } as any);\n\n this.response.destroy();\n this.request.destroy();\n this.#isDestroyed = true;\n }\n\n isDone() {\n return this.request?.isAborted() || this.response?.isDone() || this.#isDestroyed;\n }\n\n /**\n * Return the framework request instance (Express, Koa, etc...)\n */\n getRequest<Req = any>(): Req {\n return this.request.getRequest<Req>();\n }\n\n /**\n * Return the framework response instance (Express, Koa, etc...)\n */\n getResponse<Res = any>(): Res {\n return this.response.getResponse<Res>();\n }\n\n /**\n * Get Node.js request\n */\n getReq(): IncomingMessage {\n return this.request.getReq();\n }\n\n /**\n * Get Node.js response\n */\n getRes(): ServerResponse {\n return this.response.getRes();\n }\n\n /**\n * Return the original application instance.\n */\n getApp<T = any>(): T {\n return this.app.getApp() as any;\n }\n\n upgrade(event: IncomingEvent) {\n this.event = event;\n }\n}\n"]}
@@ -1,9 +1,13 @@
1
1
  import { ParamTypes } from "@tsed/platform-params";
2
2
  import { JsonOperationRoute } from "@tsed/schema";
3
3
  export class PlatformRouteDetails extends JsonOperationRoute {
4
- constructor(options = {}) {
4
+ rawBody;
5
+ provider;
6
+ constructor(options) {
5
7
  super(options);
6
8
  this.rawBody = !!this.endpoint.parameters.find((param) => param.paramType === ParamTypes.RAW_BODY);
9
+ // TMP FIX
10
+ this.endpoint.set("route", this.url);
7
11
  }
8
12
  toJSON() {
9
13
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformRouteDetails.js","sourceRoot":"","sources":["../../../src/domain/PlatformRouteDetails.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAmB,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAUlE,MAAM,OAAO,oBAAqB,SAAQ,kBAAoC;IAI5E,YAAY,UAAyC,EAAE;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrG,CAAC;IAED,MAAM;QACJ,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {ParamTypes} from \"@tsed/platform-params\";\nimport {EndpointMetadata, JsonOperationRoute} from \"@tsed/schema\";\nimport {ControllerProvider} from \"./ControllerProvider\";\n\nexport interface PlatformRouterDetailsOptions {\n provider: ControllerProvider;\n endpoint: EndpointMetadata;\n method: string;\n url: string;\n}\n\nexport class PlatformRouteDetails extends JsonOperationRoute<EndpointMetadata> {\n readonly rawBody: boolean;\n readonly provider: ControllerProvider;\n\n constructor(options: Partial<PlatformRouteDetails> = {}) {\n super(options);\n this.rawBody = !!this.endpoint.parameters.find((param) => param.paramType === ParamTypes.RAW_BODY);\n }\n\n toJSON() {\n return {\n method: this.method,\n name: this.name,\n url: this.url,\n className: this.className,\n methodClassName: this.methodClassName,\n parameters: this.parameters,\n rawBody: this.rawBody\n };\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformRouteDetails.js","sourceRoot":"","sources":["../../../src/domain/PlatformRouteDetails.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAmB,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAGlE,MAAM,OAAO,oBAAqB,SAAQ,kBAAoC;IACnE,OAAO,CAAU;IACjB,QAAQ,CAAqB;IAEtC,YAAY,OAAsC;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC;QAEnG,UAAU;QACV,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,MAAM;QACJ,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {ParamTypes} from \"@tsed/platform-params\";\nimport {EndpointMetadata, JsonOperationRoute} from \"@tsed/schema\";\nimport {ControllerProvider} from \"./ControllerProvider\";\n\nexport class PlatformRouteDetails extends JsonOperationRoute<EndpointMetadata> {\n readonly rawBody: boolean;\n readonly provider: ControllerProvider;\n\n constructor(options: Partial<PlatformRouteDetails>) {\n super(options);\n this.rawBody = !!this.endpoint.parameters.find((param) => param.paramType === ParamTypes.RAW_BODY);\n\n // TMP FIX\n this.endpoint.set(\"route\", this.url);\n }\n\n toJSON() {\n return {\n method: this.method,\n name: this.name,\n url: this.url,\n className: this.className,\n methodClassName: this.methodClassName,\n parameters: this.parameters,\n rawBody: this.rawBody\n };\n }\n}\n"]}
@@ -9,9 +9,10 @@ import { Context } from "@tsed/platform-params";
9
9
  * @platform
10
10
  */
11
11
  let PlatformAcceptMimesMiddleware = class PlatformAcceptMimesMiddleware {
12
+ acceptMimes;
12
13
  use(ctx) {
13
14
  const { endpoint, request } = ctx;
14
- const mimes = uniq(((endpoint === null || endpoint === void 0 ? void 0 : endpoint.get("acceptMimes")) || []).concat(this.acceptMimes));
15
+ const mimes = uniq((endpoint?.get("acceptMimes") || []).concat(this.acceptMimes));
15
16
  if (mimes.length && !request.accepts(mimes)) {
16
17
  throw new NotAcceptable(mimes.join(", "));
17
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformAcceptMimesMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformAcceptMimesMiddleware.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAChC,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAC;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,UAAU,EAAoB,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAE9C;;;GAGG;AAEH,IAAa,6BAA6B,GAA1C,MAAa,6BAA6B;IAIjC,GAAG,CAAY,GAAY;QAChC,MAAM,EAAC,QAAQ,EAAE,OAAO,EAAC,GAAG,GAAG,CAAC;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,CAAC,aAAa,CAAC,KAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAElF,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC3C,MAAM,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3C;IACH,CAAC;CACF,CAAA;AAVC;IADC,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;;kEACN;AAEtB;IAAY,WAAA,OAAO,EAAE,CAAA;;;;wDAOpB;AAXU,6BAA6B;IADzC,UAAU,EAAE;GACA,6BAA6B,CAYzC;SAZY,6BAA6B","sourcesContent":["import {uniq} from \"@tsed/core\";\nimport {Constant} from \"@tsed/di\";\nimport {NotAcceptable} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\n\n/**\n * @middleware\n * @platform\n */\n@Middleware()\nexport class PlatformAcceptMimesMiddleware implements MiddlewareMethods {\n @Constant(\"acceptMimes\", [])\n acceptMimes: string[];\n\n public use(@Context() ctx: Context): void {\n const {endpoint, request} = ctx;\n const mimes = uniq((endpoint?.get(\"acceptMimes\") || []).concat(this.acceptMimes));\n\n if (mimes.length && !request.accepts(mimes)) {\n throw new NotAcceptable(mimes.join(\", \"));\n }\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformAcceptMimesMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformAcceptMimesMiddleware.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAChC,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAC;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,UAAU,EAAoB,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAE9C;;;GAGG;AAEH,IAAa,6BAA6B,GAA1C,MAAa,6BAA6B;IAExC,WAAW,CAAW;IAEf,GAAG,CAAY,GAAY;QAChC,MAAM,EAAC,QAAQ,EAAE,OAAO,EAAC,GAAG,GAAG,CAAC;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAElF,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC3C,MAAM,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3C;IACH,CAAC;CACF,CAAA;AAVC;IADC,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;;kEACN;AAEtB;IAAY,WAAA,OAAO,EAAE,CAAA;;;;wDAOpB;AAXU,6BAA6B;IADzC,UAAU,EAAE;GACA,6BAA6B,CAYzC;SAZY,6BAA6B","sourcesContent":["import {uniq} from \"@tsed/core\";\nimport {Constant} from \"@tsed/di\";\nimport {NotAcceptable} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\n\n/**\n * @middleware\n * @platform\n */\n@Middleware()\nexport class PlatformAcceptMimesMiddleware implements MiddlewareMethods {\n @Constant(\"acceptMimes\", [])\n acceptMimes: string[];\n\n public use(@Context() ctx: Context): void {\n const {endpoint, request} = ctx;\n const mimes = uniq((endpoint?.get(\"acceptMimes\") || []).concat(this.acceptMimes));\n\n if (mimes.length && !request.accepts(mimes)) {\n throw new NotAcceptable(mimes.join(\", \"));\n }\n }\n}\n"]}
@@ -16,6 +16,8 @@ export class MulterException extends BadRequest {
16
16
  * @middleware
17
17
  */
18
18
  let PlatformMulterMiddleware = PlatformMulterMiddleware_1 = class PlatformMulterMiddleware {
19
+ settings;
20
+ app;
19
21
  async use(ctx) {
20
22
  try {
21
23
  const { fields, options = {} } = ctx.endpoint.get(PlatformMulterMiddleware_1);
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";;AACA,OAAO,EAAW,MAAM,EAAE,KAAK,EAAC,MAAM,UAAU,CAAC;AACjD,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAoB,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAE9C,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAOpE,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C,YAAY,EAAe;QACzB,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,EAAE,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9BU,wBAAwB;IADpC,UAAU,EAAE;GACA,wBAAwB,CAmCpC;SAnCY,wBAAwB","sourcesContent":["import type {MulterError} from \"multer\";\nimport {Constant, Inject, Value} from \"@tsed/di\";\nimport {BadRequest} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\nimport {PlatformMulterField, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformConfiguration} from \"../config/services/PlatformConfiguration\";\n\nexport interface MulterInputOptions {\n fields: PlatformMulterField[];\n}\n\nexport class MulterException extends BadRequest {\n constructor(er: MulterError) {\n super(er.message);\n this.origin = er;\n this.name = er.code;\n }\n}\n\n/**\n * @middleware\n */\n@Middleware()\nexport class PlatformMulterMiddleware implements MiddlewareMethods {\n @Value(\"multer\", {}) // NOTE: don't use constant to getting multer configuration. See issue #1840\n protected settings: PlatformMulterSettings;\n\n @Inject()\n protected app: PlatformApplication;\n\n async use(@Context() ctx: Context) {\n try {\n const {fields, options = {}} = ctx.endpoint.get(PlatformMulterMiddleware);\n const settings: PlatformMulterSettings = {\n ...this.settings,\n ...options\n };\n\n /* istanbul ignore next */\n if (settings.storage) {\n delete settings.dest;\n }\n\n const middleware: any = this.app.multer(settings).fields(this.getFields({fields}));\n\n return await middleware(ctx.getRequest(), ctx.getResponse());\n } catch (er) {\n if (er.code) {\n throw new MulterException(er);\n }\n\n throw er;\n }\n }\n\n protected getFields(conf: MulterInputOptions) {\n return conf.fields.map(({name, maxCount}) => ({name, maxCount}));\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";;AACA,OAAO,EAAW,MAAM,EAAE,KAAK,EAAC,MAAM,UAAU,CAAC;AACjD,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C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IAES,SAAS,CAAC,IAAwB;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AAjCC;IADC,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,4EAA4E;;;0DACtD;AAG3C;IADC,MAAM,EAAE;8BACM,mBAAmB;qDAAC;AAEnC;IAAW,WAAA,OAAO,EAAE,CAAA;;;;mDAuBnB;AA9BU,wBAAwB;IADpC,UAAU,EAAE;GACA,wBAAwB,CAmCpC;SAnCY,wBAAwB","sourcesContent":["import type {MulterError} from \"multer\";\nimport {Constant, Inject, Value} from \"@tsed/di\";\nimport {BadRequest} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\nimport {PlatformMulterField, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\n\nexport interface MulterInputOptions {\n fields: PlatformMulterField[];\n}\n\nexport class MulterException extends BadRequest {\n constructor(er: MulterError) {\n super(er.message);\n this.origin = er;\n this.name = er.code;\n }\n}\n\n/**\n * @middleware\n */\n@Middleware()\nexport class PlatformMulterMiddleware implements MiddlewareMethods {\n @Value(\"multer\", {}) // NOTE: don't use constant to getting multer configuration. See issue #1840\n protected settings: PlatformMulterSettings;\n\n @Inject()\n protected app: PlatformApplication;\n\n async use(@Context() ctx: Context) {\n try {\n const {fields, options = {}} = ctx.endpoint.get(PlatformMulterMiddleware);\n const settings: PlatformMulterSettings = {\n ...this.settings,\n ...options\n };\n\n /* istanbul ignore next */\n if (settings.storage) {\n delete settings.dest;\n }\n\n const middleware: any = this.app.multer(settings).fields(this.getFields({fields}));\n\n return await middleware(ctx.getRequest(), ctx.getResponse());\n } catch (er) {\n if (er.code) {\n throw new MulterException(er);\n }\n\n throw er;\n }\n }\n\n protected getFields(conf: MulterInputOptions) {\n return conf.fields.map(({name, maxCount}) => ({name, maxCount}));\n }\n}\n"]}
@@ -1,7 +1,5 @@
1
1
  export class FakeAdapter {
2
- constructor() {
3
- this.providers = [];
4
- }
2
+ providers = [];
5
3
  static createFakeRawDriver() {
6
4
  // istanbul ignore next
7
5
  function FakeRawDriver() { }
@@ -1 +1 @@
1
- {"version":3,"file":"FakeAdapter.js","sourceRoot":"","sources":["../../../src/services/FakeAdapter.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,WAAW;IAAxB;QACE,cAAS,GAAmB,EAAE,CAAC;IAuDjC,CAAC;IArDC,MAAM,CAAC,mBAAmB;QACxB,uBAAuB;QACvB,SAAS,aAAa,KAAI,CAAC;QAE3B,uBAAuB;QACvB,SAAS,GAAG;YACV,OAAO,IAAI,CAAC;QACd,CAAC;QAED,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,KAAK,GAAG,GAAG,CAAC;QAC1B,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;QACzB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;QACzB,aAAa,CAAC,MAAM,GAAG,GAAG,CAAC;QAC3B,aAAa,CAAC,OAAO,GAAG,GAAG,CAAC;QAE5B,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,GAAG;QACD,MAAM,GAAG,GAAG,WAAW,CAAC,mBAAmB,EAAE,CAAC;QAC9C,OAAO;YACL,GAAG;YACH,QAAQ;gBACN,OAAO,GAAG,CAAC;YACb,CAAC;SACF,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,OAA+B;QACvC,OAAO,EAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,aAAkB;QACvB,MAAM,MAAM,GAAG,WAAW,CAAC,mBAAmB,EAAE,CAAC;QACjD,OAAO;YACL,MAAM;YACN,QAAQ;gBACN,OAAO,MAAM,CAAC;YAChB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,OAA+B;QACvD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC;CACF","sourcesContent":["import {ProviderOpts} from \"@tsed/di\";\nimport {PlatformAdapter} from \"./PlatformAdapter\";\nimport {PlatformMulter, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformStaticsOptions} from \"../config/interfaces/PlatformStaticsSettings\";\n\nexport class FakeAdapter implements PlatformAdapter<any, any> {\n providers: ProviderOpts[] = [];\n\n static createFakeRawDriver() {\n // istanbul ignore next\n function FakeRawDriver() {}\n\n // istanbul ignore next\n function use() {\n return this;\n }\n\n FakeRawDriver.use = use;\n FakeRawDriver.all = use;\n FakeRawDriver.get = use;\n FakeRawDriver.patch = use;\n FakeRawDriver.post = use;\n FakeRawDriver.put = use;\n FakeRawDriver.head = use;\n FakeRawDriver.delete = use;\n FakeRawDriver.options = use;\n\n return FakeRawDriver;\n }\n\n app(): {app: any; callback(): any} {\n const app = FakeAdapter.createFakeRawDriver();\n return {\n app,\n callback() {\n return app;\n }\n };\n }\n\n multipart(options: PlatformMulterSettings): PlatformMulter {\n return {} as any;\n }\n\n router(routerOptions: any): {router: any; callback(): any} {\n const router = FakeAdapter.createFakeRawDriver();\n return {\n router,\n callback() {\n return router;\n }\n };\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions): any {\n return {};\n }\n\n bodyParser(type: string): any {\n return () => {};\n }\n}\n"]}
1
+ {"version":3,"file":"FakeAdapter.js","sourceRoot":"","sources":["../../../src/services/FakeAdapter.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,WAAW;IACtB,SAAS,GAAmB,EAAE,CAAC;IAE/B,MAAM,CAAC,mBAAmB;QACxB,uBAAuB;QACvB,SAAS,aAAa,KAAI,CAAC;QAE3B,uBAAuB;QACvB,SAAS,GAAG;YACV,OAAO,IAAI,CAAC;QACd,CAAC;QAED,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,KAAK,GAAG,GAAG,CAAC;QAC1B,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;QACzB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;QACzB,aAAa,CAAC,MAAM,GAAG,GAAG,CAAC;QAC3B,aAAa,CAAC,OAAO,GAAG,GAAG,CAAC;QAE5B,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,GAAG;QACD,MAAM,GAAG,GAAG,WAAW,CAAC,mBAAmB,EAAE,CAAC;QAC9C,OAAO;YACL,GAAG;YACH,QAAQ;gBACN,OAAO,GAAG,CAAC;YACb,CAAC;SACF,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,OAA+B;QACvC,OAAO,EAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,aAAkB;QACvB,MAAM,MAAM,GAAG,WAAW,CAAC,mBAAmB,EAAE,CAAC;QACjD,OAAO;YACL,MAAM;YACN,QAAQ;gBACN,OAAO,MAAM,CAAC;YAChB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,OAA+B;QACvD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC;CACF","sourcesContent":["import {ProviderOpts} from \"@tsed/di\";\nimport {PlatformAdapter} from \"./PlatformAdapter\";\nimport {PlatformMulter, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformStaticsOptions} from \"../config/interfaces/PlatformStaticsSettings\";\n\nexport class FakeAdapter implements PlatformAdapter<any, any> {\n providers: ProviderOpts[] = [];\n\n static createFakeRawDriver() {\n // istanbul ignore next\n function FakeRawDriver() {}\n\n // istanbul ignore next\n function use() {\n return this;\n }\n\n FakeRawDriver.use = use;\n FakeRawDriver.all = use;\n FakeRawDriver.get = use;\n FakeRawDriver.patch = use;\n FakeRawDriver.post = use;\n FakeRawDriver.put = use;\n FakeRawDriver.head = use;\n FakeRawDriver.delete = use;\n FakeRawDriver.options = use;\n\n return FakeRawDriver;\n }\n\n app(): {app: any; callback(): any} {\n const app = FakeAdapter.createFakeRawDriver();\n return {\n app,\n callback() {\n return app;\n }\n };\n }\n\n multipart(options: PlatformMulterSettings): PlatformMulter {\n return {} as any;\n }\n\n router(routerOptions: any): {router: any; callback(): any} {\n const router = FakeAdapter.createFakeRawDriver();\n return {\n router,\n callback() {\n return router;\n }\n };\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions): any {\n return {};\n }\n\n bodyParser(type: string): any {\n return () => {};\n }\n}\n"]}
@@ -11,11 +11,13 @@ import { PlatformMiddlewaresChain } from "./PlatformMiddlewaresChain.js";
11
11
  * @platform
12
12
  */
13
13
  let Platform = class Platform {
14
+ injector;
15
+ platformApplication;
16
+ _routes = [];
17
+ _controllers = [];
14
18
  constructor(injector, platformApplication) {
15
19
  this.injector = injector;
16
20
  this.platformApplication = platformApplication;
17
- this._routes = [];
18
- this._controllers = [];
19
21
  this.createRouters();
20
22
  }
21
23
  get app() {
@@ -1 +1 @@
1
- {"version":3,"file":"Platform.js","sourceRoot":"","sources":["../../../src/services/Platform.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAgB,MAAM,UAAU,CAAC;AACjG,OAAO,EAAC,UAAU,EAAoB,kBAAkB,EAAE,mBAAmB,EAAE,eAAe,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HY,QAAQ;IAJpB,UAAU,CAAC;QACV,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,OAAO,EAAE,CAAC,wBAAwB,CAAC;KACpC,CAAC;qCAK+B,eAAe,EAAgC,mBAAmB;GAJtF,QAAQ,CA2HpB;SA3HY,QAAQ","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {Injectable, InjectorService, ProviderScope, ProviderType, TokenProvider} from \"@tsed/di\";\nimport {concatPath, EndpointMetadata, getJsonEntityStore, getOperationsRoutes, JsonEntityStore} from \"@tsed/schema\";\nimport {buildRouter, createRouter, getRouter} from \"../builder/PlatformControllerBuilder\";\nimport {ControllerProvider} from \"../domain/ControllerProvider\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\nimport {Route, RouteController} from \"../interfaces/Route\";\nimport {PlatformApplication} from \"./PlatformApplication\";\nimport {PlatformMiddlewaresChain} from \"./PlatformMiddlewaresChain\";\n\n/**\n * `Platform` is used to provide all routes collected by annotation `@Controller`.\n *\n * @platform\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n imports: [PlatformMiddlewaresChain]\n})\nexport class Platform {\n private _routes: PlatformRouteDetails[] = [];\n private _controllers: RouteController[] = [];\n\n constructor(readonly injector: InjectorService, readonly platformApplication: PlatformApplication) {\n this.createRouters();\n }\n\n get app() {\n return this.platformApplication;\n }\n\n get routes(): PlatformRouteDetails[] {\n return this._routes;\n }\n\n public addRoutes(routes: Route[]) {\n routes.forEach((routeSettings) => {\n this.addRoute(routeSettings.route, routeSettings.token);\n });\n }\n\n public addRoute(basePath: string, token: TokenProvider) {\n const {injector} = this;\n const provider = injector.getProvider(token) as ControllerProvider;\n\n if (!provider || provider.hasParent()) {\n return;\n }\n\n this._controllers.push(...this.getAllControllers(basePath, token));\n\n const ctrlPath = concatPath(basePath, JsonEntityStore.from(provider.token).path);\n\n this.app.use(ctrlPath, ...[].concat(getRouter(injector, provider).callback()));\n\n this._routes = getOperationsRoutes<EndpointMetadata>(provider.token, {\n withChildren: true,\n basePath\n }).reduce((routes, operationRoute) => {\n if (injector.hasProvider(token)) {\n const provider = injector.getProvider(operationRoute.token) as ControllerProvider;\n const route = new PlatformRouteDetails({\n ...operationRoute,\n provider\n });\n\n routes = routes.concat(route);\n }\n\n return routes;\n }, this._routes);\n\n return this;\n }\n\n /**\n * Get all routes built by TsExpressDecorators and mounted on Express application.\n * @returns {PlatformRouteDetails[]}\n */\n public getRoutes(): PlatformRouteDetails[] {\n return this._routes;\n }\n\n /**\n * Get all controllers mounted on the application.\n * @returns {RouteController[]}\n */\n public getMountedControllers(): RouteController[] {\n return this._controllers;\n }\n\n protected $onInit() {\n this.buildControllers();\n }\n\n /**\n * Create routers from the collected controllers.\n * @private\n */\n private createRouters() {\n const {injector} = this;\n\n injector.getProviders(ProviderType.CONTROLLER).map((provider: ControllerProvider) => {\n createRouter(injector, provider);\n });\n }\n\n /**\n * Get all router controllers from the controller token.\n * @private\n */\n private getAllControllers(basePath: string, token: Type<any> | any): RouteController[] {\n const store: JsonEntityStore = token.isStore ? token : getJsonEntityStore(token);\n const ctrlPath = concatPath(basePath, JsonEntityStore.from(token).path);\n const children = store.get<Type[]>(\"childrenControllers\", []);\n\n return children\n .reduce<RouteController[]>((controllers, token) => {\n const childBasePath = concatPath(basePath, store.path);\n return controllers.concat(this.getAllControllers(childBasePath, token));\n }, [])\n .concat([\n {\n route: ctrlPath,\n provider: this.injector.getProvider(token) as ControllerProvider\n }\n ]);\n }\n\n /**\n * Create controllers from DI\n * @private\n */\n private buildControllers() {\n const {injector} = this;\n\n injector.getProviders(ProviderType.CONTROLLER).map((provider: ControllerProvider) => {\n if (!provider.hasParent()) {\n return buildRouter(injector, provider);\n }\n });\n }\n}\n"]}
1
+ {"version":3,"file":"Platform.js","sourceRoot":"","sources":["../../../src/services/Platform.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAgB,MAAM,UAAU,CAAC;AACjG,O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AAQ,CAAC,CAAC;aACxC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA3HY,QAAQ;IAJpB,UAAU,CAAC;QACV,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,OAAO,EAAE,CAAC,wBAAwB,CAAC;KACpC,CAAC;qCAK+B,eAAe,EAAgC,mBAAmB;GAJtF,QAAQ,CA2HpB;SA3HY,QAAQ","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {Injectable, InjectorService, ProviderScope, ProviderType, TokenProvider} from \"@tsed/di\";\nimport {concatPath, EndpointMetadata, getJsonEntityStore, getOperationsRoutes, JsonEntityStore} from \"@tsed/schema\";\nimport {buildRouter, createRouter, getRouter} from \"../builder/PlatformControllerBuilder\";\nimport {ControllerProvider} from \"../domain/ControllerProvider\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\nimport {Route, RouteController} from \"../interfaces/Route\";\nimport {PlatformApplication} from \"./PlatformApplication\";\nimport {PlatformMiddlewaresChain} from \"./PlatformMiddlewaresChain\";\n\n/**\n * `Platform` is used to provide all routes collected by annotation `@Controller`.\n *\n * @platform\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n imports: [PlatformMiddlewaresChain]\n})\nexport class Platform {\n private _routes: PlatformRouteDetails[] = [];\n private _controllers: RouteController[] = [];\n\n constructor(readonly injector: InjectorService, readonly platformApplication: PlatformApplication) {\n this.createRouters();\n }\n\n get app() {\n return this.platformApplication;\n }\n\n get routes(): PlatformRouteDetails[] {\n return this._routes;\n }\n\n public addRoutes(routes: Route[]) {\n routes.forEach((routeSettings) => {\n this.addRoute(routeSettings.route, routeSettings.token);\n });\n }\n\n public addRoute(basePath: string, token: TokenProvider) {\n const {injector} = this;\n const provider = injector.getProvider(token) as ControllerProvider;\n\n if (!provider || provider.hasParent()) {\n return;\n }\n\n this._controllers.push(...this.getAllControllers(basePath, token));\n\n const ctrlPath = concatPath(basePath, JsonEntityStore.from(provider.token).path);\n\n this.app.use(ctrlPath, ...[].concat(getRouter(injector, provider).callback()));\n\n this._routes = getOperationsRoutes<EndpointMetadata>(provider.token, {\n withChildren: true,\n basePath\n }).reduce((routes, operationRoute) => {\n if (injector.hasProvider(token)) {\n const provider = injector.getProvider(operationRoute.token) as ControllerProvider;\n const route = new PlatformRouteDetails({\n ...operationRoute,\n provider\n });\n\n routes = routes.concat(route);\n }\n\n return routes;\n }, this._routes);\n\n return this;\n }\n\n /**\n * Get all routes built by TsExpressDecorators and mounted on Express application.\n * @returns {PlatformRouteDetails[]}\n */\n public getRoutes(): PlatformRouteDetails[] {\n return this._routes;\n }\n\n /**\n * Get all controllers mounted on the application.\n * @returns {RouteController[]}\n */\n public getMountedControllers(): RouteController[] {\n return this._controllers;\n }\n\n protected $onInit() {\n this.buildControllers();\n }\n\n /**\n * Create routers from the collected controllers.\n * @private\n */\n private createRouters() {\n const {injector} = this;\n\n injector.getProviders(ProviderType.CONTROLLER).map((provider: ControllerProvider) => {\n createRouter(injector, provider);\n });\n }\n\n /**\n * Get all router controllers from the controller token.\n * @private\n */\n private getAllControllers(basePath: string, token: Type<any> | any): RouteController[] {\n const store: JsonEntityStore = token.isStore ? token : getJsonEntityStore(token);\n const ctrlPath = concatPath(basePath, JsonEntityStore.from(token).path);\n const children = store.get<Type[]>(\"childrenControllers\", []);\n\n return children\n .reduce<RouteController[]>((controllers, token) => {\n const childBasePath = concatPath(basePath, store.path);\n return controllers.concat(this.getAllControllers(childBasePath, token));\n }, [])\n .concat([\n {\n route: ctrlPath,\n provider: this.injector.getProvider(token) as ControllerProvider\n }\n ]);\n }\n\n /**\n * Create controllers from DI\n * @private\n */\n private buildControllers() {\n const {injector} = this;\n\n injector.getProviders(ProviderType.CONTROLLER).map((provider: ControllerProvider) => {\n if (!provider.hasParent()) {\n return buildRouter(injector, provider);\n }\n });\n }\n}\n"]}
@@ -1,6 +1,18 @@
1
1
  import { InjectorService, registerProvider } from "@tsed/di";
2
2
  import { FakeAdapter } from "./FakeAdapter.js";
3
3
  export class PlatformAdapter {
4
+ /**
5
+ * Load providers in top priority
6
+ */
7
+ providers;
8
+ /**
9
+ * Called after the injector instantiation
10
+ */
11
+ onInit;
12
+ beforeLoadRoutes;
13
+ afterLoadRoutes;
14
+ useRouter;
15
+ useContext;
4
16
  }
5
17
  registerProvider({
6
18
  provide: PlatformAdapter,
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformAdapter.js","sourceRoot":"","sources":["../../../src/services/PlatformAdapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAgB,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAIzE,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,MAAM,OAAgB,eAAe;CAoCpC;AAMD,gBAAgB,CAAC;IACf,OAAO,EAAE,eAAe;IACxB,IAAI,EAAE,CAAC,eAAe,CAAC;IACvB,QAAQ,EAAE,WAAW;CACtB,CAAC,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {InjectorService, ProviderOpts, registerProvider} from \"@tsed/di\";\nimport {PlatformMulter, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformStaticsOptions} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {RouterOptions} from \"express\";\nimport {FakeAdapter} from \"./FakeAdapter\";\n\nexport abstract class PlatformAdapter<App = TsED.Application, Router = TsED.Router> {\n /**\n * Load providers in top priority\n */\n providers: ProviderOpts[];\n /**\n * Called after the injector instantiation\n */\n onInit?: () => any;\n beforeLoadRoutes?: () => Promise<any>;\n afterLoadRoutes?: () => Promise<any>;\n useRouter?: () => any;\n useContext?: () => any;\n\n abstract app(): {app: App; callback(): any};\n\n abstract router(routerOptions?: Partial<RouterOptions>): {router: Router; callback(): any};\n /**\n * Return the statics middlewares\n * @param endpoint\n * @param options\n */\n abstract statics(endpoint: string, options: PlatformStaticsOptions): any;\n\n /**\n * Return the multipart middleware\n * @param options\n */\n abstract multipart(options: PlatformMulterSettings): PlatformMulter;\n\n /**\n * Return the body parser for the given\n * @param type\n * @param opts\n */\n abstract bodyParser(type: string, opts?: Record<string, any>): any;\n}\n\nexport interface PlatformBuilderSettings<App = TsED.Application, Router = TsED.Router> extends Partial<TsED.Configuration> {\n adapter?: Type<PlatformAdapter<App, Router>>;\n}\n\nregisterProvider({\n provide: PlatformAdapter,\n deps: [InjectorService],\n useClass: FakeAdapter\n});\n"]}
1
+ {"version":3,"file":"PlatformAdapter.js","sourceRoot":"","sources":["../../../src/services/PlatformAdapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAgB,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAIzE,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,MAAM,OAAgB,eAAe;IACnC;;OAEG;IACH,SAAS,CAAiB;IAC1B;;OAEG;IACH,MAAM,CAAa;IACnB,gBAAgB,CAAsB;IACtC,eAAe,CAAsB;IACrC,SAAS,CAAa;IACtB,UAAU,CAAa;CAwBxB;AAMD,gBAAgB,CAAC;IACf,OAAO,EAAE,eAAe;IACxB,IAAI,EAAE,CAAC,eAAe,CAAC;IACvB,QAAQ,EAAE,WAAW;CACtB,CAAC,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {InjectorService, ProviderOpts, registerProvider} from \"@tsed/di\";\nimport {PlatformMulter, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformStaticsOptions} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {RouterOptions} from \"express\";\nimport {FakeAdapter} from \"./FakeAdapter\";\n\nexport abstract class PlatformAdapter<App = TsED.Application, Router = TsED.Router> {\n /**\n * Load providers in top priority\n */\n providers: ProviderOpts[];\n /**\n * Called after the injector instantiation\n */\n onInit?: () => any;\n beforeLoadRoutes?: () => Promise<any>;\n afterLoadRoutes?: () => Promise<any>;\n useRouter?: () => any;\n useContext?: () => any;\n\n abstract app(): {app: App; callback(): any};\n\n abstract router(routerOptions?: Partial<RouterOptions>): {router: Router; callback(): any};\n /**\n * Return the statics middlewares\n * @param endpoint\n * @param options\n */\n abstract statics(endpoint: string, options: PlatformStaticsOptions): any;\n\n /**\n * Return the multipart middleware\n * @param options\n */\n abstract multipart(options: PlatformMulterSettings): PlatformMulter;\n\n /**\n * Return the body parser for the given\n * @param type\n * @param opts\n */\n abstract bodyParser(type: string, opts?: Record<string, any>): any;\n}\n\nexport interface PlatformBuilderSettings<App = TsED.Application, Router = TsED.Router> extends Partial<TsED.Configuration> {\n adapter?: Type<PlatformAdapter<App, Router>>;\n}\n\nregisterProvider({\n provide: PlatformAdapter,\n deps: [InjectorService],\n useClass: FakeAdapter\n});\n"]}
@@ -9,6 +9,8 @@ import { PlatformAdapter } from "./PlatformAdapter.js";
9
9
  * @platform
10
10
  */
11
11
  let PlatformApplication = class PlatformApplication extends PlatformRouter {
12
+ raw;
13
+ rawApp;
12
14
  constructor(platformHandler, adapter) {
13
15
  super(platformHandler, adapter);
14
16
  const { app, callback } = adapter.app();
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformApplication.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AACnD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AASlD;;;;GAIG;AAIH,IAAa,mBAAmB,GAAhC,MAAa,mBAAkE,SAAQ,cAA2B;IAKhH,YAAY,eAAgC,EAAE,OAAqC;QACjF,KAAK,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QAChC,MAAM,EAAC,GAAG,EAAE,QAAQ,EAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAEtC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF,CAAA;AAhBY,mBAAmB;IAH/B,UAAU,CAAC;QACV,KAAK,EAAE,aAAa,CAAC,SAAS;KAC/B,CAAC;qCAM6B,eAAe,EAAW,eAAe;GAL3D,mBAAmB,CAgB/B;SAhBY,mBAAmB","sourcesContent":["import {Injectable, ProviderScope} from \"@tsed/di\";\nimport {PlatformHandler} from \"./PlatformHandler\";\nimport {PlatformRouter} from \"./PlatformRouter\";\nimport {PlatformAdapter} from \"./PlatformAdapter\";\n\ndeclare global {\n namespace TsED {\n // @ts-ignore\n export interface Application {}\n }\n}\n\n/**\n * `PlatformApplication` is used to provide all routes collected by annotation `@Controller`.\n *\n * @platform\n */\n@Injectable({\n scope: ProviderScope.SINGLETON\n})\nexport class PlatformApplication<App = TsED.Application, Router = TsED.Router> extends PlatformRouter<App, Router> {\n raw: App;\n rawApp: App;\n declare rawRouter: Router;\n\n constructor(platformHandler: PlatformHandler, adapter: PlatformAdapter<App, Router>) {\n super(platformHandler, adapter);\n const {app, callback} = adapter.app();\n\n this.rawApp = this.raw = app;\n this.callback = callback;\n }\n\n getApp(): App {\n return this.raw;\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformApplication.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AACnD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AASlD;;;;GAIG;AAIH,IAAa,mBAAmB,GAAhC,MAAa,mBAAkE,SAAQ,cAA2B;IAChH,GAAG,CAAM;IACT,MAAM,CAAM;IAGZ,YAAY,eAAgC,EAAE,OAAqC;QACjF,KAAK,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QAChC,MAAM,EAAC,GAAG,EAAE,QAAQ,EAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAEtC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF,CAAA;AAhBY,mBAAmB;IAH/B,UAAU,CAAC;QACV,KAAK,EAAE,aAAa,CAAC,SAAS;KAC/B,CAAC;qCAM6B,eAAe,EAAW,eAAe;GAL3D,mBAAmB,CAgB/B;SAhBY,mBAAmB","sourcesContent":["import {Injectable, ProviderScope} from \"@tsed/di\";\nimport {PlatformHandler} from \"./PlatformHandler\";\nimport {PlatformRouter} from \"./PlatformRouter\";\nimport {PlatformAdapter} from \"./PlatformAdapter\";\n\ndeclare global {\n namespace TsED {\n // @ts-ignore\n export interface Application {}\n }\n}\n\n/**\n * `PlatformApplication` is used to provide all routes collected by annotation `@Controller`.\n *\n * @platform\n */\n@Injectable({\n scope: ProviderScope.SINGLETON\n})\nexport class PlatformApplication<App = TsED.Application, Router = TsED.Router> extends PlatformRouter<App, Router> {\n raw: App;\n rawApp: App;\n declare rawRouter: Router;\n\n constructor(platformHandler: PlatformHandler, adapter: PlatformAdapter<App, Router>) {\n super(platformHandler, adapter);\n const {app, callback} = adapter.app();\n\n this.rawApp = this.raw = app;\n this.callback = callback;\n }\n\n getApp(): App {\n return this.raw;\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import { AnyToPromiseStatus, isFunction, isStream } from "@tsed/core";
3
- import { Inject, Injectable, InjectorService, ProviderScope, runInContext } from "@tsed/di";
3
+ import { Inject, Injectable, InjectorService, ProviderScope } from "@tsed/di";
4
4
  import { $log } from "@tsed/logger";
5
5
  import { PlatformParams } from "@tsed/platform-params";
6
6
  import { PlatformResponseFilter } from "@tsed/platform-response-filter";
@@ -14,6 +14,9 @@ import { setResponseHeaders } from "../utils/setResponseHeaders.js";
14
14
  * @platform
15
15
  */
16
16
  let PlatformHandler = class PlatformHandler {
17
+ injector;
18
+ params;
19
+ responseFilter;
17
20
  constructor(injector, params) {
18
21
  this.injector = injector;
19
22
  this.params = params;
@@ -102,8 +105,8 @@ let PlatformHandler = class PlatformHandler {
102
105
  });
103
106
  return;
104
107
  }
105
- const resolver = new AnyToPromiseWithCtx({ $ctx, err });
106
- return runInContext($ctx, async () => {
108
+ return $ctx.runInContext(async () => {
109
+ const resolver = new AnyToPromiseWithCtx({ $ctx, err });
107
110
  try {
108
111
  const { state, data, status, headers } = await resolver.call(handler);
109
112
  if (state === AnyToPromiseStatus.RESOLVED) {
@@ -140,7 +143,7 @@ let PlatformHandler = class PlatformHandler {
140
143
  message: `An error was caught after the headers were sent to the client. The error comes from the handler: ${metadata.toString()}`,
141
144
  stack: er.stack,
142
145
  origin: er,
143
- request_id: $ctx === null || $ctx === void 0 ? void 0 : $ctx.id
146
+ request_id: $ctx?.id
144
147
  });
145
148
  return;
146
149
  }
@@ -155,7 +158,7 @@ let PlatformHandler = class PlatformHandler {
155
158
  async onSuccess(data, requestOptions) {
156
159
  const { metadata, $ctx, next } = requestOptions;
157
160
  // istanbul ignore next
158
- if ($ctx === null || $ctx === void 0 ? void 0 : $ctx.isDone()) {
161
+ if ($ctx?.isDone()) {
159
162
  return;
160
163
  }
161
164
  // set headers each times that an endpoint is called