@tsed/common 7.0.0-beta.8 → 7.0.0-rc.2

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 (203) hide show
  1. package/coverage.json +6 -0
  2. package/jest.config.js +9 -0
  3. package/lib/cjs/builder/PlatformBuilder.js +86 -68
  4. package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
  5. package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -1
  6. package/lib/cjs/config/services/PlatformConfiguration.js +0 -64
  7. package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -1
  8. package/lib/cjs/decorators/params/error.js +1 -1
  9. package/lib/cjs/decorators/params/error.js.map +1 -1
  10. package/lib/cjs/domain/AnyToPromiseWithCtx.js +4 -5
  11. package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -1
  12. package/lib/cjs/domain/PlatformContext.js +46 -38
  13. package/lib/cjs/domain/PlatformContext.js.map +1 -1
  14. package/lib/cjs/domain/PlatformRouteDetails.js +0 -21
  15. package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -1
  16. package/lib/cjs/exports.js +1 -1
  17. package/lib/cjs/exports.js.map +1 -1
  18. package/lib/cjs/index.js +1 -9
  19. package/lib/cjs/index.js.map +1 -1
  20. package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -1
  21. package/lib/cjs/interfaces/Route.js.map +1 -1
  22. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +2 -1
  23. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  24. package/lib/cjs/middlewares/PlatformMulterMiddleware.js +2 -0
  25. package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -1
  26. package/lib/cjs/services/FakeAdapter.js +6 -12
  27. package/lib/cjs/services/FakeAdapter.js.map +1 -1
  28. package/lib/cjs/services/Platform.js +30 -86
  29. package/lib/cjs/services/Platform.js.map +1 -1
  30. package/lib/cjs/services/PlatformAdapter.js +10 -0
  31. package/lib/cjs/services/PlatformAdapter.js.map +1 -1
  32. package/lib/cjs/services/PlatformApplication.js +23 -9
  33. package/lib/cjs/services/PlatformApplication.js.map +1 -1
  34. package/lib/cjs/services/PlatformHandler.js +112 -171
  35. package/lib/cjs/services/PlatformHandler.js.map +1 -1
  36. package/lib/cjs/services/PlatformMiddlewaresChain.js +5 -19
  37. package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
  38. package/lib/cjs/services/PlatformRequest.js +16 -12
  39. package/lib/cjs/services/PlatformRequest.js.map +1 -1
  40. package/lib/cjs/services/PlatformResponse.js +19 -22
  41. package/lib/cjs/services/PlatformResponse.js.map +1 -1
  42. package/lib/cjs/services/PlatformTest.js +29 -9
  43. package/lib/cjs/services/PlatformTest.js.map +1 -1
  44. package/lib/cjs/utils/createContext.js +32 -21
  45. package/lib/cjs/utils/createContext.js.map +1 -1
  46. package/lib/cjs/utils/createHttpServer.js +3 -3
  47. package/lib/cjs/utils/createHttpServer.js.map +1 -1
  48. package/lib/cjs/utils/createHttpsServer.js +3 -3
  49. package/lib/cjs/utils/createHttpsServer.js.map +1 -1
  50. package/lib/cjs/utils/createInjector.js +6 -8
  51. package/lib/cjs/utils/createInjector.js.map +1 -1
  52. package/lib/cjs/utils/ensureContext.js +16 -0
  53. package/lib/cjs/utils/ensureContext.js.map +1 -0
  54. package/lib/cjs/utils/getConfiguration.js +6 -12
  55. package/lib/cjs/utils/getConfiguration.js.map +1 -1
  56. package/lib/cjs/utils/printRoutes.js +10 -8
  57. package/lib/cjs/utils/printRoutes.js.map +1 -1
  58. package/lib/cjs/utils/setResponseHeaders.js +8 -14
  59. package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
  60. package/lib/esm/builder/PlatformBuilder.js +63 -68
  61. package/lib/esm/builder/PlatformBuilder.js.map +1 -1
  62. package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -1
  63. package/lib/esm/config/services/PlatformConfiguration.js +0 -64
  64. package/lib/esm/config/services/PlatformConfiguration.js.map +1 -1
  65. package/lib/esm/decorators/params/error.js +1 -1
  66. package/lib/esm/decorators/params/error.js.map +1 -1
  67. package/lib/esm/domain/AnyToPromiseWithCtx.js +4 -5
  68. package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -1
  69. package/lib/esm/domain/PlatformContext.js +46 -38
  70. package/lib/esm/domain/PlatformContext.js.map +1 -1
  71. package/lib/esm/domain/PlatformRouteDetails.js +1 -19
  72. package/lib/esm/domain/PlatformRouteDetails.js.map +1 -1
  73. package/lib/esm/exports.js +1 -1
  74. package/lib/esm/exports.js.map +1 -1
  75. package/lib/esm/index.js +1 -9
  76. package/lib/esm/index.js.map +1 -1
  77. package/lib/esm/interfaces/PlatformRouteOptions.js.map +1 -1
  78. package/lib/esm/interfaces/Route.js.map +1 -1
  79. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +2 -1
  80. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  81. package/lib/esm/middlewares/PlatformMulterMiddleware.js +2 -0
  82. package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -1
  83. package/lib/esm/services/FakeAdapter.js +6 -12
  84. package/lib/esm/services/FakeAdapter.js.map +1 -1
  85. package/lib/esm/services/Platform.js +31 -87
  86. package/lib/esm/services/Platform.js.map +1 -1
  87. package/lib/esm/services/PlatformAdapter.js +10 -0
  88. package/lib/esm/services/PlatformAdapter.js.map +1 -1
  89. package/lib/esm/services/PlatformApplication.js +23 -9
  90. package/lib/esm/services/PlatformApplication.js.map +1 -1
  91. package/lib/esm/services/PlatformHandler.js +114 -173
  92. package/lib/esm/services/PlatformHandler.js.map +1 -1
  93. package/lib/esm/services/PlatformMiddlewaresChain.js +5 -19
  94. package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
  95. package/lib/esm/services/PlatformRequest.js +16 -12
  96. package/lib/esm/services/PlatformRequest.js.map +1 -1
  97. package/lib/esm/services/PlatformResponse.js +19 -22
  98. package/lib/esm/services/PlatformResponse.js.map +1 -1
  99. package/lib/esm/services/PlatformTest.js +29 -9
  100. package/lib/esm/services/PlatformTest.js.map +1 -1
  101. package/lib/esm/utils/createContext.js +30 -20
  102. package/lib/esm/utils/createContext.js.map +1 -1
  103. package/lib/esm/utils/createHttpServer.js +3 -3
  104. package/lib/esm/utils/createHttpServer.js.map +1 -1
  105. package/lib/esm/utils/createHttpsServer.js +3 -3
  106. package/lib/esm/utils/createHttpsServer.js.map +1 -1
  107. package/lib/esm/utils/createInjector.js +7 -9
  108. package/lib/esm/utils/createInjector.js.map +1 -1
  109. package/lib/esm/utils/ensureContext.js +12 -0
  110. package/lib/esm/utils/ensureContext.js.map +1 -0
  111. package/lib/esm/utils/getConfiguration.js +8 -14
  112. package/lib/esm/utils/getConfiguration.js.map +1 -1
  113. package/lib/esm/utils/printRoutes.js +10 -8
  114. package/lib/esm/utils/printRoutes.js.map +1 -1
  115. package/lib/esm/utils/setResponseHeaders.js +8 -14
  116. package/lib/esm/utils/setResponseHeaders.js.map +1 -1
  117. package/lib/types/builder/PlatformBuilder.d.ts +17 -16
  118. package/lib/types/config/interfaces/PlatformLoggerSettings.d.ts +2 -43
  119. package/lib/types/config/services/PlatformConfiguration.d.ts +6 -22
  120. package/lib/types/domain/AnyToPromiseWithCtx.d.ts +1 -9
  121. package/lib/types/domain/PlatformContext.d.ts +32 -18
  122. package/lib/types/domain/PlatformRouteDetails.d.ts +4 -19
  123. package/lib/types/exports.d.ts +1 -1
  124. package/lib/types/index.d.ts +1 -9
  125. package/lib/types/interfaces/PlatformRouteOptions.d.ts +0 -1
  126. package/lib/types/interfaces/Route.d.ts +2 -3
  127. package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +1 -1
  128. package/lib/types/services/FakeAdapter.d.ts +7 -6
  129. package/lib/types/services/Platform.d.ts +7 -28
  130. package/lib/types/services/PlatformAdapter.d.ts +22 -11
  131. package/lib/types/services/PlatformApplication.d.ts +14 -6
  132. package/lib/types/services/PlatformHandler.d.ts +21 -59
  133. package/lib/types/services/PlatformMiddlewaresChain.d.ts +1 -2
  134. package/lib/types/services/PlatformRequest.d.ts +8 -10
  135. package/lib/types/services/PlatformResponse.d.ts +11 -15
  136. package/lib/types/services/PlatformTest.d.ts +4 -3
  137. package/lib/types/utils/createContext.d.ts +4 -1
  138. package/lib/types/utils/createHttpsServer.d.ts +1 -0
  139. package/lib/types/utils/createInjector.d.ts +2 -2
  140. package/lib/types/utils/ensureContext.d.ts +2 -0
  141. package/lib/types/utils/listenServer.d.ts +2 -0
  142. package/package.json +27 -25
  143. package/readme.md +2 -1
  144. package/lib/cjs/builder/PlatformControllerBuilder.js +0 -82
  145. package/lib/cjs/builder/PlatformControllerBuilder.js.map +0 -1
  146. package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js +0 -3
  147. package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js.map +0 -1
  148. package/lib/cjs/domain/ControllerProvider.js +0 -51
  149. package/lib/cjs/domain/ControllerProvider.js.map +0 -1
  150. package/lib/cjs/domain/HandlerMetadata.js +0 -57
  151. package/lib/cjs/domain/HandlerMetadata.js.map +0 -1
  152. package/lib/cjs/middlewares/__mock__/FakeCtrl.js +0 -12
  153. package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +0 -1
  154. package/lib/cjs/middlewares/bindEndpointMiddleware.js +0 -13
  155. package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +0 -1
  156. package/lib/cjs/services/PlatformRouter.js +0 -108
  157. package/lib/cjs/services/PlatformRouter.js.map +0 -1
  158. package/lib/cjs/utils/__mock__/Test1.js +0 -8
  159. package/lib/cjs/utils/__mock__/Test1.js.map +0 -1
  160. package/lib/cjs/utils/__mock__/Test2.js +0 -8
  161. package/lib/cjs/utils/__mock__/Test2.js.map +0 -1
  162. package/lib/cjs/utils/createHandlerMetadata.js +0 -49
  163. package/lib/cjs/utils/createHandlerMetadata.js.map +0 -1
  164. package/lib/cjs/utils/importProviders.js +0 -29
  165. package/lib/cjs/utils/importProviders.js.map +0 -1
  166. package/lib/cjs/utils/useCtxHandler.js +0 -15
  167. package/lib/cjs/utils/useCtxHandler.js.map +0 -1
  168. package/lib/esm/builder/PlatformControllerBuilder.js +0 -76
  169. package/lib/esm/builder/PlatformControllerBuilder.js.map +0 -1
  170. package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js +0 -2
  171. package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js.map +0 -1
  172. package/lib/esm/domain/ControllerProvider.js +0 -47
  173. package/lib/esm/domain/ControllerProvider.js.map +0 -1
  174. package/lib/esm/domain/HandlerMetadata.js +0 -53
  175. package/lib/esm/domain/HandlerMetadata.js.map +0 -1
  176. package/lib/esm/middlewares/__mock__/FakeCtrl.js +0 -9
  177. package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +0 -1
  178. package/lib/esm/middlewares/bindEndpointMiddleware.js +0 -9
  179. package/lib/esm/middlewares/bindEndpointMiddleware.js.map +0 -1
  180. package/lib/esm/services/PlatformRouter.js +0 -105
  181. package/lib/esm/services/PlatformRouter.js.map +0 -1
  182. package/lib/esm/utils/__mock__/Test1.js +0 -4
  183. package/lib/esm/utils/__mock__/Test1.js.map +0 -1
  184. package/lib/esm/utils/__mock__/Test2.js +0 -4
  185. package/lib/esm/utils/__mock__/Test2.js.map +0 -1
  186. package/lib/esm/utils/createHandlerMetadata.js +0 -45
  187. package/lib/esm/utils/createHandlerMetadata.js.map +0 -1
  188. package/lib/esm/utils/importProviders.js +0 -25
  189. package/lib/esm/utils/importProviders.js.map +0 -1
  190. package/lib/esm/utils/useCtxHandler.js +0 -11
  191. package/lib/esm/utils/useCtxHandler.js.map +0 -1
  192. package/lib/types/builder/PlatformControllerBuilder.d.ts +0 -18
  193. package/lib/types/config/interfaces/EndpointDirectoriesSettings.d.ts +0 -3
  194. package/lib/types/domain/ControllerProvider.d.ts +0 -24
  195. package/lib/types/domain/HandlerMetadata.d.ts +0 -32
  196. package/lib/types/middlewares/__mock__/FakeCtrl.d.ts +0 -2
  197. package/lib/types/middlewares/bindEndpointMiddleware.d.ts +0 -6
  198. package/lib/types/services/PlatformRouter.d.ts +0 -51
  199. package/lib/types/utils/__mock__/Test1.d.ts +0 -3
  200. package/lib/types/utils/__mock__/Test2.d.ts +0 -3
  201. package/lib/types/utils/createHandlerMetadata.d.ts +0 -8
  202. package/lib/types/utils/importProviders.d.ts +0 -10
  203. package/lib/types/utils/useCtxHandler.d.ts +0 -13
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../src/decorators/params/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,UAAU,GAAG;IACjB,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,GAAG;QACzB,QAAQ,EAAE,KAAK;QACf,aAAa,EAAE,KAAK;QACpB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {ParamTypes, UseParam} from \"@tsed/platform-params\";\n\n/**\n * @returns {Function}\n * @decorator\n * @operation\n * @input\n */\nexport function Err(): Function {\n return UseParam({\n paramType: ParamTypes.ERR,\n dataPath: \"err\",\n useValidation: false,\n useConverter: false\n });\n}\n"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../src/decorators/params/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,UAAU,GAAG;IACjB,OAAO,QAAQ,CAAC;QACd,SAAS,EAAE,UAAU,CAAC,GAAG;QACzB,QAAQ,EAAE,YAAY;QACtB,aAAa,EAAE,KAAK;QACpB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {ParamTypes, UseParam} from \"@tsed/platform-params\";\n\n/**\n * @returns {Function}\n * @decorator\n * @operation\n * @input\n */\nexport function Err(): Function {\n return UseParam({\n paramType: ParamTypes.ERR,\n dataPath: \"$ctx.error\",\n useValidation: false,\n useConverter: false\n });\n}\n"]}
@@ -1,20 +1,19 @@
1
1
  import { AnyToPromise } from "@tsed/core";
