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

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 (143) hide show
  1. package/jest.config.js +4 -4
  2. package/lib/cjs/builder/PlatformBuilder.js +20 -10
  3. package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
  4. package/lib/cjs/decorators/params/error.js +1 -1
  5. package/lib/cjs/decorators/params/error.js.map +1 -1
  6. package/lib/cjs/domain/AnyToPromiseWithCtx.js +1 -3
  7. package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -1
  8. package/lib/cjs/domain/PlatformContext.js +28 -1
  9. package/lib/cjs/domain/PlatformContext.js.map +1 -1
  10. package/lib/cjs/domain/PlatformRouteDetails.js +0 -25
  11. package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -1
  12. package/lib/cjs/exports.js +1 -0
  13. package/lib/cjs/exports.js.map +1 -1
  14. package/lib/cjs/index.js +1 -7
  15. package/lib/cjs/index.js.map +1 -1
  16. package/lib/cjs/interfaces/Route.js.map +1 -1
  17. package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -1
  18. package/lib/cjs/services/FakeAdapter.js +5 -9
  19. package/lib/cjs/services/FakeAdapter.js.map +1 -1
  20. package/lib/cjs/services/Platform.js +41 -85
  21. package/lib/cjs/services/Platform.js.map +1 -1
  22. package/lib/cjs/services/PlatformAdapter.js +0 -2
  23. package/lib/cjs/services/PlatformAdapter.js.map +1 -1
  24. package/lib/cjs/services/PlatformApplication.js +22 -10
  25. package/lib/cjs/services/PlatformApplication.js.map +1 -1
  26. package/lib/cjs/services/PlatformHandler.js +87 -163
  27. package/lib/cjs/services/PlatformHandler.js.map +1 -1
  28. package/lib/cjs/services/PlatformMiddlewaresChain.js +2 -18
  29. package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
  30. package/lib/cjs/services/PlatformRequest.js +2 -2
  31. package/lib/cjs/services/PlatformRequest.js.map +1 -1
  32. package/lib/cjs/services/PlatformResponse.js +5 -9
  33. package/lib/cjs/services/PlatformResponse.js.map +1 -1
  34. package/lib/cjs/services/PlatformTest.js +1 -0
  35. package/lib/cjs/services/PlatformTest.js.map +1 -1
  36. package/lib/cjs/utils/createContext.js +7 -11
  37. package/lib/cjs/utils/createContext.js.map +1 -1
  38. package/lib/cjs/utils/createInjector.js +0 -2
  39. package/lib/cjs/utils/createInjector.js.map +1 -1
  40. package/lib/cjs/utils/ensureContext.js +16 -0
  41. package/lib/cjs/utils/ensureContext.js.map +1 -0
  42. package/lib/cjs/utils/printRoutes.js +10 -8
  43. package/lib/cjs/utils/printRoutes.js.map +1 -1
  44. package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
  45. package/lib/esm/builder/PlatformBuilder.js +20 -10
  46. package/lib/esm/builder/PlatformBuilder.js.map +1 -1
  47. package/lib/esm/decorators/params/error.js +1 -1
  48. package/lib/esm/decorators/params/error.js.map +1 -1
  49. package/lib/esm/domain/AnyToPromiseWithCtx.js +1 -3
  50. package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -1
  51. package/lib/esm/domain/PlatformContext.js +28 -1
  52. package/lib/esm/domain/PlatformContext.js.map +1 -1
  53. package/lib/esm/domain/PlatformRouteDetails.js +1 -23
  54. package/lib/esm/domain/PlatformRouteDetails.js.map +1 -1
  55. package/lib/esm/exports.js +1 -0
  56. package/lib/esm/exports.js.map +1 -1
  57. package/lib/esm/index.js +1 -7
  58. package/lib/esm/index.js.map +1 -1
  59. package/lib/esm/interfaces/Route.js.map +1 -1
  60. package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -1
  61. package/lib/esm/services/FakeAdapter.js +5 -9
  62. package/lib/esm/services/FakeAdapter.js.map +1 -1
  63. package/lib/esm/services/Platform.js +42 -86
  64. package/lib/esm/services/Platform.js.map +1 -1
  65. package/lib/esm/services/PlatformAdapter.js +0 -2
  66. package/lib/esm/services/PlatformAdapter.js.map +1 -1
  67. package/lib/esm/services/PlatformApplication.js +22 -10
  68. package/lib/esm/services/PlatformApplication.js.map +1 -1
  69. package/lib/esm/services/PlatformHandler.js +89 -165
  70. package/lib/esm/services/PlatformHandler.js.map +1 -1
  71. package/lib/esm/services/PlatformMiddlewaresChain.js +2 -18
  72. package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
  73. package/lib/esm/services/PlatformRequest.js +2 -2
  74. package/lib/esm/services/PlatformRequest.js.map +1 -1
  75. package/lib/esm/services/PlatformResponse.js +5 -9
  76. package/lib/esm/services/PlatformResponse.js.map +1 -1
  77. package/lib/esm/services/PlatformTest.js +1 -0
  78. package/lib/esm/services/PlatformTest.js.map +1 -1
  79. package/lib/esm/utils/createContext.js +5 -9
  80. package/lib/esm/utils/createContext.js.map +1 -1
  81. package/lib/esm/utils/createInjector.js +0 -2
  82. package/lib/esm/utils/createInjector.js.map +1 -1
  83. package/lib/esm/utils/ensureContext.js +12 -0
  84. package/lib/esm/utils/ensureContext.js.map +1 -0
  85. package/lib/esm/utils/printRoutes.js +10 -8
  86. package/lib/esm/utils/printRoutes.js.map +1 -1
  87. package/lib/esm/utils/setResponseHeaders.js.map +1 -1
  88. package/lib/types/builder/PlatformBuilder.d.ts +13 -11
  89. package/lib/types/domain/AnyToPromiseWithCtx.d.ts +1 -9
  90. package/lib/types/domain/PlatformContext.d.ts +16 -1
  91. package/lib/types/domain/PlatformRouteDetails.d.ts +6 -15
  92. package/lib/types/exports.d.ts +1 -0
  93. package/lib/types/index.d.ts +1 -7
  94. package/lib/types/interfaces/Route.d.ts +2 -3
  95. package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +1 -1
  96. package/lib/types/services/FakeAdapter.d.ts +7 -6
  97. package/lib/types/services/Platform.d.ts +11 -28
  98. package/lib/types/services/PlatformAdapter.d.ts +19 -10
  99. package/lib/types/services/PlatformApplication.d.ts +14 -6
  100. package/lib/types/services/PlatformHandler.d.ts +19 -55
  101. package/lib/types/services/PlatformMiddlewaresChain.d.ts +1 -2
  102. package/lib/types/services/PlatformRequest.d.ts +1 -5
  103. package/lib/types/services/PlatformResponse.d.ts +2 -4
  104. package/lib/types/services/PlatformTest.d.ts +2 -1
  105. package/lib/types/utils/createContext.d.ts +2 -2
  106. package/lib/types/utils/createInjector.d.ts +1 -1
  107. package/lib/types/utils/ensureContext.d.ts +2 -0
  108. package/package.json +16 -15
  109. package/lib/cjs/builder/PlatformControllerBuilder.js +0 -82
  110. package/lib/cjs/builder/PlatformControllerBuilder.js.map +0 -1
  111. package/lib/cjs/domain/ControllerProvider.js +0 -52
  112. package/lib/cjs/domain/ControllerProvider.js.map +0 -1
  113. package/lib/cjs/domain/HandlerMetadata.js +0 -62
  114. package/lib/cjs/domain/HandlerMetadata.js.map +0 -1
  115. package/lib/cjs/middlewares/bindEndpointMiddleware.js +0 -13
  116. package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +0 -1
  117. package/lib/cjs/services/PlatformRouter.js +0 -114
  118. package/lib/cjs/services/PlatformRouter.js.map +0 -1
  119. package/lib/cjs/utils/createHandlerMetadata.js +0 -49
  120. package/lib/cjs/utils/createHandlerMetadata.js.map +0 -1
  121. package/lib/cjs/utils/useCtxHandler.js +0 -15
  122. package/lib/cjs/utils/useCtxHandler.js.map +0 -1
  123. package/lib/esm/builder/PlatformControllerBuilder.js +0 -76
  124. package/lib/esm/builder/PlatformControllerBuilder.js.map +0 -1
  125. package/lib/esm/domain/ControllerProvider.js +0 -48
  126. package/lib/esm/domain/ControllerProvider.js.map +0 -1
  127. package/lib/esm/domain/HandlerMetadata.js +0 -58
  128. package/lib/esm/domain/HandlerMetadata.js.map +0 -1
  129. package/lib/esm/middlewares/bindEndpointMiddleware.js +0 -9
  130. package/lib/esm/middlewares/bindEndpointMiddleware.js.map +0 -1
  131. package/lib/esm/services/PlatformRouter.js +0 -111
  132. package/lib/esm/services/PlatformRouter.js.map +0 -1
  133. package/lib/esm/utils/createHandlerMetadata.js +0 -45
  134. package/lib/esm/utils/createHandlerMetadata.js.map +0 -1
  135. package/lib/esm/utils/useCtxHandler.js +0 -11
  136. package/lib/esm/utils/useCtxHandler.js.map +0 -1
  137. package/lib/types/builder/PlatformControllerBuilder.d.ts +0 -18
  138. package/lib/types/domain/ControllerProvider.d.ts +0 -24
  139. package/lib/types/domain/HandlerMetadata.d.ts +0 -32
  140. package/lib/types/middlewares/bindEndpointMiddleware.d.ts +0 -6
  141. package/lib/types/services/PlatformRouter.d.ts +0 -51
  142. package/lib/types/utils/createHandlerMetadata.d.ts +0 -8
  143. package/lib/types/utils/useCtxHandler.d.ts +0 -13
