@tsed/common 7.0.0-beta.7 → 7.0.0-rc.1

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 -0
  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 -0
  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 -0
  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 +28 -23
  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 +0,0 @@
1
- {"version":3,"file":"HandlerMetadata.js","sourceRoot":"","sources":["../../../src/domain/HandlerMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAO,MAAM,YAAY,CAAC;AACxC,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAChD,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AAYtD,MAAM,OAAO,eAAe;IAY1B,YAAY,OAA+B;QARlC,eAAU,GAAY,KAAK,CAAC;QAC5B,SAAI,GAAgB,WAAW,CAAC,MAAM,CAAC;QACvC,oBAAe,GAAY,KAAK,CAAC;QAOxC,MAAM,EAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAC,GAAG,OAAO,CAAC;QAExE,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,MAAM,CAAC,IAAI,IAAI,WAAW,CAAC,MAAM,CAAC;QACtD,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,aAAa,CAAC,SAAS,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,YAAY,IAAI,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAErE,IA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AA,MAAA,IAAI,CAAC,YAAY,0CAAE,OAAO,KAAI,KAAK,CAAC;IAC7C,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1F,CAAC;CACF","sourcesContent":["import {nameOf, Type} from \"@tsed/core\";\nimport {ProviderScope} from \"@tsed/di\";\nimport {ParamTypes} from \"@tsed/platform-params\";\nimport {JsonParameterStore} from \"@tsed/schema\";\nimport {HandlerType} from \"../interfaces/HandlerType\";\nimport {PlatformRouteOptions, PlatformRouteWithoutHandlers} from \"../interfaces/PlatformRouteOptions\";\n\nexport interface HandlerMetadataOptions {\n target: (Type<any> | Function) & {type?: HandlerType};\n routeOptions?: PlatformRouteWithoutHandlers;\n token?: Type<any>;\n propertyKey?: string | symbol;\n scope?: ProviderScope;\n type?: HandlerType;\n}\n\nexport class HandlerMetadata {\n readonly target: any;\n readonly token: Type<any>;\n readonly propertyKey: string | symbol;\n readonly injectable: boolean = false;\n readonly type: HandlerType = HandlerType.RAW_FN;\n readonly hasNextFunction: boolean = false;\n readonly routeOptions: Partial<PlatformRouteOptions>;\n readonly scope: ProviderScope;\n\n handler: any;\n\n constructor(options: HandlerMetadataOptions) {\n const {target, token, propertyKey, type, scope, routeOptions} = options;\n\n this.type = type || target.type || HandlerType.RAW_FN;\n this.scope = scope || ProviderScope.SINGLETON;\n this.routeOptions = routeOptions || {};\n const handler = propertyKey ? target.prototype[propertyKey] : target;\n\n if (propertyKey) {\n this.target = target;\n this.token = token!;\n this.propertyKey = propertyKey;\n this.hasNextFunction = this.hasParamType(ParamTypes.NEXT_FN);\n\n if (this.hasParamType(ParamTypes.ERR)) {\n this.type = HandlerType.ERR_MIDDLEWARE;\n }\n\n this.injectable = JsonParameterStore.getParams(target as any, propertyKey).length > 0;\n } else {\n this.handler = handler;\n }\n\n if (!this.injectable) {\n if (handler.length === 4) {\n this.type = HandlerType.RAW_ERR_FN;\n }\n this.hasNextFunction = handler.length >= 3;\n }\n }\n\n get hasErrorParam() {\n return this.type === HandlerType.ERR_MIDDLEWARE || this.type === HandlerType.RAW_ERR_FN;\n }\n\n public getParams() {\n return JsonParameterStore.getParams(this.target, this.propertyKey) || [];\n }\n\n public hasParamType(paramType: any): boolean {\n return this.getParams().findIndex((p) => p.paramType === paramType) > -1;\n }\n\n public isFinal() {\n return this.routeOptions?.isFinal || false;\n }\n\n toString() {\n return [this.target && nameOf(this.target), this.propertyKey].filter(Boolean).join(\".\");\n }\n}\n"]}
@@ -1,9 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { Controller } from "@tsed/di";
3
- let FakeCtrl = class FakeCtrl {
4
- };
5
- FakeCtrl = __decorate([
6
- Controller("/")
7
- ], FakeCtrl);
8
- export { FakeCtrl };
9
- //# sourceMappingURL=FakeCtrl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FakeCtrl.js","sourceRoot":"","sources":["../../../../src/middlewares/__mock__/FakeCtrl.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,IAAa,QAAQ,GAArB,MAAa,QAAQ;CAAG,CAAA;AAAX,QAAQ;IADpB,UAAU,CAAC,GAAG,CAAC;GACH,QAAQ,CAAG;SAAX,QAAQ","sourcesContent":["import {Controller} from \"@tsed/di\";\n\n@Controller(\"/\")\nexport class FakeCtrl {}\n"]}
@@ -1,9 +0,0 @@
1
- /**
2
- * @ignore
3
- */
4
- export function bindEndpointMiddleware(endpoint) {
5
- return (ctx) => {
6
- ctx.endpoint = endpoint;
7
- };
8
- }
9
- //# sourceMappingURL=bindEndpointMiddleware.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bindEndpointMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/bindEndpointMiddleware.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAA0B;IAC/D,OAAO,CAAC,GAAoB,EAAE,EAAE;QAC9B,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC","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,105 +0,0 @@
1
- var PlatformRouter_1;
2
- import { __decorate, __metadata, __param } from "tslib";
3
- import { Inject, Injectable, InjectorService, ProviderScope } from "@tsed/di";
4
- import { PlatformHandler } from "./PlatformHandler.js";
5
- import { PlatformAdapter } from "./PlatformAdapter.js";
6
- /**
7
- * @ignore
8
- */
9
- export const PLATFORM_ROUTER_OPTIONS = Symbol.for("PlatformRouterOptions");
10
- /**
11
- * Platform Router abstraction layer.
12
- * @platform
13
- */
14
- let PlatformRouter = PlatformRouter_1 = class PlatformRouter {
15
- constructor(platformHandler, adapter, routerOptions = {}) {
16
- this.platformHandler = platformHandler;
17
- this.adapter = adapter;
18
- this.isBuilt = false;
19
- const { router, callback } = adapter.router(routerOptions);
20
- this.rawRouter = this.raw = router;
21
- this.callback = callback;
22
- }
23
- /**
24
- * Create a new instance of PlatformRouter
25
- * @param injector
26
- * @param routerOptions
27
- */
28
- static create(injector, routerOptions = {}) {
29
- const locals = new Map();
30
- locals.set(PLATFORM_ROUTER_OPTIONS, routerOptions);
31
- return injector.invoke(PlatformRouter_1, locals);
32
- }
33
- getRouter() {
34
- return this.rawRouter;
35
- }
36
- use(...handlers) {
37
- // @ts-ignore
38
- this.getRouter().use(...this.mapHandlers(handlers));
39
- return this;
40
- }
41
- addRoute(options) {
42
- const { method, path, handlers, ...opts } = options;
43
- // @ts-ignore
44
- this.getRouter()[method](path, ...this.mapHandlers(handlers, { method, path, ...opts }));
45
- return this;
46
- }
47
- all(path, ...handlers) {
48
- return this.addRoute({ method: "all", path, handlers, isFinal: true });
49
- }
50
- get(path, ...handlers) {
51
- return this.addRoute({ method: "get", path, handlers, isFinal: true });
52
- }
53
- post(path, ...handlers) {
54
- return this.addRoute({ method: "post", path, handlers, isFinal: true });
55
- }
56
- put(path, ...handlers) {
57
- return this.addRoute({ method: "put", path, handlers, isFinal: true });
58
- }
59
- delete(path, ...handlers) {
60
- return this.addRoute({ method: "delete", path, handlers, isFinal: true });
61
- }
62
- patch(path, ...handlers) {
63
- return this.addRoute({ method: "patch", path, handlers, isFinal: true });
64
- }
65
- head(path, ...handlers) {
66
- return this.addRoute({ method: "head", path, handlers, isFinal: true });
67
- }
68
- options(path, ...handlers) {
69
- return this.addRoute({ method: "options", path, handlers, isFinal: true });
70
- }
71
- statics(path, options) {
72
- return this.use(path, this.adapter.statics(path, options));
73
- }
74
- multer(options) {
75
- return this.adapter.multipart(options);
76
- }
77
- mapHandlers(handlers, options = {}) {
78
- return handlers.reduce((list, handler, index) => {
79
- if (typeof handler === "string") {
80
- return list.concat(handler);
81
- }
82
- if (handler instanceof PlatformRouter_1) {
83
- return list.concat(handler.callback());
84
- }
85
- return list.concat(this.platformHandler.createHandler(handler, {
86
- ...options,
87
- isFinal: options.isFinal ? index === handlers.length - 1 : false
88
- }));
89
- }, []);
90
- }
91
- };
92
- __decorate([
93
- Inject(),
94
- __metadata("design:type", InjectorService)
95
- ], PlatformRouter.prototype, "injector", void 0);
96
- PlatformRouter = PlatformRouter_1 = __decorate([
97
- Injectable({
98
- scope: ProviderScope.INSTANCE
99
- }),
100
- __param(2, Inject(PLATFORM_ROUTER_OPTIONS)),
101
- __metadata("design:paramtypes", [PlatformHandler,
102
- PlatformAdapter, Object])
103
- ], PlatformRouter);
104
- export { PlatformRouter };
105
- //# sourceMappingURL=PlatformRouter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformRouter.js","source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AC,MAAM,CAChB,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,OAAO,EAAE;gBAC1C,GAAG,OAAO;gBACV,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK;aACjE,CAAC,CACH,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF,CAAA;AAzGC;IADC,MAAM,EAAE;8BACC,eAAe;gDAAC;AANf,cAAc;IAH1B,UAAU,CAAC;QACV,KAAK,EAAE,aAAa,CAAC,QAAQ;KAC9B,CAAC;IAcG,WAAA,MAAM,CAAC,uBAAuB,CAAC,CAAA;qCAFL,eAAe;QACxB,eAAe;GAZxB,cAAc,CA+G1B;SA/GY,cAAc","sourcesContent":["import {Inject, Injectable, InjectorService, PathType, ProviderScope} from \"@tsed/di\";\nimport {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,4 +0,0 @@
1
- export const value1 = "value";
2
- export class Test1 {
3
- }
4
- //# sourceMappingURL=Test1.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Test1.js","sourceRoot":"","sources":["../../../../src/utils/__mock__/Test1.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC;AAE9B,MAAM,OAAO,KAAK;CAAG","sourcesContent":["export const value1 = \"value\";\n\nexport class Test1 {}\n"]}
@@ -1,4 +0,0 @@
1
- export const value2 = "value";
2
- export class Test2 {
3
- }
4
- //# sourceMappingURL=Test2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Test2.js","sourceRoot":"","sources":["../../../../src/utils/__mock__/Test2.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC;AAE9B,MAAM,OAAO,KAAK;CAAG","sourcesContent":["export const value2 = \"value\";\n\nexport class Test2 {}\n"]}
@@ -1,45 +0,0 @@
1
- import { EndpointMetadata } from "@tsed/schema";
2
- import { HandlerMetadata } from "../domain/HandlerMetadata.js";
3
- import { HandlerType } from "../interfaces/HandlerType.js";
4
- function isMetadata(input) {
5
- return input instanceof HandlerMetadata;
6
- }
7
- /**
8
- * @ignore
9
- */
10
- export function createHandlerMetadata(injector, obj, routeOptions = {}) {
11
- if (isMetadata(obj)) {
12
- return obj;
13
- }
14
- let options;
15
- if (obj instanceof EndpointMetadata) {
16
- const provider = injector.getProvider(routeOptions.token);
17
- options = {
18
- token: provider.token,
19
- target: provider.useClass,
20
- scope: provider.scope,
21
- type: HandlerType.ENDPOINT,
22
- propertyKey: obj.propertyKey
23
- };
24
- }
25
- else {
26
- const provider = injector.getProvider(obj);
27
- if (provider) {
28
- options = {
29
- token: provider.token,
30
- target: provider.useClass,
31
- scope: provider.scope,
32
- type: HandlerType.MIDDLEWARE,
33
- propertyKey: "use"
34
- };
35
- }
36
- else {
37
- options = {
38
- target: obj
39
- };
40
- }
41
- }
42
- options.routeOptions = routeOptions;
43
- return new HandlerMetadata(options);
44
- }
45
- //# sourceMappingURL=createHandlerMetadata.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createHandlerMetadata.js","sourceRoot":"","sources":["../../../src/utils/createHandlerMetadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAyB,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AAGtD,SAAS,UAAU,CAAC,KAAU;IAC5B,OAAO,KAAK,YAAY,eAAe,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAyB,EACzB,GAA2B,EAC3B,eAA6C,EAAE;IAE/C,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE;QACnB,OAAO,GAAsB,CAAC;KAC/B;IAED,IAAI,OAA+B,CAAC;IAEpC,IAAI,GAAG,YAAY,gBAAgB,EAAE;QACnC,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,CAAE,CAAC;QAE3D,OAAO,GAAG;YACR,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,MAAM,EAAE,QAAQ,CAAC,QAAQ;YACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,IAAI,EAAE,WAAW,CAAC,QAAQ;YAC1B,WAAW,EAAE,GAAG,CAAC,WAAW;SAC7B,CAAC;KACH;SAAM;QACL,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAE3C,IAAI,QAAQ,EAAE;YACZ,OAAO,GAAG;gBACR,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,MAAM,EAAE,QAAQ,CAAC,QAAQ;gBACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,IAAI,EAAE,WAAW,CAAC,UAAU;gBAC5B,WAAW,EAAE,KAAK;aACnB,CAAC;SACH;aAAM;YACL,OAAO,GAAG;gBACR,MAAM,EAAE,GAAG;aACZ,CAAC;SACH;KACF;IAED,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;IAEpC,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import {InjectorService} from \"@tsed/di\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {HandlerMetadata, HandlerMetadataOptions} from \"../domain/HandlerMetadata\";\nimport {HandlerType} from \"../interfaces/HandlerType\";\nimport {PlatformRouteWithoutHandlers} from \"../interfaces/PlatformRouteOptions\";\n\nfunction isMetadata(input: any) {\n return input instanceof HandlerMetadata;\n}\n\n/**\n * @ignore\n */\nexport function createHandlerMetadata(\n injector: InjectorService,\n obj: any | EndpointMetadata,\n routeOptions: PlatformRouteWithoutHandlers = {}\n): HandlerMetadata {\n if (isMetadata(obj)) {\n return obj as HandlerMetadata;\n }\n\n let options: HandlerMetadataOptions;\n\n if (obj instanceof EndpointMetadata) {\n const provider = injector.getProvider(routeOptions.token)!;\n\n options = {\n token: provider.token,\n target: provider.useClass,\n scope: provider.scope,\n type: HandlerType.ENDPOINT,\n propertyKey: obj.propertyKey\n };\n } else {\n const provider = injector.getProvider(obj);\n\n if (provider) {\n options = {\n token: provider.token,\n target: provider.useClass,\n scope: provider.scope,\n type: HandlerType.MIDDLEWARE,\n propertyKey: \"use\"\n };\n } else {\n options = {\n target: obj\n };\n }\n }\n\n options.routeOptions = routeOptions;\n\n return new HandlerMetadata(options);\n}\n"]}
@@ -1,25 +0,0 @@
1
- import { GlobalProviders, ProviderType } from "@tsed/di";
2
- import { importComponents } from "@tsed/components-scan";
3
- async function recursiveImports(providers, settings, properties) {
4
- const { exclude = [] } = settings;
5
- const promises = providers
6
- .map(({ token }) => GlobalProviders.get(token))
7
- .filter((provider) => (provider === null || provider === void 0 ? void 0 : provider.type) === ProviderType.MODULE && provider.configuration)
8
- .map((provider) => importProviders({ exclude, ...provider.configuration }, properties));
9
- return (await Promise.all(promises)).flat();
10
- }
11
- /**
12
- * Import providers from given patterns.
13
- *
14
- * @param settings
15
- * @param properties
16
- */
17
- export async function importProviders(settings, properties = ["imports"]) {
18
- const { exclude = [] } = settings;
19
- const disableComponentsScan = settings.disableComponentsScan || !!process.env.WEBPACK;
20
- const promises = properties.map((key) => importComponents(settings[key], exclude, disableComponentsScan));
21
- const providers = (await Promise.all(promises)).flat();
22
- const children = await recursiveImports(providers, settings, properties);
23
- return [...children, ...providers];
24
- }
25
- //# sourceMappingURL=importProviders.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"importProviders.js","sourceRoot":"","sources":["../../../src/utils/importProviders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAY,YAAY,EAAC,MAAM,UAAU,CAAC;AACjE,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAEvD,KAAK,UAAU,gBAAgB,CAAC,SAA4C,EAAE,QAAqC,EAAE,UAAoB;IACvI,MAAM,EAAC,OAAO,GAAG,EAAE,EAAC,GAAG,QAAQ,CAAC;IAEhC,MAAM,QAAQ,GAAG,SAAS;SACvB,GAAG,CAAC,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC5C,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,YAAY,CAAC,MAAM,IAAI,QAAQ,CAAC,aAAa,CAAC;SACtF,GAAG,CAAC,CAAC,QAAkB,EAAE,EAAE,CAAC,eAAe,CAAC,EAAC,OAAO,EAAE,GAAG,QAAQ,CAAC,aAAa,EAAC,EAAE,UAAU,CAAC,CAAC,CAAC;IAElG,OAAO,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9C,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,QAAqC,EACrC,aAAuB,CAAC,SAAS,CAAC;IAElC,MAAM,EAAC,OAAO,GAAG,EAAE,EAAC,GAAG,QAAQ,CAAC;IAChC,MAAM,qBAAqB,GAAG,QAAQ,CAAC,qBAAqB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;IAEtF,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAC1G,MAAM,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvD,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IAEzE,OAAO,CAAC,GAAG,QAAQ,EAAE,GAAG,SAAS,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import {GlobalProviders, Provider, ProviderType} from \"@tsed/di\";\nimport {importComponents} from \"@tsed/components-scan\";\n\nasync function recursiveImports(providers: {token: string; route?: string}[], settings: Partial<TsED.Configuration>, properties: string[]) {\n const {exclude = []} = settings;\n\n const promises = providers\n .map(({token}) => GlobalProviders.get(token))\n .filter((provider) => provider?.type === ProviderType.MODULE && provider.configuration)\n .map((provider: Provider) => importProviders({exclude, ...provider.configuration}, properties));\n\n return (await Promise.all(promises)).flat();\n}\n\n/**\n * Import providers from given patterns.\n *\n * @param settings\n * @param properties\n */\nexport async function importProviders(\n settings: Partial<TsED.Configuration>,\n properties: string[] = [\"imports\"]\n): Promise<{token: string; route?: string}[]> {\n const {exclude = []} = settings;\n const disableComponentsScan = settings.disableComponentsScan || !!process.env.WEBPACK;\n\n const promises = properties.map((key) => importComponents(settings[key], exclude, disableComponentsScan));\n const providers = (await Promise.all(promises)).flat();\n const children = await recursiveImports(providers, settings, properties);\n\n return [...children, ...providers];\n}\n"]}
@@ -1,11 +0,0 @@
1
- import { HandlerType } from "../interfaces/HandlerType.js";
2
- /**
3
- * Create Ts.ED context handler
4
- * @param fn
5
- * @ignore
6
- */
7
- export function useCtxHandler(fn) {
8
- fn.type = HandlerType.CTX_FN;
9
- return fn;
10
- }
11
- //# sourceMappingURL=useCtxHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCtxHandler.js","sourceRoot":"","sources":["../../../src/utils/useCtxHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AAItD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,EAA6C;IACzE,EAAE,CAAC,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC;IAE7B,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import {PlatformContext} from \"../domain/PlatformContext\";\nimport {HandlerType} from \"../interfaces/HandlerType\";\n\nexport type PlatformCtxHandler = ($ctx: PlatformContext) => any | Promise<any>;\n\n/**\n * Create Ts.ED context handler\n * @param fn\n * @ignore\n */\nexport function useCtxHandler(fn: PlatformCtxHandler & {type?: HandlerType}) {\n fn.type = HandlerType.CTX_FN;\n\n return fn;\n}\n"]}
@@ -1,18 +0,0 @@
1
- import { InjectorService } from "@tsed/di";
2
- import { ControllerProvider } from "../domain/ControllerProvider";
3
- import { PlatformRouter } from "../services/PlatformRouter";
4
- /**
5
- * @ignore
6
- */
7
- export declare function getRouter(injector: InjectorService, provider: ControllerProvider): any;
8
- /**
9
- * @ignore
10
- */
11
- export declare function createRouter(injector: InjectorService, provider: ControllerProvider): PlatformRouter;
12
- /**
13
- * @ignore
14
- * @param injector
15
- * @param provider
16
- * @param parentUseBefore
17
- */
18
- export declare function buildRouter(injector: InjectorService, provider: ControllerProvider, parentUseBefore?: any[]): PlatformRouter<TsED.Application, TsED.Router>;
@@ -1,3 +0,0 @@
1
- export interface EndpointDirectoriesSettings {
2
- [endpoint: string]: any | string | (any | string)[];
3
- }
@@ -1,24 +0,0 @@
1
- import { ControllerMiddlewares, Provider, TokenProvider } from "@tsed/di";
2
- export declare class ControllerProvider<T = any> extends Provider<T> {
3
- readonly tokenRouter: string;
4
- constructor(provide: TokenProvider, options?: Partial<Provider>);
5
- /**
6
- *
7
- */
8
- get routerOptions(): any;
9
- /**
10
- *
11
- * @param value
12
- */
13
- set routerOptions(value: any);
14
- /**
15
- *
16
- * @returns {any[]}
17
- */
18
- get middlewares(): ControllerMiddlewares;
19
- /**
20
- *
21
- * @param middlewares
22
- */
23
- set middlewares(middlewares: ControllerMiddlewares);
24
- }
@@ -1,32 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { ProviderScope } from "@tsed/di";
3
- import { JsonParameterStore } from "@tsed/schema";
4
- import { HandlerType } from "../interfaces/HandlerType";
5
- import { PlatformRouteOptions, PlatformRouteWithoutHandlers } from "../interfaces/PlatformRouteOptions";
6
- export interface HandlerMetadataOptions {
7
- target: (Type<any> | Function) & {
8
- type?: HandlerType;
9
- };
10
- routeOptions?: PlatformRouteWithoutHandlers;
11
- token?: Type<any>;
12
- propertyKey?: string | symbol;
13
- scope?: ProviderScope;
14
- type?: HandlerType;
15
- }
16
- export declare class HandlerMetadata {
17
- readonly target: any;
18
- readonly token: Type<any>;
19
- readonly propertyKey: string | symbol;
20
- readonly injectable: boolean;
21
- readonly type: HandlerType;
22
- readonly hasNextFunction: boolean;
23
- readonly routeOptions: Partial<PlatformRouteOptions>;
24
- readonly scope: ProviderScope;
25
- handler: any;
26
- constructor(options: HandlerMetadataOptions);
27
- get hasErrorParam(): boolean;
28
- getParams(): JsonParameterStore[];
29
- hasParamType(paramType: any): boolean;
30
- isFinal(): boolean;
31
- toString(): string;
32
- }
@@ -1,2 +0,0 @@
1
- export declare class FakeCtrl {
2
- }
@@ -1,6 +0,0 @@
1
- import type { EndpointMetadata } from "../domain/EndpointMetadata";
2
- import type { PlatformContext } from "../domain/PlatformContext";
3
- /**
4
- * @ignore
5
- */
6
- export declare function bindEndpointMiddleware(endpoint: EndpointMetadata): (ctx: PlatformContext) => void;
@@ -1,51 +0,0 @@
1
- import { InjectorService, PathType } from "@tsed/di";
2
- import { PlatformHandler } from "./PlatformHandler";
3
- import { PlatformRouteOptions, PlatformRouteWithoutHandlers } from "../interfaces/PlatformRouteOptions";
4
- import { PlatformStaticsOptions } from "../config/interfaces/PlatformStaticsSettings";
5
- import { PlatformMulter, PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings";
6
- import { PlatformAdapter } from "./PlatformAdapter";
7
- import { RouterOptions } from "express";
8
- /**
9
- * @ignore
10
- */
11
- export declare const PLATFORM_ROUTER_OPTIONS: unique symbol;
12
- declare global {
13
- namespace TsED {
14
- interface Router {
15
- }
16
- }
17
- }
18
- /**
19
- * Platform Router abstraction layer.
20
- * @platform
21
- */
22
- export declare class PlatformRouter<App = TsED.Application, Router = TsED.Router> {
23
- protected platformHandler: PlatformHandler;
24
- readonly adapter: PlatformAdapter<App, Router>;
25
- rawRouter: Router;
26
- raw: any;
27
- isBuilt: boolean;
28
- injector: InjectorService;
29
- callback: () => any;
30
- constructor(platformHandler: PlatformHandler, adapter: PlatformAdapter<App, Router>, routerOptions?: Partial<RouterOptions>);
31
- /**
32
- * Create a new instance of PlatformRouter
33
- * @param injector
34
- * @param routerOptions
35
- */
36
- static create(injector: InjectorService, routerOptions?: any): PlatformRouter<TsED.Application, TsED.Router>;
37
- getRouter(): Router;
38
- use(...handlers: any[]): this;
39
- addRoute(options: Partial<PlatformRouteOptions>): this;
40
- all(path: PathType, ...handlers: any[]): this;
41
- get(path: PathType, ...handlers: any[]): this;
42
- post(path: PathType, ...handlers: any[]): this;
43
- put(path: PathType, ...handlers: any[]): this;
44
- delete(path: PathType, ...handlers: any[]): this;
45
- patch(path: PathType, ...handlers: any[]): this;
46
- head(path: PathType, ...handlers: any[]): this;
47
- options(path: PathType, ...handlers: any[]): this;
48
- statics(path: string, options: PlatformStaticsOptions): this;
49
- multer(options: PlatformMulterSettings): PlatformMulter;
50
- protected mapHandlers(handlers: any[], options?: PlatformRouteWithoutHandlers): any[];
51
- }
@@ -1,3 +0,0 @@
1
- export declare const value1 = "value";
2
- export declare class Test1 {
3
- }
@@ -1,3 +0,0 @@
1
- export declare const value2 = "value";
2
- export declare class Test2 {
3
- }
@@ -1,8 +0,0 @@
1
- import { InjectorService } from "@tsed/di";
2
- import { EndpointMetadata } from "@tsed/schema";
3
- import { HandlerMetadata } from "../domain/HandlerMetadata";
4
- import { PlatformRouteWithoutHandlers } from "../interfaces/PlatformRouteOptions";
5
- /**
6
- * @ignore
7
- */
8
- export declare function createHandlerMetadata(injector: InjectorService, obj: any | EndpointMetadata, routeOptions?: PlatformRouteWithoutHandlers): HandlerMetadata;
@@ -1,10 +0,0 @@
1
- /**
2
- * Import providers from given patterns.
3
- *
4
- * @param settings
5
- * @param properties
6
- */
7
- export declare function importProviders(settings: Partial<TsED.Configuration>, properties?: string[]): Promise<{
8
- token: string;
9
- route?: string;
10
- }[]>;
@@ -1,13 +0,0 @@
1
- import { PlatformContext } from "../domain/PlatformContext";
2
- import { HandlerType } from "../interfaces/HandlerType";
3
- export declare type PlatformCtxHandler = ($ctx: PlatformContext) => any | Promise<any>;
4
- /**
5
- * Create Ts.ED context handler
6
- * @param fn
7
- * @ignore
8
- */
9
- export declare function useCtxHandler(fn: PlatformCtxHandler & {
10
- type?: HandlerType;
11
- }): PlatformCtxHandler & {
12
- type?: HandlerType | undefined;
13
- };