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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/jest.config.js +14 -0
  2. package/lib/cjs/builder/PlatformBuilder.js +83 -63
  3. package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
  4. package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -1
  5. package/lib/cjs/config/services/PlatformConfiguration.js +0 -70
  6. package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -1
  7. package/lib/cjs/decorators/params/error.js +1 -1
  8. package/lib/cjs/decorators/params/error.js.map +1 -1
  9. package/lib/cjs/domain/AnyToPromiseWithCtx.js +4 -5
  10. package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -1
  11. package/lib/cjs/domain/PlatformContext.js +82 -32
  12. package/lib/cjs/domain/PlatformContext.js.map +1 -1
  13. package/lib/cjs/domain/PlatformRouteDetails.js +0 -21
  14. package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -1
  15. package/lib/cjs/exports.js +1 -0
  16. package/lib/cjs/exports.js.map +1 -1
  17. package/lib/cjs/index.js +1 -7
  18. package/lib/cjs/index.js.map +1 -1
  19. package/lib/cjs/interfaces/Route.js.map +1 -1
  20. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +2 -1
  21. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  22. package/lib/cjs/middlewares/PlatformMulterMiddleware.js +2 -0
  23. package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -1
  24. package/lib/cjs/services/FakeAdapter.js +6 -12
  25. package/lib/cjs/services/FakeAdapter.js.map +1 -1
  26. package/lib/cjs/services/Platform.js +43 -85
  27. package/lib/cjs/services/Platform.js.map +1 -1
  28. package/lib/cjs/services/PlatformAdapter.js +10 -0
  29. package/lib/cjs/services/PlatformAdapter.js.map +1 -1
  30. package/lib/cjs/services/PlatformApplication.js +23 -9
  31. package/lib/cjs/services/PlatformApplication.js.map +1 -1
  32. package/lib/cjs/services/PlatformHandler.js +88 -161
  33. package/lib/cjs/services/PlatformHandler.js.map +1 -1
  34. package/lib/cjs/services/PlatformMiddlewaresChain.js +5 -19
  35. package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
  36. package/lib/cjs/services/PlatformRequest.js +17 -12
  37. package/lib/cjs/services/PlatformRequest.js.map +1 -1
  38. package/lib/cjs/services/PlatformResponse.js +20 -20
  39. package/lib/cjs/services/PlatformResponse.js.map +1 -1
  40. package/lib/cjs/services/PlatformTest.js +20 -8
  41. package/lib/cjs/services/PlatformTest.js.map +1 -1
  42. package/lib/cjs/utils/createContext.js +30 -21
  43. package/lib/cjs/utils/createContext.js.map +1 -1
  44. package/lib/cjs/utils/createHttpServer.js +3 -3
  45. package/lib/cjs/utils/createHttpServer.js.map +1 -1
  46. package/lib/cjs/utils/createHttpsServer.js +3 -3
  47. package/lib/cjs/utils/createHttpsServer.js.map +1 -1
  48. package/lib/cjs/utils/createInjector.js +6 -8
  49. package/lib/cjs/utils/createInjector.js.map +1 -1
  50. package/lib/cjs/utils/ensureContext.js +16 -0
  51. package/lib/cjs/utils/ensureContext.js.map +1 -0
  52. package/lib/cjs/utils/getConfiguration.js +2 -12
  53. package/lib/cjs/utils/getConfiguration.js.map +1 -1
  54. package/lib/cjs/utils/printRoutes.js +10 -8
  55. package/lib/cjs/utils/printRoutes.js.map +1 -1
  56. package/lib/cjs/utils/setResponseHeaders.js +7 -13
  57. package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
  58. package/lib/esm/builder/PlatformBuilder.js +60 -63
  59. package/lib/esm/builder/PlatformBuilder.js.map +1 -1
  60. package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -1
  61. package/lib/esm/config/services/PlatformConfiguration.js +0 -70
  62. package/lib/esm/config/services/PlatformConfiguration.js.map +1 -1
  63. package/lib/esm/decorators/params/error.js +1 -1
  64. package/lib/esm/decorators/params/error.js.map +1 -1
  65. package/lib/esm/domain/AnyToPromiseWithCtx.js +4 -5
  66. package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -1
  67. package/lib/esm/domain/PlatformContext.js +82 -32
  68. package/lib/esm/domain/PlatformContext.js.map +1 -1
  69. package/lib/esm/domain/PlatformRouteDetails.js +1 -19
  70. package/lib/esm/domain/PlatformRouteDetails.js.map +1 -1
  71. package/lib/esm/exports.js +1 -0
  72. package/lib/esm/exports.js.map +1 -1
  73. package/lib/esm/index.js +1 -7
  74. package/lib/esm/index.js.map +1 -1
  75. package/lib/esm/interfaces/Route.js.map +1 -1
  76. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +2 -1
  77. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  78. package/lib/esm/middlewares/PlatformMulterMiddleware.js +2 -0
  79. package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -1
  80. package/lib/esm/services/FakeAdapter.js +6 -12
  81. package/lib/esm/services/FakeAdapter.js.map +1 -1
  82. package/lib/esm/services/Platform.js +44 -86
  83. package/lib/esm/services/Platform.js.map +1 -1
  84. package/lib/esm/services/PlatformAdapter.js +10 -0
  85. package/lib/esm/services/PlatformAdapter.js.map +1 -1
  86. package/lib/esm/services/PlatformApplication.js +23 -9
  87. package/lib/esm/services/PlatformApplication.js.map +1 -1
  88. package/lib/esm/services/PlatformHandler.js +90 -163
  89. package/lib/esm/services/PlatformHandler.js.map +1 -1
  90. package/lib/esm/services/PlatformMiddlewaresChain.js +5 -19
  91. package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
  92. package/lib/esm/services/PlatformRequest.js +17 -12
  93. package/lib/esm/services/PlatformRequest.js.map +1 -1
  94. package/lib/esm/services/PlatformResponse.js +20 -20
  95. package/lib/esm/services/PlatformResponse.js.map +1 -1
  96. package/lib/esm/services/PlatformTest.js +20 -8
  97. package/lib/esm/services/PlatformTest.js.map +1 -1
  98. package/lib/esm/utils/createContext.js +28 -20
  99. package/lib/esm/utils/createContext.js.map +1 -1
  100. package/lib/esm/utils/createHttpServer.js +3 -3
  101. package/lib/esm/utils/createHttpServer.js.map +1 -1
  102. package/lib/esm/utils/createHttpsServer.js +3 -3
  103. package/lib/esm/utils/createHttpsServer.js.map +1 -1
  104. package/lib/esm/utils/createInjector.js +7 -9
  105. package/lib/esm/utils/createInjector.js.map +1 -1
  106. package/lib/esm/utils/ensureContext.js +12 -0
  107. package/lib/esm/utils/ensureContext.js.map +1 -0
  108. package/lib/esm/utils/getConfiguration.js +4 -14
  109. package/lib/esm/utils/getConfiguration.js.map +1 -1
  110. package/lib/esm/utils/printRoutes.js +10 -8
  111. package/lib/esm/utils/printRoutes.js.map +1 -1
  112. package/lib/esm/utils/setResponseHeaders.js +7 -13
  113. package/lib/esm/utils/setResponseHeaders.js.map +1 -1
  114. package/lib/types/builder/PlatformBuilder.d.ts +17 -16
  115. package/lib/types/config/interfaces/PlatformLoggerSettings.d.ts +2 -43
  116. package/lib/types/config/services/PlatformConfiguration.d.ts +1 -22
  117. package/lib/types/domain/AnyToPromiseWithCtx.d.ts +1 -9
  118. package/lib/types/domain/PlatformContext.d.ts +36 -15
  119. package/lib/types/domain/PlatformRouteDetails.d.ts +4 -19
  120. package/lib/types/exports.d.ts +1 -0
  121. package/lib/types/index.d.ts +1 -7
  122. package/lib/types/interfaces/Route.d.ts +2 -3
  123. package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +1 -1
  124. package/lib/types/services/FakeAdapter.d.ts +7 -6
  125. package/lib/types/services/Platform.d.ts +11 -28
  126. package/lib/types/services/PlatformAdapter.d.ts +19 -10
  127. package/lib/types/services/PlatformApplication.d.ts +14 -6
  128. package/lib/types/services/PlatformHandler.d.ts +19 -55
  129. package/lib/types/services/PlatformMiddlewaresChain.d.ts +1 -2
  130. package/lib/types/services/PlatformRequest.d.ts +8 -9
  131. package/lib/types/services/PlatformResponse.d.ts +10 -13
  132. package/lib/types/services/PlatformTest.d.ts +4 -3
  133. package/lib/types/utils/createContext.d.ts +4 -1
  134. package/lib/types/utils/createHttpsServer.d.ts +1 -0
  135. package/lib/types/utils/createInjector.d.ts +2 -2
  136. package/lib/types/utils/ensureContext.d.ts +2 -0
  137. package/lib/types/utils/listenServer.d.ts +2 -0
  138. package/package.json +23 -21
  139. package/lib/cjs/builder/PlatformControllerBuilder.js +0 -82
  140. package/lib/cjs/builder/PlatformControllerBuilder.js.map +0 -1
  141. package/lib/cjs/domain/ControllerProvider.js +0 -51
  142. package/lib/cjs/domain/ControllerProvider.js.map +0 -1
  143. package/lib/cjs/domain/HandlerMetadata.js +0 -57
  144. package/lib/cjs/domain/HandlerMetadata.js.map +0 -1
  145. package/lib/cjs/middlewares/__mock__/FakeCtrl.js +0 -12
  146. package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +0 -1
  147. package/lib/cjs/middlewares/bindEndpointMiddleware.js +0 -13
  148. package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +0 -1
  149. package/lib/cjs/services/PlatformRouter.js +0 -108
  150. package/lib/cjs/services/PlatformRouter.js.map +0 -1
  151. package/lib/cjs/utils/__mock__/Test1.js +0 -8
  152. package/lib/cjs/utils/__mock__/Test1.js.map +0 -1
  153. package/lib/cjs/utils/__mock__/Test2.js +0 -8
  154. package/lib/cjs/utils/__mock__/Test2.js.map +0 -1
  155. package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js +0 -12
  156. package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js.map +0 -1
  157. package/lib/cjs/utils/__mock__/module1/Module1.js +0 -19
  158. package/lib/cjs/utils/__mock__/module1/Module1.js.map +0 -1
  159. package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js +0 -17
  160. package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js.map +0 -1
  161. package/lib/cjs/utils/__mock__/module1/services/M1Service.js +0 -17
  162. package/lib/cjs/utils/__mock__/module1/services/M1Service.js.map +0 -1
  163. package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js +0 -15
  164. package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js.map +0 -1
  165. package/lib/cjs/utils/__mock__/module1/submodule/SubService.js +0 -12
  166. package/lib/cjs/utils/__mock__/module1/submodule/SubService.js.map +0 -1
  167. package/lib/cjs/utils/__mock__/module2/Module2.js +0 -18
  168. package/lib/cjs/utils/__mock__/module2/Module2.js.map +0 -1
  169. package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js +0 -12
  170. package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js.map +0 -1
  171. package/lib/cjs/utils/createHandlerMetadata.js +0 -49
  172. package/lib/cjs/utils/createHandlerMetadata.js.map +0 -1
  173. package/lib/cjs/utils/useCtxHandler.js +0 -15
  174. package/lib/cjs/utils/useCtxHandler.js.map +0 -1
  175. package/lib/esm/builder/PlatformControllerBuilder.js +0 -76
  176. package/lib/esm/builder/PlatformControllerBuilder.js.map +0 -1
  177. package/lib/esm/domain/ControllerProvider.js +0 -47
  178. package/lib/esm/domain/ControllerProvider.js.map +0 -1
  179. package/lib/esm/domain/HandlerMetadata.js +0 -53
  180. package/lib/esm/domain/HandlerMetadata.js.map +0 -1
  181. package/lib/esm/middlewares/__mock__/FakeCtrl.js +0 -9
  182. package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +0 -1
  183. package/lib/esm/middlewares/bindEndpointMiddleware.js +0 -9
  184. package/lib/esm/middlewares/bindEndpointMiddleware.js.map +0 -1
  185. package/lib/esm/services/PlatformRouter.js +0 -105
  186. package/lib/esm/services/PlatformRouter.js.map +0 -1
  187. package/lib/esm/utils/__mock__/Test1.js +0 -4
  188. package/lib/esm/utils/__mock__/Test1.js.map +0 -1
  189. package/lib/esm/utils/__mock__/Test2.js +0 -4
  190. package/lib/esm/utils/__mock__/Test2.js.map +0 -1
  191. package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js +0 -9
  192. package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js.map +0 -1
  193. package/lib/esm/utils/__mock__/module1/Module1.js +0 -16
  194. package/lib/esm/utils/__mock__/module1/Module1.js.map +0 -1
  195. package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js +0 -14
  196. package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js.map +0 -1
  197. package/lib/esm/utils/__mock__/module1/services/M1Service.js +0 -14
  198. package/lib/esm/utils/__mock__/module1/services/M1Service.js.map +0 -1
  199. package/lib/esm/utils/__mock__/module1/submodule/SubModule.js +0 -12
  200. package/lib/esm/utils/__mock__/module1/submodule/SubModule.js.map +0 -1
  201. package/lib/esm/utils/__mock__/module1/submodule/SubService.js +0 -9
  202. package/lib/esm/utils/__mock__/module1/submodule/SubService.js.map +0 -1
  203. package/lib/esm/utils/__mock__/module2/Module2.js +0 -15
  204. package/lib/esm/utils/__mock__/module2/Module2.js.map +0 -1
  205. package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js +0 -9
  206. package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js.map +0 -1
  207. package/lib/esm/utils/createHandlerMetadata.js +0 -45
  208. package/lib/esm/utils/createHandlerMetadata.js.map +0 -1
  209. package/lib/esm/utils/useCtxHandler.js +0 -11
  210. package/lib/esm/utils/useCtxHandler.js.map +0 -1
  211. package/lib/types/builder/PlatformControllerBuilder.d.ts +0 -18
  212. package/lib/types/domain/ControllerProvider.d.ts +0 -24
  213. package/lib/types/domain/HandlerMetadata.d.ts +0 -32
  214. package/lib/types/middlewares/__mock__/FakeCtrl.d.ts +0 -2
  215. package/lib/types/middlewares/bindEndpointMiddleware.d.ts +0 -6
  216. package/lib/types/services/PlatformRouter.d.ts +0 -51
  217. package/lib/types/utils/__mock__/Test1.d.ts +0 -3
  218. package/lib/types/utils/__mock__/Test2.d.ts +0 -3
  219. package/lib/types/utils/__mock__/controllers/rest/TestCtrl.d.ts +0 -2
  220. package/lib/types/utils/__mock__/module1/Module1.d.ts +0 -2
  221. package/lib/types/utils/__mock__/module1/controllers/M1Ctrl1.d.ts +0 -5
  222. package/lib/types/utils/__mock__/module1/services/M1Service.d.ts +0 -5
  223. package/lib/types/utils/__mock__/module1/submodule/SubModule.d.ts +0 -2
  224. package/lib/types/utils/__mock__/module1/submodule/SubService.d.ts +0 -2
  225. package/lib/types/utils/__mock__/module2/Module2.d.ts +0 -2
  226. package/lib/types/utils/__mock__/module2/controllers/M2Ctrl.d.ts +0 -2
  227. package/lib/types/utils/createHandlerMetadata.d.ts +0 -8
  228. package/lib/types/utils/useCtxHandler.d.ts +0 -13
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildRouter = exports.createRouter = exports.getRouter = void 0;
4
- const di_1 = require("@tsed/di");
5
- const schema_1 = require("@tsed/schema");
6
- const ControllerProvider_1 = require("../domain/ControllerProvider");
7
- const PlatformRouter_1 = require("../services/PlatformRouter");
8
- const PlatformMiddlewaresChain_1 = require("../services/PlatformMiddlewaresChain");
9
- di_1.GlobalProviders.createRegistry(di_1.ProviderType.CONTROLLER, ControllerProvider_1.ControllerProvider, {
10
- onInvoke(provider, locals, { injector }) {
11
- const router = createRouter(injector, provider);
12
- locals.set(PlatformRouter_1.PlatformRouter, router);
13
- }
14
- });
15
- /**
16
- * @ignore
17
- */
18
- function formatMethod(method) {
19
- return (method === schema_1.OperationMethods.CUSTOM ? "use" : method || "use").toLowerCase();
20
- }
21
- /**
22
- * @ignore
23
- */
24
- function getRouter(injector, provider) {
25
- return injector.get(provider.tokenRouter);
26
- }
27
- exports.getRouter = getRouter;
28
- /**
29
- * @ignore
30
- */
31
- function createRouter(injector, provider) {
32
- const token = provider.tokenRouter;
33
- if (injector.has(token)) {
34
- return getRouter(injector, provider);
35
- }
36
- const router = PlatformRouter_1.PlatformRouter.create(injector, provider.routerOptions);
37
- return injector
38
- .add(token, {
39
- useValue: router
40
- })
41
- .invoke(token);
42
- }
43
- exports.createRouter = createRouter;
44
- /**
45
- * @ignore
46
- * @param injector
47
- * @param provider
48
- * @param parentUseBefore
49
- */
50
- function buildRouter(injector, provider, parentUseBefore = []) {
51
- const { middlewares: { useBefore }, children } = provider;
52
- // Controller lifecycle
53
- const router = createRouter(injector, provider);
54
- if (!router.isBuilt) {
55
- router.isBuilt = true;
56
- const platformMiddlewaresChain = injector.get(PlatformMiddlewaresChain_1.PlatformMiddlewaresChain);
57
- // build all endpoints and his middlewares
58
- (0, schema_1.getOperationsRoutes)(provider.token).forEach((operationRoute) => {
59
- const handlers = platformMiddlewaresChain === null || platformMiddlewaresChain === void 0 ? void 0 : platformMiddlewaresChain.get(provider, operationRoute, parentUseBefore);
60
- router.addRoute({
61
- handlers,
62
- token: operationRoute.token,
63
- method: formatMethod(operationRoute.method),
64
- path: operationRoute.path,
65
- isFinal: operationRoute.isFinal
66
- });
67
- });
68
- const middlewares = [...parentUseBefore, ...useBefore];
69
- // build children controllers
70
- children.forEach((child) => {
71
- const childProvider = injector.getProvider(child);
72
- /* istanbul ignore next */
73
- if (!childProvider) {
74
- throw new Error("Controller component not found in the ControllerRegistry");
75
- }
76
- router.use(childProvider.path, buildRouter(injector, childProvider, middlewares));
77
- });
78
- }
79
- return router;
80
- }
81
- exports.buildRouter = buildRouter;
82
- //# sourceMappingURL=PlatformControllerBuilder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformControllerBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformControllerBuilder.ts"],"names":[],"mappings":";;;AACA,iCAAwE;AACxE,yCAAmE;AACnE,qEAAgE;AAChE,+DAA0D;AAC1D,mFAA8E;AAE9E,oBAAe,CAAC,cAAc,CAAC,iBAAY,CAAC,UAAU,EAAE,uCAAkB,EAAE;IAC1E,QAAQ,CAAC,QAA4B,EAAE,MAAW,EAAE,EAAC,QAAQ,EAAC;QAC5D,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,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,GAAG,QAAQ,CAAC,GAAG,CAA2B,mDAAwB,CAAC,CAAC;QAElG,0CAA0C;QAC1C,IAAA,4BAAmB,EAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE;YAC7D,MAAM,QAAQ,GAAG,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAE,GAAG,CAAC,QAAQ,EAAE,cAAc,EAAE,eAAe,CAAC,CAAC;YAE1F,MAAM,CAAC,QAAQ,CAAC;gBACd,QAAQ;gBACR,KAAK,EAAE,cAAc,CAAC,KAAK;gBAC3B,MAAM,EAAE,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC;gBAC3C,IAAI,EAAE,cAAc,CAAC,IAAI;gBACzB,OAAO,EAAE,cAAc,CAAC,OAAO;aAChC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,WAAW,GAAU,CAAC,GAAG,eAAe,EAAE,GAAG,SAAS,CAAC,CAAC;QAC9D,6BAA6B;QAC7B,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAgB,EAAE,EAAE;YACpC,MAAM,aAAa,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAuB,CAAC;YAExE,0BAA0B;YAC1B,IAAI,CAAC,aAAa,EAAE;gBAClB,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;aAC7E;YAED,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;QACpF,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA1CD,kCA0CC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {GlobalProviders, InjectorService, ProviderType} from \"@tsed/di\";\nimport {getOperationsRoutes, OperationMethods} from \"@tsed/schema\";\nimport {ControllerProvider} from \"../domain/ControllerProvider\";\nimport {PlatformRouter} from \"../services/PlatformRouter\";\nimport {PlatformMiddlewaresChain} from \"../services/PlatformMiddlewaresChain\";\n\nGlobalProviders.createRegistry(ProviderType.CONTROLLER, ControllerProvider, {\n onInvoke(provider: ControllerProvider, locals: any, {injector}) {\n const router = createRouter(injector, provider);\n locals.set(PlatformRouter, router);\n }\n});\n\n/**\n * @ignore\n */\nfunction formatMethod(method: string | undefined) {\n return (method === OperationMethods.CUSTOM ? \"use\" : method || \"use\").toLowerCase();\n}\n\n/**\n * @ignore\n */\nexport function getRouter(injector: InjectorService, provider: ControllerProvider) {\n return injector.get(provider.tokenRouter)!;\n}\n\n/**\n * @ignore\n */\nexport function createRouter(injector: InjectorService, provider: ControllerProvider): PlatformRouter {\n const token = provider.tokenRouter;\n\n if (injector.has(token)) {\n return getRouter(injector, provider);\n }\n\n const router = PlatformRouter.create(injector, provider.routerOptions);\n\n return injector\n .add(token, {\n useValue: router\n })\n .invoke<PlatformRouter>(token);\n}\n\n/**\n * @ignore\n * @param injector\n * @param provider\n * @param parentUseBefore\n */\nexport function buildRouter(injector: InjectorService, provider: ControllerProvider, parentUseBefore: any[] = []) {\n const {\n middlewares: {useBefore},\n children\n } = provider;\n\n // Controller lifecycle\n const router = createRouter(injector, provider);\n\n if (!router.isBuilt) {\n router.isBuilt = true;\n\n const platformMiddlewaresChain = injector.get<PlatformMiddlewaresChain>(PlatformMiddlewaresChain);\n\n // build all endpoints and his middlewares\n getOperationsRoutes(provider.token).forEach((operationRoute) => {\n const handlers = platformMiddlewaresChain?.get(provider, operationRoute, parentUseBefore);\n\n router.addRoute({\n handlers,\n token: operationRoute.token,\n method: formatMethod(operationRoute.method),\n path: operationRoute.path,\n isFinal: operationRoute.isFinal\n });\n });\n\n const middlewares: any[] = [...parentUseBefore, ...useBefore];\n // build children controllers\n children.forEach((child: Type<any>) => {\n const childProvider = injector.getProvider(child) as ControllerProvider;\n\n /* istanbul ignore next */\n if (!childProvider) {\n throw new Error(\"Controller component not found in the ControllerRegistry\");\n }\n\n router.use(childProvider.path, buildRouter(injector, childProvider, middlewares));\n });\n }\n\n return router;\n}\n"]}
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ControllerProvider = void 0;
4
- const di_1 = require("@tsed/di");
5
- const routerOptions_1 = require("../constants/routerOptions");
6
- let AUTO_INC = 0;
7
- class ControllerProvider extends di_1.Provider {
8
- constructor(provide, options = {}) {
9
- super(provide, options);
10
- this.type = di_1.ProviderType.CONTROLLER;
11
- this.tokenRouter = `${this.name}_ROUTER_${AUTO_INC++}`;
12
- }
13
- /**
14
- *
15
- */
16
- get routerOptions() {
17
- return this.store.get(routerOptions_1.ROUTER_OPTIONS) || {};
18
- }
19
- /**
20
- *
21
- * @param value
22
- */
23
- set routerOptions(value) {
24
- this.store.set(routerOptions_1.ROUTER_OPTIONS, value);
25
- }
26
- /**
27
- *
28
- * @returns {any[]}
29
- */
30
- get middlewares() {
31
- return Object.assign({
32
- use: [],
33
- useAfter: [],
34
- useBefore: []
35
- }, this.store.get("middlewares", {}));
36
- }
37
- /**
38
- *
39
- * @param middlewares
40
- */
41
- set middlewares(middlewares) {
42
- const mdlwrs = this.middlewares;
43
- const concat = (key, a, b) => (a[key] = a[key].concat(b[key]));
44
- Object.keys(middlewares).forEach((key) => {
45
- concat(key, mdlwrs, middlewares);
46
- });
47
- this.store.set("middlewares", mdlwrs);
48
- }
49
- }
50
- exports.ControllerProvider = ControllerProvider;
51
- //# sourceMappingURL=ControllerProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ControllerProvider.js","sourceRoot":"","sources":["../../../src/domain/ControllerProvider.ts"],"names":[],"mappings":";;;AAAA,iCAAsF;AACtF,8DAA0D;AAE1D,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB,MAAa,kBAA4B,SAAQ,aAAW;IAG1D,YAAY,OAAsB,EAAE,UAA6B,EAAE;QACjE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI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@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,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HandlerMetadata = void 0;
4
- const core_1 = require("@tsed/core");
5
- const di_1 = require("@tsed/di");
6
- const platform_params_1 = require("@tsed/platform-params");
7
- const schema_1 = require("@tsed/schema");
8
- const HandlerType_1 = require("../interfaces/HandlerType");
9
- class HandlerMetadata {
10
- constructor(options) {
11
- this.injectable = false;
12
- this.type = HandlerType_1.HandlerType.RAW_FN;
13
- this.hasNextFunction = false;
14
- const { target, token, propertyKey, type, scope, routeOptions } = options;
15
- this.type = type || target.type || HandlerType_1.HandlerType.RAW_FN;
16
- this.scope = scope || di_1.ProviderScope.SINGLETON;
17
- this.routeOptions = routeOptions || {};
18
- const handler = propertyKey ? target.prototype[propertyKey] : target;
19
- if (propertyKey) {
20
- this.target = target;
21
- this.token = token;
22
- this.propertyKey = propertyKey;
23
- this.hasNextFunction = this.hasParamType(platform_params_1.ParamTypes.NEXT_FN);
24
- if (this.hasParamType(platform_params_1.ParamTypes.ERR)) {
25
- this.type = HandlerType_1.HandlerType.ERR_MIDDLEWARE;
26
- }
27
- this.injectable = schema_1.JsonParameterStore.getParams(target, propertyKey).length > 0;
28
- }
29
- else {
30
- this.handler = handler;
31
- }
32
- if (!this.injectable) {
33
- if (handler.length === 4) {
34
- this.type = HandlerType_1.HandlerType.RAW_ERR_FN;
35
- }
36
- this.hasNextFunction = handler.length >= 3;
37
- }
38
- }
39
- get hasErrorParam() {
40
- return this.type === HandlerType_1.HandlerType.ERR_MIDDLEWARE || this.type === HandlerType_1.HandlerType.RAW_ERR_FN;
41
- }
42
- getParams() {
43
- return schema_1.JsonParameterStore.getParams(this.target, this.propertyKey) || [];
44
- }
45
- hasParamType(paramType) {
46
- return this.getParams().findIndex((p) => p.paramType === paramType) > -1;
47
- }
48
- isFinal() {
49
- var _a;
50
- return ((_a = this.routeOptions) === null || _a === void 0 ? void 0 : _a.isFinal) || false;
51
- }
52
- toString() {
53
- return [this.target && (0, core_1.nameOf)(this.target), this.propertyKey].filter(Boolean).join(".");
54
- }
55
- }
56
- exports.HandlerMetadata = HandlerMetadata;
57
- //# sourceMappingURL=HandlerMetadata.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HandlerMetadata.js","sourceRoot":"","sources":["../../../src/domain/HandlerMetadata.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AACxC,iCAAuC;AACvC,2DAAiD;AACjD,yCAAgD;AAChD,2DAAsD;AAYtD,MAAa,eAAe;IAY1B,YAAY,OAA+B;QARlC,eAAU,GAAY,KAAK,CAAC;QAC5B,SAAI,GAAgB,yBAAW,CAAC,MAAM,CAAC;QACvC,oBAAe,GAAY,KAAK,CAAC;QAOxC,MAAM,EAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EA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,IAAI,KAAK,yBAAW,CAAC,UAAU,CAAC;IAC1F,CAAC;IAEM,SAAS;QACd,OAAO,2BAAkB,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,IAAA,aAAM,EAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1F,CAAC;CACF;AA9DD,0CA8DC","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,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FakeCtrl = void 0;
4
- const tslib_1 = require("tslib");
5
- const di_1 = require("@tsed/di");
6
- let FakeCtrl = class FakeCtrl {
7
- };
8
- FakeCtrl = tslib_1.__decorate([
9
- (0, di_1.Controller)("/")
10
- ], FakeCtrl);
11
- exports.FakeCtrl = FakeCtrl;
12
- //# sourceMappingURL=FakeCtrl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FakeCtrl.js","sourceRoot":"","sources":["../../../../src/middlewares/__mock__/FakeCtrl.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AAGpC,IAAa,QAAQ,GAArB,MAAa,QAAQ;CAAG,CAAA;AAAX,QAAQ;IADpB,IAAA,eAAU,EAAC,GAAG,CAAC;GACH,QAAQ,CAAG;AAAX,4BAAQ","sourcesContent":["import {Controller} from \"@tsed/di\";\n\n@Controller(\"/\")\nexport class FakeCtrl {}\n"]}
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bindEndpointMiddleware = void 0;
4
- /**
5
- * @ignore
6
- */
7
- function bindEndpointMiddleware(endpoint) {
8
- return (ctx) => {
9
- ctx.endpoint = endpoint;
10
- };
11
- }
12
- exports.bindEndpointMiddleware = bindEndpointMiddleware;
13
- //# sourceMappingURL=bindEndpointMiddleware.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bindEndpointMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/bindEndpointMiddleware.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,SAAgB,sBAAsB,CAAC,QAA0B;IAC/D,OAAO,CAAC,GAAoB,EAAE,EAAE;QAC9B,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC;AAJD,wDAIC","sourcesContent":["import type {EndpointMetadata} from \"../domain/EndpointMetadata\";\nimport type {PlatformContext} from \"../domain/PlatformContext\";\n\n/**\n * @ignore\n */\nexport function bindEndpointMiddleware(endpoint: EndpointMetadata) {\n return (ctx: PlatformContext) => {\n ctx.endpoint = endpoint;\n };\n}\n"]}
@@ -1,108 +0,0 @@
1
- "use strict";
2
- var PlatformRouter_1;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.PlatformRouter = exports.PLATFORM_ROUTER_OPTIONS = void 0;
5
- const tslib_1 = require("tslib");
6
- const di_1 = require("@tsed/di");
7
- const PlatformHandler_1 = require("./PlatformHandler");
8
- const PlatformAdapter_1 = require("./PlatformAdapter");
9
- /**
10
- * @ignore
11
- */
12
- exports.PLATFORM_ROUTER_OPTIONS = Symbol.for("PlatformRouterOptions");
13
- /**
14
- * Platform Router abstraction layer.
15
- * @platform
16
- */
17
- let PlatformRouter = PlatformRouter_1 = class PlatformRouter {
18
- constructor(platformHandler, adapter, routerOptions = {}) {
19
- this.platformHandler = platformHandler;
20
- this.adapter = adapter;
21
- this.isBuilt = false;
22
- const { router, callback } = adapter.router(routerOptions);
23
- this.rawRouter = this.raw = router;
24
- this.callback = callback;
25
- }
26
- /**
27
- * Create a new instance of PlatformRouter
28
- * @param injector
29
- * @param routerOptions
30
- */
31
- static create(injector, routerOptions = {}) {
32
- const locals = new Map();
33
- locals.set(exports.PLATFORM_ROUTER_OPTIONS, routerOptions);
34
- return injector.invoke(PlatformRouter_1, locals);
35
- }
36
- getRouter() {
37
- return this.rawRouter;
38
- }
39
- use(...handlers) {
40
- // @ts-ignore
41
- this.getRouter().use(...this.mapHandlers(handlers));
42
- return this;
43
- }
44
- addRoute(options) {
45
- const { method, path, handlers, ...opts } = options;
46
- // @ts-ignore
47
- this.getRouter()[method](path, ...this.mapHandlers(handlers, { method, path, ...opts }));
48
- return this;
49
- }
50
- all(path, ...handlers) {
51
- return this.addRoute({ method: "all", path, handlers, isFinal: true });
52
- }
53
- get(path, ...handlers) {
54
- return this.addRoute({ method: "get", path, handlers, isFinal: true });
55
- }
56
- post(path, ...handlers) {
57
- return this.addRoute({ method: "post", path, handlers, isFinal: true });
58
- }
59
- put(path, ...handlers) {
60
- return this.addRoute({ method: "put", path, handlers, isFinal: true });
61
- }
62
- delete(path, ...handlers) {
63
- return this.addRoute({ method: "delete", path, handlers, isFinal: true });
64
- }
65
- patch(path, ...handlers) {
66
- return this.addRoute({ method: "patch", path, handlers, isFinal: true });
67
- }
68
- head(path, ...handlers) {
69
- return this.addRoute({ method: "head", path, handlers, isFinal: true });
70
- }
71
- options(path, ...handlers) {
72
- return this.addRoute({ method: "options", path, handlers, isFinal: true });
73
- }
74
- statics(path, options) {
75
- return this.use(path, this.adapter.statics(path, options));
76
- }
77
- multer(options) {
78
- return this.adapter.multipart(options);
79
- }
80
- mapHandlers(handlers, options = {}) {
81
- return handlers.reduce((list, handler, index) => {
82
- if (typeof handler === "string") {
83
- return list.concat(handler);
84
- }
85
- if (handler instanceof PlatformRouter_1) {
86
- return list.concat(handler.callback());
87
- }
88
- return list.concat(this.platformHandler.createHandler(handler, {
89
- ...options,
90
- isFinal: options.isFinal ? index === handlers.length - 1 : false
91
- }));
92
- }, []);
93
- }
94
- };
95
- tslib_1.__decorate([
96
- (0, di_1.Inject)(),
97
- tslib_1.__metadata("design:type", di_1.InjectorService)
98
- ], PlatformRouter.prototype, "injector", void 0);
99
- PlatformRouter = PlatformRouter_1 = tslib_1.__decorate([
100
- (0, di_1.Injectable)({
101
- scope: di_1.ProviderScope.INSTANCE
102
- }),
103
- tslib_1.__param(2, (0, di_1.Inject)(exports.PLATFORM_ROUTER_OPTIONS)),
104
- tslib_1.__metadata("design:paramtypes", [PlatformHandler_1.PlatformHandler,
105
- PlatformAdapter_1.PlatformAdapter, Object])
106
- ], PlatformRouter);
107
- exports.PlatformRouter = PlatformRouter;
108
- //# sourceMappingURL=PlatformRouter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformRouter.js","sourceRoot":"","sources":["../../../src/services/PlatformRouter.ts"],"names":[],"mappings":";;;;;AAAA,iCAAsF;AACtF,uDAAkD;AAIlD,uDAAkD;AAGlD;;GAEG;AACU,QAAA,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAS3E;;;GAGG;AAIH,IAAa,cAAc,sBAA3B,MAAa,cAAc;IAUzB,YACY,eAAgC,EACjC,OAAqC,EACb,gBAAwC,EAAE;QAFjE,oBAAe,GAAf,eAAe,CAAiB;QACjC,YAAO,GAAP,OAAO,CAA8B;QAThD,YAAO,GAAY,KAAK,CAAC;QAYvB,MAAM,EAAC,MAAM,EAAE,QAAQ,EAAC,GAAG,OAAO,CAAC,MA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import {PlatformHandler} from \"./PlatformHandler\";\nimport {PlatformRouteOptions, PlatformRouteWithoutHandlers} from \"../interfaces/PlatformRouteOptions\";\nimport {PlatformStaticsOptions} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {PlatformMulter, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformAdapter} from \"./PlatformAdapter\";\nimport {RouterOptions} from \"express\";\n\n/**\n * @ignore\n */\nexport const PLATFORM_ROUTER_OPTIONS = Symbol.for(\"PlatformRouterOptions\");\n\ndeclare global {\n namespace TsED {\n // @ts-ignore\n export interface Router {}\n }\n}\n\n/**\n * Platform Router abstraction layer.\n * @platform\n */\n@Injectable({\n scope: ProviderScope.INSTANCE\n})\nexport class PlatformRouter<App = TsED.Application, Router = TsED.Router> {\n rawRouter: Router;\n raw: any;\n isBuilt: boolean = false;\n\n @Inject()\n injector: InjectorService;\n\n callback: () => any;\n\n constructor(\n protected platformHandler: PlatformHandler,\n readonly adapter: PlatformAdapter<App, Router>,\n @Inject(PLATFORM_ROUTER_OPTIONS) routerOptions: Partial<RouterOptions> = {}\n ) {\n const {router, callback} = adapter.router(routerOptions);\n\n this.rawRouter = this.raw = router;\n this.callback = callback;\n }\n\n /**\n * Create a new instance of PlatformRouter\n * @param injector\n * @param routerOptions\n */\n static create(injector: InjectorService, routerOptions: any = {}) {\n const locals = new Map();\n locals.set(PLATFORM_ROUTER_OPTIONS, routerOptions);\n\n return injector.invoke<PlatformRouter>(PlatformRouter, locals);\n }\n\n getRouter(): Router {\n return this.rawRouter;\n }\n\n use(...handlers: any[]) {\n // @ts-ignore\n this.getRouter().use(...this.mapHandlers(handlers));\n\n return this;\n }\n\n addRoute(options: Partial<PlatformRouteOptions>) {\n const {method, path, handlers, ...opts} = options;\n\n // @ts-ignore\n this.getRouter()[method](path, ...this.mapHandlers(handlers, {method, path, ...opts}));\n\n return this;\n }\n\n all(path: PathType, ...handlers: any[]) {\n return this.addRoute({method: \"all\", path, handlers, isFinal: true});\n }\n\n get(path: PathType, ...handlers: any[]) {\n return this.addRoute({method: \"get\", path, handlers, isFinal: true});\n }\n\n post(path: PathType, ...handlers: any[]) {\n return this.addRoute({method: \"post\", path, handlers, isFinal: true});\n }\n\n put(path: PathType, ...handlers: any[]) {\n return this.addRoute({method: \"put\", path, handlers, isFinal: true});\n }\n\n delete(path: PathType, ...handlers: any[]) {\n return this.addRoute({method: \"delete\", path, handlers, isFinal: true});\n }\n\n patch(path: PathType, ...handlers: any[]) {\n return this.addRoute({method: \"patch\", path, handlers, isFinal: true});\n }\n\n head(path: PathType, ...handlers: any[]) {\n return this.addRoute({method: \"head\", path, handlers, isFinal: true});\n }\n\n options(path: PathType, ...handlers: any[]) {\n return this.addRoute({method: \"options\", path, handlers, isFinal: true});\n }\n\n statics(path: string, options: PlatformStaticsOptions) {\n return this.use(path, this.adapter.statics(path, options));\n }\n\n multer(options: PlatformMulterSettings): PlatformMulter {\n return this.adapter.multipart(options);\n }\n\n protected mapHandlers(handlers: any[], options: PlatformRouteWithoutHandlers = {}): any[] {\n return handlers.reduce((list, handler, index) => {\n if (typeof handler === \"string\") {\n return list.concat(handler);\n }\n\n if (handler instanceof PlatformRouter) {\n return list.concat(handler.callback());\n }\n\n return list.concat(\n this.platformHandler.createHandler(handler, {\n ...options,\n isFinal: options.isFinal ? index === handlers.length - 1 : false\n })\n );\n }, []);\n }\n}\n"]}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Test1 = exports.value1 = void 0;
4
- exports.value1 = "value";
5
- class Test1 {
6
- }
7
- exports.Test1 = Test1;
8
- //# sourceMappingURL=Test1.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Test1.js","sourceRoot":"","sources":["../../../../src/utils/__mock__/Test1.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG,OAAO,CAAC;AAE9B,MAAa,KAAK;CAAG;AAArB,sBAAqB","sourcesContent":["export const value1 = \"value\";\n\nexport class Test1 {}\n"]}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Test2 = exports.value2 = void 0;
4
- exports.value2 = "value";
5
- class Test2 {
6
- }
7
- exports.Test2 = Test2;
8
- //# sourceMappingURL=Test2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Test2.js","sourceRoot":"","sources":["../../../../src/utils/__mock__/Test2.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG,OAAO,CAAC;AAE9B,MAAa,KAAK;CAAG;AAArB,sBAAqB","sourcesContent":["export const value2 = \"value\";\n\nexport class Test2 {}\n"]}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TestCtrl = void 0;
4
- const tslib_1 = require("tslib");
5
- const di_1 = require("@tsed/di");
6
- let TestCtrl = class TestCtrl {
7
- };
8
- TestCtrl = tslib_1.__decorate([
9
- (0, di_1.Controller)("/root")
10
- ], TestCtrl);
11
- exports.TestCtrl = TestCtrl;
12
- //# sourceMappingURL=TestCtrl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TestCtrl.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/controllers/rest/TestCtrl.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AAGpC,IAAa,QAAQ,GAArB,MAAa,QAAQ;CAAG,CAAA;AAAX,QAAQ;IADpB,IAAA,eAAU,EAAC,OAAO,CAAC;GACP,QAAQ,CAAG;AAAX,4BAAQ","sourcesContent":["import {Controller} from \"@tsed/di\";\n\n@Controller(\"/root\")\nexport class TestCtrl {}\n"]}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Module1 = void 0;
4
- const tslib_1 = require("tslib");
5
- const SubModule_1 = require("./submodule/SubModule");
6
- const di_1 = require("@tsed/di");
7
- const M1Ctrl1_1 = require("./controllers/M1Ctrl1");
8
- let Module1 = class Module1 {
9
- };
10
- Module1 = tslib_1.__decorate([
11
- (0, di_1.Module)({
12
- mount: {
13
- "/m1": [M1Ctrl1_1.M1Ctrl1]
14
- },
15
- imports: [SubModule_1.SubModule]
16
- })
17
- ], Module1);
18
- exports.Module1 = Module1;
19
- //# sourceMappingURL=Module1.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Module1.js","sourceRoot":"","sources":["../../../../../src/utils/__mock__/module1/Module1.ts"],"names":[],"mappings":";;;;AAAA,qDAAgD;AAChD,iCAAgC;AAChC,mDAA8C;AAQ9C,IAAa,OAAO,GAApB,MAAa,OAAO;CAAG,CAAA;AAAV,OAAO;IANnB,IAAA,WAAM,EAAC;QACN,KAAK,EAAE;YACL,KAAK,EAAE,CAAC,iBAAO,CAAC;SACjB;QACD,OAAO,EAAE,CAAC,qBAAS,CAAC;KACrB,CAAC;GACW,OAAO,CAAG;AAAV,0BAAO","sourcesContent":["import {SubModule} from \"./submodule/SubModule\";\nimport {Module} from \"@tsed/di\";\nimport {M1Ctrl1} from \"./controllers/M1Ctrl1\";\n\n@Module({\n mount: {\n \"/m1\": [M1Ctrl1]\n },\n imports: [SubModule]\n})\nexport class Module1 {}\n"]}
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.M1Ctrl1 = void 0;
4
- const tslib_1 = require("tslib");
5
- const di_1 = require("@tsed/di");
6
- const M1Service_1 = require("../services/M1Service");
7
- let M1Ctrl1 = class M1Ctrl1 {
8
- constructor(service) {
9
- this.service = service;
10
- }
11
- };
12
- M1Ctrl1 = tslib_1.__decorate([
13
- (0, di_1.Controller)("/m1"),
14
- tslib_1.__metadata("design:paramtypes", [M1Service_1.M1Service])
15
- ], M1Ctrl1);
16
- exports.M1Ctrl1 = M1Ctrl1;
17
- //# sourceMappingURL=M1Ctrl1.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"M1Ctrl1.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module1/controllers/M1Ctrl1.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AACpC,qDAAgD;AAGhD,IAAa,OAAO,GAApB,MAAa,OAAO;IAClB,YAAmB,OAAkB;QAAlB,YAAO,GAAP,OAAO,CAAW;IAAG,CAAC;CAC1C,CAAA;AAFY,OAAO;IADnB,IAAA,eAAU,EAAC,KAAK,CAAC;6CAEY,qBAAS;GAD1B,OAAO,CAEnB;AAFY,0BAAO","sourcesContent":["import {Controller} from \"@tsed/di\";\nimport {M1Service} from \"../services/M1Service\";\n\n@Controller(\"/m1\")\nexport class M1Ctrl1 {\n constructor(public service: M1Service) {}\n}\n"]}
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.M1Service = void 0;
4
- const tslib_1 = require("tslib");
5
- const di_1 = require("@tsed/di");
6
- const SubService_1 = require("../submodule/SubService");
7
- let M1Service = class M1Service {
8
- constructor(subService) {
9
- this.subService = subService;
10
- }
11
- };
12
- M1Service = tslib_1.__decorate([
13
- (0, di_1.Injectable)(),
14
- tslib_1.__metadata("design:paramtypes", [SubService_1.SubService])
15
- ], M1Service);
16
- exports.M1Service = M1Service;
17
- //# sourceMappingURL=M1Service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"M1Service.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module1/services/M1Service.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AACpC,wDAAmD;AAGnD,IAAa,SAAS,GAAtB,MAAa,SAAS;IACpB,YAAmB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;CAC9C,CAAA;AAFY,SAAS;IADrB,IAAA,eAAU,GAAE;6CAEoB,uBAAU;GAD9B,SAAS,CAErB;AAFY,8BAAS","sourcesContent":["import {Injectable} from \"@tsed/di\";\nimport {SubService} from \"../submodule/SubService\";\n\n@Injectable()\nexport class M1Service {\n constructor(public subService: SubService) {}\n}\n"]}
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubModule = void 0;
4
- const tslib_1 = require("tslib");
5
- const di_1 = require("@tsed/di");
6
- const SubService_1 = require("./SubService");
7
- let SubModule = class SubModule {
8
- };
9
- SubModule = tslib_1.__decorate([
10
- (0, di_1.Module)({
11
- imports: [SubService_1.SubService]
12
- })
13
- ], SubModule);
14
- exports.SubModule = SubModule;
15
- //# sourceMappingURL=SubModule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SubModule.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module1/submodule/SubModule.ts"],"names":[],"mappings":";;;;AAAA,iCAAgC;AAChC,6CAAwC;AAKxC,IAAa,SAAS,GAAtB,MAAa,SAAS;CAAG,CAAA;AAAZ,SAAS;IAHrB,IAAA,WAAM,EAAC;QACN,OAAO,EAAE,CAAC,uBAAU,CAAC;KACtB,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS","sourcesContent":["import {Module} from \"@tsed/di\";\nimport {SubService} from \"./SubService\";\n\n@Module({\n imports: [SubService]\n})\nexport class SubModule {}\n"]}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubService = void 0;
4
- const tslib_1 = require("tslib");
5
- const di_1 = require("@tsed/di");
6
- let SubService = class SubService {
7
- };
8
- SubService = tslib_1.__decorate([
9
- (0, di_1.Injectable)()
10
- ], SubService);
11
- exports.SubService = SubService;
12
- //# sourceMappingURL=SubService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SubService.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module1/submodule/SubService.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AAGpC,IAAa,UAAU,GAAvB,MAAa,UAAU;CAAG,CAAA;AAAb,UAAU;IADtB,IAAA,eAAU,GAAE;GACA,UAAU,CAAG;AAAb,gCAAU","sourcesContent":["import {Injectable} from \"@tsed/di\";\n\n@Injectable()\nexport class SubService {}\n"]}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Module2 = void 0;
4
- const tslib_1 = require("tslib");
5
- const di_1 = require("@tsed/di");
6
- const M2Ctrl_1 = require("./controllers/M2Ctrl");
7
- let Module2 = class Module2 {
8
- };
9
- Module2 = tslib_1.__decorate([
10
- (0, di_1.Module)({
11
- mount: {
12
- "/mod2": [M2Ctrl_1.M2Ctrl]
13
- },
14
- imports: []
15
- })
16
- ], Module2);
17
- exports.Module2 = Module2;
18
- //# sourceMappingURL=Module2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Module2.js","sourceRoot":"","sources":["../../../../../src/utils/__mock__/module2/Module2.ts"],"names":[],"mappings":";;;;AAAA,iCAAgC;AAChC,iDAA4C;AAQ5C,IAAa,OAAO,GAApB,MAAa,OAAO;CAAG,CAAA;AAAV,OAAO;IANnB,IAAA,WAAM,EAAC;QACN,KAAK,EAAE;YACL,OAAO,EAAE,CAAC,eAAM,CAAC;SAClB;QACD,OAAO,EAAE,EAAE;KACZ,CAAC;GACW,OAAO,CAAG;AAAV,0BAAO","sourcesContent":["import {Module} from \"@tsed/di\";\nimport {M2Ctrl} from \"./controllers/M2Ctrl\";\n\n@Module({\n mount: {\n \"/mod2\": [M2Ctrl]\n },\n imports: []\n})\nexport class Module2 {}\n"]}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.M2Ctrl = void 0;
4
- const tslib_1 = require("tslib");
5
- const di_1 = require("@tsed/di");
6
- let M2Ctrl = class M2Ctrl {
7
- };
8
- M2Ctrl = tslib_1.__decorate([
9
- (0, di_1.Controller)("/m2")
10
- ], M2Ctrl);
11
- exports.M2Ctrl = M2Ctrl;
12
- //# sourceMappingURL=M2Ctrl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"M2Ctrl.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module2/controllers/M2Ctrl.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AAGpC,IAAa,MAAM,GAAnB,MAAa,MAAM;CAAG,CAAA;AAAT,MAAM;IADlB,IAAA,eAAU,EAAC,KAAK,CAAC;GACL,MAAM,CAAG;AAAT,wBAAM","sourcesContent":["import {Controller} from \"@tsed/di\";\n\n@Controller(\"/m2\")\nexport class M2Ctrl {}\n"]}
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createHandlerMetadata = void 0;
4
- const schema_1 = require("@tsed/schema");
5
- const HandlerMetadata_1 = require("../domain/HandlerMetadata");
6
- const HandlerType_1 = require("../interfaces/HandlerType");
7
- function isMetadata(input) {
8
- return input instanceof HandlerMetadata_1.HandlerMetadata;
9
- }
10
- /**
11
- * @ignore
12
- */
13
- function createHandlerMetadata(injector, obj, routeOptions = {}) {
14
- if (isMetadata(obj)) {
15
- return obj;
16
- }
17
- let options;
18
- if (obj instanceof schema_1.EndpointMetadata) {
19
- const provider = injector.getProvider(routeOptions.token);
20
- options = {
21
- token: provider.token,
22
- target: provider.useClass,
23
- scope: provider.scope,
24
- type: HandlerType_1.HandlerType.ENDPOINT,
25
- propertyKey: obj.propertyKey
26
- };
27
- }
28
- else {
29
- const provider = injector.getProvider(obj);
30
- if (provider) {
31
- options = {
32
- token: provider.token,
33
- target: provider.useClass,
34
- scope: provider.scope,
35
- type: HandlerType_1.HandlerType.MIDDLEWARE,
36
- propertyKey: "use"
37
- };
38
- }
39
- else {
40
- options = {
41
- target: obj
42
- };
43
- }
44
- }
45
- options.routeOptions = routeOptions;
46
- return new HandlerMetadata_1.HandlerMetadata(options);
47
- }
48
- exports.createHandlerMetadata = createHandlerMetadata;
49
- //# sourceMappingURL=createHandlerMetadata.js.map