@@ -1 +0,0 @@
1
- {"version":3,"file":"ControllerProvider.js","sourceRoot":"","sources":["../../../src/domain/ControllerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,QAAQ,EAAE,YAAY,EAAgB,MAAM,UAAU,CAAC;AACtF,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAE1D,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB,MAAM,OAAO,kBAA4B,SAAQ,QAAW;IACjD,WAAW,CAAS;IAE7B,YAAY,OAAsB,EAAE,UAA6B,EAAE;QACjE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,GAAG,IAAI,CAAC,IAAI,WAAW,QAAQ,EAAE,EAAE,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,IAAK,EAAU,CAAC;IACvD,CAAC;IAED;;;OAGG;IACH,IAAI,aAAa,CAAC,KAAU;QAC1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW;QACb,OAAO,MAAM,CAAC,MAAM,CAClB;YACE,GAAG,EAAE,EAAE;YACP,QAAQ,EAAE,EAAE;YACZ,SAAS,EAAE,EAAE;SACd,EACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,CAAC,CAClC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW,CAAC,WAAkC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;QAChC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEjF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;YAC/C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import {ControllerMiddlewares, Provider, ProviderType, TokenProvider} from \"@tsed/di\";\nimport {ROUTER_OPTIONS} from \"../constants/routerOptions\";\n\nlet AUTO_INC = 0;\n\nexport class ControllerProvider<T = any> extends Provider<T> {\n readonly tokenRouter: string;\n\n constructor(provide: TokenProvider, options: Partial<Provider> = {}) {\n super(provide, options);\n this.type = ProviderType.CONTROLLER;\n this.tokenRouter = `${this.name}_ROUTER_${AUTO_INC++}`;\n }\n\n /**\n *\n */\n get routerOptions(): any {\n return this.store.get(ROUTER_OPTIONS) || ({} as any);\n }\n\n /**\n *\n * @param value\n */\n set routerOptions(value: any) {\n this.store.set(ROUTER_OPTIONS, value);\n }\n\n /**\n *\n * @returns {any[]}\n */\n get middlewares(): ControllerMiddlewares {\n return Object.assign(\n {\n use: [],\n useAfter: [],\n useBefore: []\n },\n this.store.get(\"middlewares\", {})\n );\n }\n\n /**\n *\n * @param middlewares\n */\n set middlewares(middlewares: ControllerMiddlewares) {\n const mdlwrs = this.middlewares;\n const concat = (key: string, a: any, b: any) => (a[key] = a[key].concat(b[key]));\n\n Object.keys(middlewares).forEach((key: string) => {\n concat(key, mdlwrs, middlewares);\n });\n this.store.set(\"middlewares\", mdlwrs);\n }\n}\n"]}
@@ -1,58 +0,0 @@
1
- import { nameOf } from "@tsed/core";
2
- import { ProviderScope } from "@tsed/di";
3
- import { ParamTypes } from "@tsed/platform-params";
4
- import { JsonParameterStore } from "@tsed/schema";
5
- import { HandlerType } from "../interfaces/HandlerType.js";
6
- export class HandlerMetadata {
7
- target;
8
- token;
9
- propertyKey;
10
- injectable = false;
11
- type = HandlerType.RAW_FN;
12
- hasNextFunction = false;
13
- routeOptions;
14
- scope;
15
- handler;
16
- constructor(options) {
17
- const { target, token, propertyKey, type, scope, routeOptions } = options;
18
- this.type = type || target.type || HandlerType.RAW_FN;
19
- this.scope = scope || ProviderScope.SINGLETON;
20
- this.routeOptions = routeOptions || {};
21
- const handler = propertyKey ? target.prototype[propertyKey] : target;
22
- if (propertyKey) {
23
- this.target = target;
24
- this.token = token;
25
- this.propertyKey = propertyKey;
26
- this.hasNextFunction = this.hasParamType(ParamTypes.NEXT_FN);
27
- if (this.hasParamType(ParamTypes.ERR)) {
28
- this.type = HandlerType.ERR_MIDDLEWARE;
29
- }
30
- this.injectable = JsonParameterStore.getParams(target, propertyKey).length > 0;
31
- }
32
- else {
33
- this.handler = handler;
34
- }
35
- if (!this.injectable) {
36
- if (handler.length === 4) {
37
- this.type = HandlerType.RAW_ERR_FN;
38
- }
39
- this.hasNextFunction = handler.length >= 3;
40
- }
41
- }
42
- get hasErrorParam() {
43
- return this.type === HandlerType.ERR_MIDDLEWARE || this.type === HandlerType.RAW_ERR_FN;
44
- }
45
- getParams() {
46
- return JsonParameterStore.getParams(this.target, this.propertyKey) || [];
47
- }
48
- hasParamType(paramType) {
49
- return this.getParams().findIndex((p) => p.paramType === paramType) > -1;
50
- }
51
- isFinal() {
52
- return this.routeOptions?.isFinal || false;
53
- }
54
- toString() {
55
- return [this.target && nameOf(this.target), this.propertyKey].filter(Boolean).join(".");
56
- }
57
- }
58
- //# sourceMappingURL=HandlerMetadata.js.map
@@ -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;IACjB,MAAM,CAAM;IACZ,KAAK,CAAY;IACjB,WAAW,CAAkB;IAC7B,UAAU,GAAY,KAAK,CAAC;IAC5B,IAAI,GAAgB,WAAW,CAAC,MAAM,CAAC;IACvC,eAAe,GAAY,KAAK,CAAC;IACjC,YAAY,CAAgC;IAC5C,KAAK,CAAgB;IAE9B,OAAO,CAAM;IAEb,YAAY,OAA+B;QACzC,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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OAAO,IAAI,CAAC,YAAY,EAAE,OAAO,IAAI,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
- /**
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,111 +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
- platformHandler;
16
- adapter;
17
- rawRouter;
18
- raw;
19
- isBuilt = false;
20
- injector;
21
- callback;
22
- constructor(platformHandler, adapter, routerOptions = {}) {
23
- this.platformHandler = platformHandler;
24
- this.adapter = adapter;
25
- const { router, callback } = adapter.router(routerOptions);
26
- this.rawRouter = this.raw = router;
27
- this.callback = callback;
28
- }
29
- /**
30
- * Create a new instance of PlatformRouter
31
- * @param injector
32
- * @param routerOptions
33
- */
34
- static create(injector, routerOptions = {}) {
35
- const locals = new Map();
36
- locals.set(PLATFORM_ROUTER_OPTIONS, routerOptions);
37
- return injector.invoke(PlatformRouter_1, locals);
38
- }
39
- getRouter() {
40
- return this.rawRouter;
41
- }
42
- use(...handlers) {
43
- // @ts-ignore
44
- this.getRouter().use(...this.mapHandlers(handlers));
45
- return this;
46
- }
47
- addRoute(options) {
48
- const { method, path, handlers, ...opts } = options;
49
- // @ts-ignore
50
- this.getRouter()[method](path, ...this.mapHandlers(handlers, { method, path, ...opts }));
51
- return this;
52
- }
53
- all(path, ...handlers) {
54
- return this.addRoute({ method: "all", path, handlers, isFinal: true });
55
- }
56
- get(path, ...handlers) {
57
- return this.addRoute({ method: "get", path, handlers, isFinal: true });
58
- }
59
- post(path, ...handlers) {
60
- return this.addRoute({ method: "post", path, handlers, isFinal: true });
61
- }
62
- put(path, ...handlers) {
63
- return this.addRoute({ method: "put", path, handlers, isFinal: true });
64
- }
65
- delete(path, ...handlers) {
66
- return this.addRoute({ method: "delete", path, handlers, isFinal: true });
67
- }
68
- patch(path, ...handlers) {
69
- return this.addRoute({ method: "patch", path, handlers, isFinal: true });
70
- }
71
- head(path, ...handlers) {
72
- return this.addRoute({ method: "head", path, handlers, isFinal: true });
73
- }
74
- options(path, ...handlers) {
75
- return this.addRoute({ method: "options", path, handlers, isFinal: true });
76
- }
77
- statics(path, options) {
78
- return this.use(path, this.adapter.statics(path, options));
79
- }
80
- multer(options) {
81
- return this.adapter.multipart(options);
82
- }
83
- mapHandlers(handlers, options = {}) {
84
- return handlers.reduce((list, handler, index) => {
85
- if (typeof handler === "string") {
86
- return list.concat(handler);
87
- }
88
- if (handler instanceof PlatformRouter_1) {
89
- return list.concat(handler.callback());
90
- }
91
- return list.concat(this.platformHandler.createHandler(handler, {
92
- ...options,
93
- isFinal: options.isFinal ? index === handlers.length - 1 : false
94
- }));
95
- }, []);
96
- }
97
- };
98
- __decorate([
99
- Inject(),
100
- __metadata("design:type", InjectorService)
101
- ], PlatformRouter.prototype, "injector", void 0);
102
- PlatformRouter = PlatformRouter_1 = __decorate([
103
- Injectable({
104
- scope: ProviderScope.INSTANCE
105
- }),
106
- __param(2, Inject(PLATFORM_ROUTER_OPTIONS)),
107
- __metadata("design:paramtypes", [PlatformHandler,
108
- PlatformAdapter, Object])
109
- ], PlatformRouter);
110
- export { PlatformRouter };
111
- //# sourceMappingURL=PlatformRouter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformRouter.js","sourceRoot":"","sources":["../../../src/services/PlatformRouter.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAY,aAAa,EAAC,MAAM,UAAU,CAAC;AACtF,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAIlD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAS3E;;;GAGG;AAIH,IAAa,cAAc,sBAA3B,MAAa,cAAc;IAWb;IACD;IAXX,SAAS,CAAS;IAClB,GAAG,CAAM;IACT,OAAO,GAAY,KAAK,CAAC;IAGzB,QAAQ,CAAkB;IAE1B,QA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AC;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,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,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,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,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,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,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
- };