2
2
  export class AnyToPromiseWithCtx extends AnyToPromise {
3
- constructor({ $ctx, err }) {
3
+ $ctx;
4
+ constructor($ctx) {
4
5
  super();
5
6
  this.$ctx = $ctx;
6
- this.err = err;
7
7
  }
8
8
  isDone() {
9
9
  const { $ctx } = this;
10
- return ($ctx === null || $ctx === void 0 ? void 0 : $ctx.isDone()) || super.isDone();
10
+ return $ctx?.isDone() || super.isDone();
11
11
  }
12
12
  async call(cb) {
13
13
  return super.call(() => cb(this));
14
14
  }
15
15
  destroy() {
16
- // @ts-ignore
17
- delete this.$ctx;
16
+ this.$ctx = null;
18
17
  }
19
18
  isCanceledResponse(process) {
20
19
  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;AAG1D,MAAM,OAAO,mBAAoB,SAAQ,YAAY;IAC5C,IAAI,CAAkB;IAE7B,YAAY,IAAqB;QAC/B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,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;QACJ,IAAI,CAAC,IAAY,GAAG,IAAI,CAAC;IAC5B,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\nexport class AnyToPromiseWithCtx extends AnyToPromise {\n public $ctx: PlatformContext;\n\n constructor($ctx: PlatformContext) {\n super();\n this.$ctx = $ctx;\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 as any) = null;\n }\n\n isCanceledResponse(process: any) {\n return process === this.$ctx.getResponse();\n }\n}\n"]}
@@ -3,26 +3,44 @@ import { PlatformApplication } from "../services/PlatformApplication.js";
3
3
  import { PlatformRequest } from "../services/PlatformRequest.js";
4
4
  import { PlatformResponse } from "../services/PlatformResponse.js";
5
5
  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;
6
+ event;
7
+ /**
8
+ * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.
9
+ */
10
+ data;
11
+ /**
12
+ * The error caught by the current handler
13
+ */
14
+ error;
15
+ /**
16
+ *
17
+ */
18
+ next;
19
+ /**
20
+ * The current @@PlatformResponse@@.
21
+ */
22
+ response;
23
+ /**
24
+ * The current @@PlatformRequest@@.
25
+ */
26
+ request;
27
+ /**
28
+ * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
29
+ */
30
+ endpoint;
31
+ /**
32
+ * The current @@PlatformHandlerMetadata@@ resolved by Ts.ED during the request.
33
+ */
34
+ handlerMetadata;
35
+ #isFinished = false;
36
+ constructor(options) {
37
+ super(options);
38
+ options.endpoint && (this.endpoint = options.endpoint);
39
+ this.event = options.event;
40
+ this.response = new (options.ResponseKlass || PlatformResponse)(this);
41
+ this.request = new (options.RequestKlass || PlatformRequest)(this);
20
42
  this.request.request.$ctx = this;
21
43
  this.request.request.id = this.id;
22
- this.logger.url = this.url;
23
- this.container.set(PlatformResponse, this.response);
24
- this.container.set(PlatformRequest, this.request);
25
- this.container.set(PlatformContext, this);
26
44
  this.response.setHeader("x-request-id", this.id);
27
45
  }
28
46
  get url() {
@@ -31,28 +49,18 @@ export class PlatformContext extends DIContext {
31
49
  get app() {
32
50
  return this.injector.get(PlatformApplication);
33
51
  }
34
- async destroy() {
35
- var _a, _b;
36
- await super.destroy();
37
- (_b = (_a = this.request) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? true : delete _b.$ctx;
38
- this.response.destroy();
39
- this.request.destroy();
40
- // @ts-ignore
41
- delete this.endpoint;
42
- // @ts-ignore
43
- delete this.response;
44
- // @ts-ignore
45
- delete this.request;
52
+ async start() {
53
+ return this.emit("$onRequest", this);
54
+ }
55
+ async finish() {
56
+ await Promise.all([this.emit("$onResponse", this), this.destroy()]);
57
+ this.#isFinished = true;
58
+ }
59
+ isFinished() {
60
+ return this.#isFinished;
46
61
  }
47
62
  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();
63
+ return this.request?.isAborted() || this.response?.isDone() || this.isFinished();
56
64
  }
57
65
  /**
58
66
  * Return the framework request instance (Express, Koa, etc...)
@@ -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,IAAI,CAAC,CAAC;QAE7C,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAEtC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QAE3B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QAE1C,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;IAC1B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAsB,mBAAmB,CAAE,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,OAAO;;QACX,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QAEf,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,+CAAE,IAAI,CAAC;QAEnC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAEvB,aAAa;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;QACrB,aAAa;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;QACrB,aAAa;QACb,OAAO,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,EAAC,SAAS,EAAmB,MAAM,UAAU,CAAC;AAKrD,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,eAGX,SAAQ,SAAS;IACV,KAAK,CAAgB;IAC5B;;OAEG;IACI,IAAI,CAAM;IACjB;;OAEG;IACI,KAAK,CAAW;IACvB;;OAEG;IACI,IAAI,CAAO;IAClB;;OAEG;IACM,QAAQ,CAAO;IACxB;;OAEG;IACM,OAAO,CAAO;IACvB;;OAEG;IACH,QAAQ,CAAmB;IAC3B;;OAEG;IACH,eAAe,CAA0B;IAEzC,WAAW,GAAY,KAAK,CAAC;IAE7B,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,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAElC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;IAC1B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAsB,mBAAmB,CAAE,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACpE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,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;CACF","sourcesContent":["import {DIContext, DIContextOptions} from \"@tsed/di\";\nimport {PlatformHandlerMetadata} from \"@tsed/platform-router\";\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<\n PReq extends PlatformRequest = PlatformRequest,\n PRes extends PlatformResponse = PlatformResponse\n> extends DIContext {\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 *\n */\n public next?: any;\n /**\n * The current @@PlatformResponse@@.\n */\n readonly response: PRes;\n /**\n * The current @@PlatformRequest@@.\n */\n readonly request: PReq;\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n endpoint: EndpointMetadata;\n /**\n * The current @@PlatformHandlerMetadata@@ resolved by Ts.ED during the request.\n */\n handlerMetadata: PlatformHandlerMetadata;\n\n #isFinished: 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\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 start() {\n return this.emit(\"$onRequest\", this);\n }\n\n async finish() {\n await Promise.all([this.emit(\"$onResponse\", this), this.destroy()]);\n this.#isFinished = true;\n }\n\n isFinished() {\n return this.#isFinished;\n }\n\n isDone() {\n return this.request?.isAborted() || this.response?.isDone() || this.isFinished();\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,20 +1,2 @@
1
- import { ParamTypes } from "@tsed/platform-params";
2
- import { JsonOperationRoute } from "@tsed/schema";
3
- export class PlatformRouteDetails extends JsonOperationRoute {
4
- constructor(options = {}) {
5
- super(options);
6
- this.rawBody = !!this.endpoint.parameters.find((param) => param.paramType === ParamTypes.RAW_BODY);
7
- }
8
- toJSON() {
9
- return {
10
- method: this.method,
11
- name: this.name,
12
- url: this.url,
13
- className: this.className,
14
- methodClassName: this.methodClassName,
15
- parameters: this.parameters,
16
- rawBody: this.rawBody
17
- };
18
- }
19
- }
1
+ export {};
20
2
  //# sourceMappingURL=PlatformRouteDetails.js.map
@@ -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":"","sourcesContent":["export interface PlatformRouteDetails {\n method: string;\n name: string;\n url: string;\n className: string;\n methodClassName: string;\n}\n"]}
@@ -4,10 +4,10 @@ export * from "@tsed/di";
4
4
  export * from "@tsed/platform-params";
5
5
  export * from "@tsed/platform-exceptions";
6
6
  export * from "@tsed/platform-response-filter";
7
- export * from "@tsed/platform-cache";
8
7
  export * from "@tsed/platform-middlewares";
9
8
  export * from "@tsed/components-scan";
10
9
  export * from "@tsed/platform-log-middleware";
10
+ export * from "@tsed/platform-router";
11
11
  export { $log, Logger } from "@tsed/logger";
12
12
  export { AcceptMime, Location, Redirect, View, Get, Post, Put, Patch, Delete, Head, Options, All } from "@tsed/schema";
13
13
  //# sourceMappingURL=exports.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,OAAO,mBAAmB,CAAC;AAE3B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAE9C,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,cAAc,CAAC","sourcesContent":["import \"@tsed/logger\";\nimport \"@tsed/logger-file\";\n\nexport * from \"@tsed/di\";\nexport * from \"@tsed/platform-params\";\nexport * from \"@tsed/platform-exceptions\";\nexport * from \"@tsed/platform-response-filter\";\nexport * from \"@tsed/platform-cache\";\nexport * from \"@tsed/platform-middlewares\";\nexport * from \"@tsed/components-scan\";\nexport * from \"@tsed/platform-log-middleware\";\n\nexport {$log, Logger} from \"@tsed/logger\";\n\nexport {AcceptMime, Location, Redirect, View, Get, Post, Put, Patch, Delete, Head, Options, All} from \"@tsed/schema\";\n"]}
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,OAAO,mBAAmB,CAAC;AAE3B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AAEtC,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,cAAc,CAAC","sourcesContent":["import \"@tsed/logger\";\nimport \"@tsed/logger-file\";\n\nexport * from \"@tsed/di\";\nexport * from \"@tsed/platform-params\";\nexport * from \"@tsed/platform-exceptions\";\nexport * from \"@tsed/platform-response-filter\";\nexport * from \"@tsed/platform-middlewares\";\nexport * from \"@tsed/components-scan\";\nexport * from \"@tsed/platform-log-middleware\";\nexport * from \"@tsed/platform-router\";\n\nexport {$log, Logger} from \"@tsed/logger\";\n\nexport {AcceptMime, Location, Redirect, View, Get, Post, Put, Patch, Delete, Head, Options, All} from \"@tsed/schema\";\n"]}
package/lib/esm/index.js CHANGED
@@ -3,9 +3,7 @@
3
3
  */
4
4
  export * from "./exports.js";
5
5
  export * from "./builder/PlatformBuilder.js";
6
- export * from "./builder/PlatformControllerBuilder.js";
7
6
  export * from "./config/interfaces/ConverterSettings.js";
8
- export * from "./config/interfaces/EndpointDirectoriesSettings.js";
9
7
  export * from "./config/interfaces/PlatformLoggerSettings.js";
10
8
  export * from "./config/interfaces/PlatformMulterSettings.js";
11
9
  export * from "./config/interfaces/PlatformStaticsSettings.js";
@@ -19,9 +17,7 @@ export * from "./decorators/params/next.js";
19
17
  export * from "./decorators/params/request.js";
20
18
  export * from "./decorators/params/response.js";
21
19
  export * from "./domain/AnyToPromiseWithCtx.js";
22
- export * from "./domain/ControllerProvider.js";
23
20
  export * from "./domain/EndpointMetadata.js";
24
- export * from "./domain/HandlerMetadata.js";
25
21
  export * from "./domain/PlatformContext.js";
26
22
  export * from "./domain/PlatformRouteDetails.js";
27
23
  export * from "./interfaces/AfterInit.js";
@@ -41,7 +37,6 @@ export * from "./interfaces/ResponseErrorObject.js";
41
37
  export * from "./interfaces/Route.js";
42
38
  export * from "./middlewares/PlatformAcceptMimesMiddleware.js";
43
39
  export * from "./middlewares/PlatformMulterMiddleware.js";
44
- export * from "./middlewares/bindEndpointMiddleware.js";
45
40
  export * from "./services/FakeAdapter.js";
46
41
  export * from "./services/Platform.js";
47
42
  export * from "./services/PlatformAdapter.js";
@@ -50,18 +45,15 @@ export * from "./services/PlatformHandler.js";
50
45
  export * from "./services/PlatformMiddlewaresChain.js";
51
46
  export * from "./services/PlatformRequest.js";
52
47
  export * from "./services/PlatformResponse.js";
53
- export * from "./services/PlatformRouter.js";
54
48
  export * from "./services/PlatformTest.js";
55
49
  export * from "./utils/createContext.js";
56
- export * from "./utils/createHandlerMetadata.js";
57
50
  export * from "./utils/createHttpServer.js";
58
51
  export * from "./utils/createHttpsServer.js";
59
52
  export * from "./utils/createInjector.js";
53
+ export * from "./utils/ensureContext.js";
60
54
  export * from "./utils/getStaticsOptions.js";
61
- export * from "./utils/importProviders.js";
62
55
  export * from "./utils/listenServer.js";
63
56
  export * from "./utils/mapReturnedResponse.js";
64
57
  export * from "./utils/printRoutes.js";
65
58
  export * from "./utils/setResponseHeaders.js";
66
- export * from "./utils/useCtxHandler.js";
67
59
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,iDAAiD,CAAC;AAChE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,yCAAyC,CAAC;AACxD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./builder/PlatformBuilder\";\nexport * from \"./builder/PlatformControllerBuilder\";\nexport * from \"./config/interfaces/ConverterSettings\";\nexport * from \"./config/interfaces/EndpointDirectoriesSettings\";\nexport * from \"./config/interfaces/PlatformLoggerSettings\";\nexport * from \"./config/interfaces/PlatformMulterSettings\";\nexport * from \"./config/interfaces/PlatformStaticsSettings\";\nexport * from \"./config/services/PlatformConfiguration\";\nexport * from \"./constants/routerOptions\";\nexport * from \"./decorators/multer/multerFileSize\";\nexport * from \"./decorators/multer/multerOptions\";\nexport * from \"./decorators/multer/multipartFile\";\nexport * from \"./decorators/params/error\";\nexport * from \"./decorators/params/next\";\nexport * from \"./decorators/params/request\";\nexport * from \"./decorators/params/response\";\nexport * from \"./domain/AnyToPromiseWithCtx\";\nexport * from \"./domain/ControllerProvider\";\nexport * from \"./domain/EndpointMetadata\";\nexport * from \"./domain/HandlerMetadata\";\nexport * from \"./domain/PlatformContext\";\nexport * from \"./domain/PlatformRouteDetails\";\nexport * from \"./interfaces/AfterInit\";\nexport * from \"./interfaces/AfterListen\";\nexport * from \"./interfaces/AfterRoutesInit\";\nexport * from \"./interfaces/BeforeInit\";\nexport * from \"./interfaces/BeforeListen\";\nexport * from \"./interfaces/BeforeRoutesInit\";\nexport * from \"./interfaces/HandlerType\";\nexport * from \"./interfaces/IncomingEvent\";\nexport * from \"./interfaces/OnReady\";\nexport * from \"./interfaces/OnRequest\";\nexport * from \"./interfaces/OnResponse\";\nexport * from \"./interfaces/OnRoutesInit\";\nexport * from \"./interfaces/PlatformRouteOptions\";\nexport * from \"./interfaces/ResponseErrorObject\";\nexport * from \"./interfaces/Route\";\nexport * from \"./middlewares/PlatformAcceptMimesMiddleware\";\nexport * from \"./middlewares/PlatformMulterMiddleware\";\nexport * from \"./middlewares/bindEndpointMiddleware\";\nexport * from \"./services/FakeAdapter\";\nexport * from \"./services/Platform\";\nexport * from \"./services/PlatformAdapter\";\nexport * from \"./services/PlatformApplication\";\nexport * from \"./services/PlatformHandler\";\nexport * from \"./services/PlatformMiddlewaresChain\";\nexport * from \"./services/PlatformRequest\";\nexport * from \"./services/PlatformResponse\";\nexport * from \"./services/PlatformRouter\";\nexport * from \"./services/PlatformTest\";\nexport * from \"./utils/createContext\";\nexport * from \"./utils/createHandlerMetadata\";\nexport * from \"./utils/createHttpServer\";\nexport * from \"./utils/createHttpsServer\";\nexport * from \"./utils/createInjector\";\nexport * from \"./utils/getStaticsOptions\";\nexport * from \"./utils/importProviders\";\nexport * from \"./utils/listenServer\";\nexport * from \"./utils/mapReturnedResponse\";\nexport * from \"./utils/printRoutes\";\nexport * from \"./utils/setResponseHeaders\";\nexport * from \"./utils/useCtxHandler\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uCAAuC,CAAC;AACtD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,yCAAyC,CAAC;AACxD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC;AACvD,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./builder/PlatformBuilder\";\nexport * from \"./config/interfaces/ConverterSettings\";\nexport * from \"./config/interfaces/PlatformLoggerSettings\";\nexport * from \"./config/interfaces/PlatformMulterSettings\";\nexport * from \"./config/interfaces/PlatformStaticsSettings\";\nexport * from \"./config/services/PlatformConfiguration\";\nexport * from \"./constants/routerOptions\";\nexport * from \"./decorators/multer/multerFileSize\";\nexport * from \"./decorators/multer/multerOptions\";\nexport * from \"./decorators/multer/multipartFile\";\nexport * from \"./decorators/params/error\";\nexport * from \"./decorators/params/next\";\nexport * from \"./decorators/params/request\";\nexport * from \"./decorators/params/response\";\nexport * from \"./domain/AnyToPromiseWithCtx\";\nexport * from \"./domain/EndpointMetadata\";\nexport * from \"./domain/PlatformContext\";\nexport * from \"./domain/PlatformRouteDetails\";\nexport * from \"./interfaces/AfterInit\";\nexport * from \"./interfaces/AfterListen\";\nexport * from \"./interfaces/AfterRoutesInit\";\nexport * from \"./interfaces/BeforeInit\";\nexport * from \"./interfaces/BeforeListen\";\nexport * from \"./interfaces/BeforeRoutesInit\";\nexport * from \"./interfaces/HandlerType\";\nexport * from \"./interfaces/IncomingEvent\";\nexport * from \"./interfaces/OnReady\";\nexport * from \"./interfaces/OnRequest\";\nexport * from \"./interfaces/OnResponse\";\nexport * from \"./interfaces/OnRoutesInit\";\nexport * from \"./interfaces/PlatformRouteOptions\";\nexport * from \"./interfaces/ResponseErrorObject\";\nexport * from \"./interfaces/Route\";\nexport * from \"./middlewares/PlatformAcceptMimesMiddleware\";\nexport * from \"./middlewares/PlatformMulterMiddleware\";\nexport * from \"./services/FakeAdapter\";\nexport * from \"./services/Platform\";\nexport * from \"./services/PlatformAdapter\";\nexport * from \"./services/PlatformApplication\";\nexport * from \"./services/PlatformHandler\";\nexport * from \"./services/PlatformMiddlewaresChain\";\nexport * from \"./services/PlatformRequest\";\nexport * from \"./services/PlatformResponse\";\nexport * from \"./services/PlatformTest\";\nexport * from \"./utils/createContext\";\nexport * from \"./utils/createHttpServer\";\nexport * from \"./utils/createHttpsServer\";\nexport * from \"./utils/createInjector\";\nexport * from \"./utils/ensureContext\";\nexport * from \"./utils/getStaticsOptions\";\nexport * from \"./utils/listenServer\";\nexport * from \"./utils/mapReturnedResponse\";\nexport * from \"./utils/printRoutes\";\nexport * from \"./utils/setResponseHeaders\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformRouteOptions.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformRouteOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PathType} from \"@tsed/di\";\n\n/**\n * @ignore\n */\nexport interface PlatformRouteOptions {\n token?: Type<any>;\n path?: PathType | undefined;\n method?: string;\n isFinal?: boolean;\n handlers: any[];\n}\n\n/**\n * @ignore\n */\nexport type PlatformRouteWithoutHandlers = Partial<Omit<PlatformRouteOptions, \"handlers\">>;\n"]}
1
+ {"version":3,"file":"PlatformRouteOptions.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformRouteOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PathType} from \"@tsed/di\";\n\n/**\n * @ignore\n */\nexport interface PlatformRouteOptions {\n token?: Type<any>;\n path?: PathType | undefined;\n method?: string;\n handlers: any[];\n}\n\n/**\n * @ignore\n */\nexport type PlatformRouteWithoutHandlers = Partial<Omit<PlatformRouteOptions, \"handlers\">>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Route.js","sourceRoot":"","sources":["../../../src/interfaces/Route.ts"],"names":[],"mappings":"","sourcesContent":["import {TokenProvider} from \"@tsed/di\";\nimport {ControllerProvider} from \"../domain/ControllerProvider\";\n\nexport interface Route extends Record<string, any> {\n route: string;\n token: TokenProvider;\n}\n\nexport interface RouteController {\n route: string;\n provider: ControllerProvider;\n}\n"]}
1
+ {"version":3,"file":"Route.js","sourceRoot":"","sources":["../../../src/interfaces/Route.ts"],"names":[],"mappings":"","sourcesContent":["import {Provider, TokenProvider} from \"@tsed/di\";\n\nexport interface Route extends Record<string, any> {\n route: string;\n token: TokenProvider;\n}\n\nexport interface RouteController {\n route: string;\n provider: Provider;\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,CAAC,IAAI,CAAC;IACtB,CAAC;CACF;AAED;;GAEG;AAEH,IAAa,wBAAwB,gCAArC,MAAa,wBAAwB;IAOnC,KAAK,CAAC,GAAG,CAAY,GAAY;QAC/B,IAAI;YACF,MAAM,EAAC,MAAM,EAAE,OAAO,GAAG,EAAE,EAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,0BAAwB,CAAC,CAAC;YAC1E,MAAM,QAAQ,GAA2B;gBACvC,GAAG,IAAI,CAAC,QAAQ;gBAChB,GAAG,OAAO;aACX,CAAC;YAEF,0BAA0B;YAC1B,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACpB,OAAO,QAAQ,CAAC,IAAI,CAAC;aACtB;YAED,MAAM,UAAU,GAAQ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC,CAAC;YAEnF,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;SAC9D;QAAC,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,CAAC,IAAI,EAAE;gBACX,MAAM,IAAI,eAAe,CAAC,EAAE,CAAC,CAAC;aAC/B;YAED,MAAM,EAAE,CAAC;SACV;IACH,CAAC;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\";\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":";;AAAA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,UAAU,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAoB,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAG9C,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAMpE,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,CAAC,IAAI,CAAC;IACtB,CAAC;CACF;AAED;;GAEG;AAEH,IAAa,wBAAwB,gCAArC,MAAa,wBAAwB;IAEzB,QAAQ,CAAyB;IAGjC,GAAG,CAAsB;IAEnC,KAAK,CAAC,GAAG,CAAY,GAAY;QAC/B,IAAI;YACF,MAAM,EAAC,MAAM,EAAE,OAAO,GAAG,EAAE,EAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,0BAAwB,CAAC,CAAC;YAC1E,MAAM,QAAQ,GAA2B;gBACvC,GAAG,IAAI,CAAC,QAAQ;gBAChB,GAAG,OAAO;aACX,CAAC;YAEF,0BAA0B;YAC1B,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACpB,OAAO,QAAQ,CAAC,IAAI,CAAC;aACtB;YAED,MAAM,UAAU,GAAQ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC,CAAC;YAEnF,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;SAC9D;QAAC,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,CAAC,IAAI,EAAE;gBACX,MAAM,IAAI,eAAe,CAAC,EAAE,CAAC,CAAC;aAC/B;YAED,MAAM,EAAE,CAAC;SACV;IACH,CAAC;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 {Inject, Value} from \"@tsed/di\";\nimport {BadRequest} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\nimport type {MulterError} from \"multer\";\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() { }
@@ -32,20 +30,16 @@ export class FakeAdapter {
32
30
  multipart(options) {
33
31
  return {};
34
32
  }
35
- router(routerOptions) {
36
- const router = FakeAdapter.createFakeRawDriver();
37
- return {
38
- router,
39
- callback() {
40
- return router;
41
- }
42
- };
43
- }
44
33
  statics(endpoint, options) {
45
34
  return {};
46
35
  }
47
36
  bodyParser(type) {
48
37
  return () => { };
49
38
  }
39
+ mapLayers(layers) { }
40
+ mapHandler(handler) {
41
+ return handler;
42
+ }
43
+ useContext() { }
50
44
  }
51
45
  //# sourceMappingURL=FakeAdapter.js.map
@@ -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":"AAOA,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,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;IAED,SAAS,CAAC,MAAuB,IAAG,CAAC;IAErC,UAAU,CAAC,OAAgD;QACzD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,UAAU,KAAI,CAAC;CAChB","sourcesContent":["import {ProviderOpts} from \"@tsed/di\";\nimport {PlatformContextHandler, PlatformLayer} from \"@tsed/platform-router\";\nimport {PlatformMulter, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformStaticsOptions} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {PlatformContext} from \"../domain/PlatformContext\";\nimport {PlatformAdapter} from \"./PlatformAdapter\";\n\nexport class FakeAdapter implements PlatformAdapter<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 statics(endpoint: string, options: PlatformStaticsOptions): any {\n return {};\n }\n\n bodyParser(type: string): any {\n return () => {};\n }\n\n mapLayers(layers: PlatformLayer[]) {}\n\n mapHandler(handler: PlatformContextHandler<PlatformContext>) {\n return handler;\n }\n\n useContext() {}\n}\n"]}
@@ -1,125 +1,69 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
- import { Injectable, InjectorService, ProviderScope, ProviderType } from "@tsed/di";
3
- import { concatPath, getJsonEntityStore, getOperationsRoutes, JsonEntityStore } from "@tsed/schema";
4
- import { buildRouter, createRouter, getRouter } from "../builder/PlatformControllerBuilder.js";
5
- import { PlatformRouteDetails } from "../domain/PlatformRouteDetails.js";
2
+ import { Injectable, InjectorService, ProviderScope } from "@tsed/di";
3
+ import { PlatformRouters } from "@tsed/platform-router";
6
4
  import { PlatformApplication } from "./PlatformApplication.js";
7
- import { PlatformMiddlewaresChain } from "./PlatformMiddlewaresChain.js";
5
+ import { PlatformHandler } from "./PlatformHandler.js";
8
6
  /**
9
7
  * `Platform` is used to provide all routes collected by annotation `@Controller`.
10
8
  *
11
9
  * @platform
12
10
  */
13
11
  let Platform = class Platform {
14
- constructor(injector, platformApplication) {
12
+ injector;
13
+ platformApplication;
14
+ platformRouters;
15
+ #controllers = new Map();
16
+ constructor(injector, platformApplication, platformRouters) {
15
17
  this.injector = injector;
16
18
  this.platformApplication = platformApplication;
17
- this._routes = [];
18
- this._controllers = [];
19
- this.createRouters();
19
+ this.platformRouters = platformRouters;
20
+ platformRouters.prebuild();
20
21
  }
21
22
  get app() {
22
23
  return this.platformApplication;
23
24
  }
24
- get routes() {
25
- return this._routes;
26
- }
27
25
  addRoutes(routes) {
28
26
  routes.forEach((routeSettings) => {
29
27
  this.addRoute(routeSettings.route, routeSettings.token);
30
28
  });
31
29
  }
32
- addRoute(basePath, token) {
33
- const { injector } = this;
34
- const provider = injector.getProvider(token);
30
+ addRoute(route, token) {
31
+ const provider = this.injector.getProvider(token);
35
32
  if (!provider || provider.hasParent()) {
36
- return;
33
+ return this;
37
34
  }
38
- this._controllers.push(...this.getAllControllers(basePath, token));
39
- const ctrlPath = concatPath(basePath, JsonEntityStore.from(provider.token).path);
40
- this.app.use(ctrlPath, ...[].concat(getRouter(injector, provider).callback()));
41
- this._routes = getOperationsRoutes(provider.token, {
42
- withChildren: true,
43
- basePath
44
- }).reduce((routes, operationRoute) => {
45
- if (injector.hasProvider(token)) {
46
- const provider = injector.getProvider(operationRoute.token);
47
- const route = new PlatformRouteDetails({
48
- ...operationRoute,
49
- provider
50
- });
51
- routes = routes.concat(route);
52
- }
53
- return routes;
54
- }, this._routes);
35
+ const router = this.platformRouters.from(provider.token);
36
+ this.app.use(route, router);
55
37
  return this;
56
38
  }
57
- /**
58
- * Get all routes built by TsExpressDecorators and mounted on Express application.
59
- * @returns {PlatformRouteDetails[]}
60
- */
61
- getRoutes() {
62
- return this._routes;
39
+ getLayers() {
40
+ this.#controllers = new Map();
41
+ return this.platformRouters.getLayers(this.app).map((layer) => {
42
+ if (layer.isProvider()) {
43
+ this.#controllers.set(layer.provider.token, {
44
+ route: String(layer.path).split(layer.provider.path)[0],
45
+ provider: layer.provider
46
+ });
47
+ }
48
+ return layer;
49
+ });
63
50
  }
64
51
  /**
65
52
  * Get all controllers mounted on the application.
66
53
  * @returns {RouteController[]}
67
54
  */
68
55
  getMountedControllers() {
69
- return this._controllers;
70
- }
71
- $onInit() {
72
- this.buildControllers();
73
- }
74
- /**
75
- * Create routers from the collected controllers.
76
- * @private
77
- */
78
- createRouters() {
79
- const { injector } = this;
80
- injector.getProviders(ProviderType.CONTROLLER).map((provider) => {
81
- createRouter(injector, provider);
82
- });
83
- }
84
- /**
85
- * Get all router controllers from the controller token.
86
- * @private
87
- */
88
- getAllControllers(basePath, token) {
89
- const store = token.isStore ? token : getJsonEntityStore(token);
90
- const ctrlPath = concatPath(basePath, JsonEntityStore.from(token).path);
91
- const children = store.get("childrenControllers", []);
92
- return children
93
- .reduce((controllers, token) => {
94
- const childBasePath = concatPath(basePath, store.path);
95
- return controllers.concat(this.getAllControllers(childBasePath, token));
96
- }, [])
97
- .concat([
98
- {
99
- route: ctrlPath,
100
- provider: this.injector.getProvider(token)
101
- }
102
- ]);
103
- }
104
- /**
105
- * Create controllers from DI
106
- * @private
107
- */
108
- buildControllers() {
109
- const { injector } = this;
110
- injector.getProviders(ProviderType.CONTROLLER).map((provider) => {
111
- if (!provider.hasParent()) {
112
- return buildRouter(injector, provider);
113
- }
114
- });
56
+ return [...this.#controllers.values()];
115
57
  }
116
58
  };
117
59
  Platform = __decorate([
118
60
  Injectable({
119
61
  scope: ProviderScope.SINGLETON,
120
- imports: [PlatformMiddlewaresChain]
62
+ imports: [PlatformHandler]
121
63
  }),
122
- __metadata("design:paramtypes", [InjectorService, PlatformApplication])
64
+ __metadata("design:paramtypes", [InjectorService,
65
+ PlatformApplication,
66
+ PlatformRouters])
123
67
  ], Platform);
124
68
  export { Platform };
125
69
  //# sourceMappingURL=Platform.js.map