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

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 (138) hide show
  1. package/lib/cjs/builder/PlatformBuilder.js +20 -10
  2. package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
  3. package/lib/cjs/decorators/params/error.js +1 -1
  4. package/lib/cjs/decorators/params/error.js.map +1 -1
  5. package/lib/cjs/domain/AnyToPromiseWithCtx.js +1 -3
  6. package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -1
  7. package/lib/cjs/domain/PlatformContext.js +18 -1
  8. package/lib/cjs/domain/PlatformContext.js.map +1 -1
  9. package/lib/cjs/domain/PlatformRouteDetails.js +0 -25
  10. package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -1
  11. package/lib/cjs/exports.js +1 -0
  12. package/lib/cjs/exports.js.map +1 -1
  13. package/lib/cjs/index.js +1 -7
  14. package/lib/cjs/index.js.map +1 -1
  15. package/lib/cjs/interfaces/Route.js.map +1 -1
  16. package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -1
  17. package/lib/cjs/services/FakeAdapter.js +5 -9
  18. package/lib/cjs/services/FakeAdapter.js.map +1 -1
  19. package/lib/cjs/services/Platform.js +41 -85
  20. package/lib/cjs/services/Platform.js.map +1 -1
  21. package/lib/cjs/services/PlatformAdapter.js +0 -2
  22. package/lib/cjs/services/PlatformAdapter.js.map +1 -1
  23. package/lib/cjs/services/PlatformApplication.js +27 -10
  24. package/lib/cjs/services/PlatformApplication.js.map +1 -1
  25. package/lib/cjs/services/PlatformHandler.js +87 -163
  26. package/lib/cjs/services/PlatformHandler.js.map +1 -1
  27. package/lib/cjs/services/PlatformMiddlewaresChain.js +2 -18
  28. package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
  29. package/lib/cjs/services/PlatformRequest.js +2 -2
  30. package/lib/cjs/services/PlatformRequest.js.map +1 -1
  31. package/lib/cjs/services/PlatformResponse.js +2 -2
  32. package/lib/cjs/services/PlatformResponse.js.map +1 -1
  33. package/lib/cjs/utils/createContext.js +2 -2
  34. package/lib/cjs/utils/createContext.js.map +1 -1
  35. package/lib/cjs/utils/createInjector.js +0 -2
  36. package/lib/cjs/utils/createInjector.js.map +1 -1
  37. package/lib/cjs/utils/ensureContext.js +16 -0
  38. package/lib/cjs/utils/ensureContext.js.map +1 -0
  39. package/lib/cjs/utils/printRoutes.js +10 -8
  40. package/lib/cjs/utils/printRoutes.js.map +1 -1
  41. package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
  42. package/lib/esm/builder/PlatformBuilder.js +20 -10
  43. package/lib/esm/builder/PlatformBuilder.js.map +1 -1
  44. package/lib/esm/decorators/params/error.js +1 -1
  45. package/lib/esm/decorators/params/error.js.map +1 -1
  46. package/lib/esm/domain/AnyToPromiseWithCtx.js +1 -3
  47. package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -1
  48. package/lib/esm/domain/PlatformContext.js +18 -1
  49. package/lib/esm/domain/PlatformContext.js.map +1 -1
  50. package/lib/esm/domain/PlatformRouteDetails.js +1 -23
  51. package/lib/esm/domain/PlatformRouteDetails.js.map +1 -1
  52. package/lib/esm/exports.js +1 -0
  53. package/lib/esm/exports.js.map +1 -1
  54. package/lib/esm/index.js +1 -7
  55. package/lib/esm/index.js.map +1 -1
  56. package/lib/esm/interfaces/Route.js.map +1 -1
  57. package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -1
  58. package/lib/esm/services/FakeAdapter.js +5 -9
  59. package/lib/esm/services/FakeAdapter.js.map +1 -1
  60. package/lib/esm/services/Platform.js +42 -86
  61. package/lib/esm/services/Platform.js.map +1 -1
  62. package/lib/esm/services/PlatformAdapter.js +0 -2
  63. package/lib/esm/services/PlatformAdapter.js.map +1 -1
  64. package/lib/esm/services/PlatformApplication.js +27 -10
  65. package/lib/esm/services/PlatformApplication.js.map +1 -1
  66. package/lib/esm/services/PlatformHandler.js +89 -165
  67. package/lib/esm/services/PlatformHandler.js.map +1 -1
  68. package/lib/esm/services/PlatformMiddlewaresChain.js +2 -18
  69. package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
  70. package/lib/esm/services/PlatformRequest.js +2 -2
  71. package/lib/esm/services/PlatformRequest.js.map +1 -1
  72. package/lib/esm/services/PlatformResponse.js +2 -2
  73. package/lib/esm/services/PlatformResponse.js.map +1 -1
  74. package/lib/esm/utils/createContext.js +2 -2
  75. package/lib/esm/utils/createContext.js.map +1 -1
  76. package/lib/esm/utils/createInjector.js +0 -2
  77. package/lib/esm/utils/createInjector.js.map +1 -1
  78. package/lib/esm/utils/ensureContext.js +12 -0
  79. package/lib/esm/utils/ensureContext.js.map +1 -0
  80. package/lib/esm/utils/printRoutes.js +10 -8
  81. package/lib/esm/utils/printRoutes.js.map +1 -1
  82. package/lib/esm/utils/setResponseHeaders.js.map +1 -1
  83. package/lib/types/builder/PlatformBuilder.d.ts +13 -11
  84. package/lib/types/domain/AnyToPromiseWithCtx.d.ts +1 -9
  85. package/lib/types/domain/PlatformContext.d.ts +14 -1
  86. package/lib/types/domain/PlatformRouteDetails.d.ts +6 -15
  87. package/lib/types/exports.d.ts +1 -0
  88. package/lib/types/index.d.ts +1 -7
  89. package/lib/types/interfaces/Route.d.ts +2 -3
  90. package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +1 -1
  91. package/lib/types/services/FakeAdapter.d.ts +7 -6
  92. package/lib/types/services/Platform.d.ts +11 -28
  93. package/lib/types/services/PlatformAdapter.d.ts +19 -10
  94. package/lib/types/services/PlatformApplication.d.ts +14 -6
  95. package/lib/types/services/PlatformHandler.d.ts +19 -55
  96. package/lib/types/services/PlatformMiddlewaresChain.d.ts +1 -2
  97. package/lib/types/services/PlatformRequest.d.ts +1 -5
  98. package/lib/types/services/PlatformResponse.d.ts +1 -2
  99. package/lib/types/services/PlatformTest.d.ts +2 -1
  100. package/lib/types/utils/createContext.d.ts +1 -1
  101. package/lib/types/utils/createInjector.d.ts +1 -1
  102. package/lib/types/utils/ensureContext.d.ts +2 -0
  103. package/package.json +16 -15
  104. package/lib/cjs/builder/PlatformControllerBuilder.js +0 -82
  105. package/lib/cjs/builder/PlatformControllerBuilder.js.map +0 -1
  106. package/lib/cjs/domain/ControllerProvider.js +0 -52
  107. package/lib/cjs/domain/ControllerProvider.js.map +0 -1
  108. package/lib/cjs/domain/HandlerMetadata.js +0 -62
  109. package/lib/cjs/domain/HandlerMetadata.js.map +0 -1
  110. package/lib/cjs/middlewares/bindEndpointMiddleware.js +0 -13
  111. package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +0 -1
  112. package/lib/cjs/services/PlatformRouter.js +0 -114
  113. package/lib/cjs/services/PlatformRouter.js.map +0 -1
  114. package/lib/cjs/utils/createHandlerMetadata.js +0 -49
  115. package/lib/cjs/utils/createHandlerMetadata.js.map +0 -1
  116. package/lib/cjs/utils/useCtxHandler.js +0 -15
  117. package/lib/cjs/utils/useCtxHandler.js.map +0 -1
  118. package/lib/esm/builder/PlatformControllerBuilder.js +0 -76
  119. package/lib/esm/builder/PlatformControllerBuilder.js.map +0 -1
  120. package/lib/esm/domain/ControllerProvider.js +0 -48
  121. package/lib/esm/domain/ControllerProvider.js.map +0 -1
  122. package/lib/esm/domain/HandlerMetadata.js +0 -58
  123. package/lib/esm/domain/HandlerMetadata.js.map +0 -1
  124. package/lib/esm/middlewares/bindEndpointMiddleware.js +0 -9
  125. package/lib/esm/middlewares/bindEndpointMiddleware.js.map +0 -1
  126. package/lib/esm/services/PlatformRouter.js +0 -111
  127. package/lib/esm/services/PlatformRouter.js.map +0 -1
  128. package/lib/esm/utils/createHandlerMetadata.js +0 -45
  129. package/lib/esm/utils/createHandlerMetadata.js.map +0 -1
  130. package/lib/esm/utils/useCtxHandler.js +0 -11
  131. package/lib/esm/utils/useCtxHandler.js.map +0 -1
  132. package/lib/types/builder/PlatformControllerBuilder.d.ts +0 -18
  133. package/lib/types/domain/ControllerProvider.d.ts +0 -24
  134. package/lib/types/domain/HandlerMetadata.d.ts +0 -32
  135. package/lib/types/middlewares/bindEndpointMiddleware.d.ts +0 -6
  136. package/lib/types/services/PlatformRouter.d.ts +0 -51
  137. package/lib/types/utils/createHandlerMetadata.d.ts +0 -8
  138. package/lib/types/utils/useCtxHandler.d.ts +0 -13
@@ -130,10 +130,7 @@ class PlatformBuilder {
130
130
  return this.build(module, settings).bootstrap();
131
131
  }
132
132
  callback(req, res) {
133
- if (req && res) {
134
- return this.app.callback()(req, res);
135
- }
136
- return this.app.callback();
133
+ return this.app.callback(req, res);
137
134
  }
138
135
  log(...data) {
139
136
  return !this.disableBootstrapLog && this.logger.info(...data, this.diff());
@@ -174,10 +171,8 @@ class PlatformBuilder {
174
171
  async runLifecycle() {
175
172
  (0, di_1.setLoggerConfiguration)(this.injector);
176
173
  await this.loadInjector();
177
- this.#adapter.useContext && this.#adapter.useContext();
178
- this.#adapter.useRouter && this.#adapter.useRouter();
174
+ this.#adapter.useContext();
179
175
  await this.loadRoutes();
180
- await this.logRoutes();
181
176
  return this;
182
177
  }
183
178
  async loadInjector() {
@@ -257,6 +252,12 @@ class PlatformBuilder {
257
252
  await this.loadStatics("$afterRoutesInit");
258
253
  await this.callHook("$afterRoutesInit");
259
254
  this.#adapter.afterLoadRoutes && (await this.#adapter.afterLoadRoutes());
255
+ await this.mapRouters();
256
+ }
257
+ async mapRouters() {
258
+ const layers = this.platform.getLayers();
259
+ this.#adapter.mapLayers(layers);
260
+ return this.logRoutes(layers.filter((layer) => layer.isProvider()));
260
261
  }
261
262
  diff() {
262
263
  const ms = di_1.colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);
@@ -279,11 +280,20 @@ class PlatformBuilder {
279
280
  async listenServers() {
280
281
  this.#listeners = await Promise.all(this.#servers.map((cb) => cb && cb()));
281
282
  }
282
- async logRoutes() {
283
- const { logger, platform } = this;
283
+ async logRoutes(layers) {
284
+ const { logger } = this;
284
285
  this.log("Routes mounted...");
285
286
  if (!this.settings.get("logger.disableRoutesSummary") && !this.disableBootstrapLog) {
286
- logger.info((0, printRoutes_1.printRoutes)(await this.injector.alterAsync("$logRoutes", platform.getRoutes())));
287
+ const routes = layers.map((layer) => {
288
+ return {
289
+ url: layer.path,
290
+ method: layer.method,
291
+ name: layer.opts.name || `${layer.provider.className}.constructor()`,
292
+ className: layer.opts.className || layer.provider.className,
293
+ methodClassName: layer.opts.methodClassName || ""
294
+ };
295
+ });
296
+ logger.info((0, printRoutes_1.printRoutes)(await this.injector.alterAsync("$logRoutes", routes)));
287
297
  }
288
298
  }
289
299
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAwC;AACxC,iCAAsG;AACtG,qEAAiE;AAKjE,mDAA8C;AAC9C,iEAAqF;AACrF,yEAAoE;AACpE,gEAA2D;AAC3D,kEAA6D;AAC7D,4DAAuD;AACvD,gEAA2D;AAC3D,kEAA6D;AAC7D,sDAAiD;AAEjD;;GAEG;AACH,MAAa,eAAe;IACnB,MAAM,CAAC,OAAO,CAAkC;IAE9C,IAAI,GAAW,EAAE,CAAC;IACjB,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;IACtB,SAAS,CAAkB;IAC3B,WAAW,CAAY;IACvB,QAAQ,CAA+B;IAChD,QAAQ,CAAgB;IACxB,QAAQ,CAA2C;IACnD,UAAU,GAA8B,EAAE,CAAC;IAE3C,YAAsB,OAAuD,EAAE,MAAY,EAAE,QAAqC;QAChI,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAE1B,MAAM,aAAa,GAAG,IAAA,mCAAgB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACzD,MAAM,YAAY,GAAuC,OAAO,IAAK,eAAe,CAAC,OAAe,CAAC;QACrG,MAAM,IAAI,GA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;IACL,CAAC;IAES,iBAAiB;QACzB,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAA,mCAAgB,EAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAA,qCAAiB,EAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAC5H,OAAO,CACC,CAAC;IACb,CAAC;IAES,KAAK,CAAC,aAAa;QAC3B,IAAI,CAAC,UAAU,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IAC7E,CAAC;IAES,KAAK,CAAC,SAAS;QACvB,MAAM,EAAC,MAAM,EAAE,QAAQ,EAAC,GAAG,IAAI,CAAC;QAEhC,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAE9B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,6BAA6B,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;YAClF,MAAM,CAAC,IAAI,CAAC,IAAA,yBAAW,EAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;SAC9F;IACH,CAAC;CACF;AAvUD,0CAuUC","sourcesContent":["import {nameOf, Type} from \"@tsed/core\";\nimport {colors, InjectorService, ProviderOpts, setLoggerConfiguration, TokenProvider} from \"@tsed/di\";\nimport {getMiddlewaresForHook} from \"@tsed/platform-middlewares\";\nimport type {IncomingMessage, Server, ServerResponse} from \"http\";\nimport type Https from \"https\";\nimport {PlatformStaticsSettings} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {Route} from \"../interfaces/Route\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformAdapter, PlatformBuilderSettings} from \"../services/PlatformAdapter\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {createHttpServer} from \"../utils/createHttpServer\";\nimport {createHttpsServer} from \"../utils/createHttpsServer\";\nimport {createInjector} from \"../utils/createInjector\";\nimport {getConfiguration} from \"../utils/getConfiguration\";\nimport {getStaticsOptions} from \"../utils/getStaticsOptions\";\nimport {printRoutes} from \"../utils/printRoutes\";\n\n/**\n * @platform\n */\nexport class PlatformBuilder<App = TsED.Application, Router = TsED.Router> {\n public static adapter: Type<PlatformAdapter<any, any>>;\n\n readonly name: string = \"\";\n protected startedAt = new Date();\n protected current = new Date();\n readonly #injector: InjectorService;\n readonly #rootModule: Type<any>;\n readonly #adapter: PlatformAdapter<App, Router>;\n #promise: Promise<this>;\n #servers: (() => Promise<Server | Https.Server>)[];\n #listeners: (Server | Https.Server)[] = [];\n\n protected constructor(adapter: Type<PlatformAdapter<App, Router>> | undefined, module: Type, settings: Partial<TsED.Configuration>) {\n this.#rootModule = module;\n\n const configuration = getConfiguration(settings, module);\n const adapterKlass: Type<PlatformAdapter<App, Router>> = adapter || (PlatformBuilder.adapter as any);\n const name = nameOf(adapterKlass).replace(\"Platform\", \"\").toLowerCase();\n\n configuration.PLATFORM_NAME = name;\n this.name = name;\n\n this.#injector = createInjector({\n adapter: adapterKlass,\n settings: configuration\n });\n\n this.#adapter = this.#injector.get<PlatformAdapter<App, Router>>(PlatformAdapter)!;\n\n this.createHttpServers();\n\n this.#adapter.onInit && this.#adapter.onInit();\n\n this.log(\"Injector created...\");\n }\n\n get injector(): InjectorService {\n return this.#injector;\n }\n\n get rootModule(): any {\n return this.#injector.get(this.#rootModule);\n }\n\n get app(): PlatformApplication<App, Router> {\n return this.injector.get<PlatformApplication<App, Router>>(PlatformApplication)!;\n }\n\n get platform() {\n return this.injector.get<Platform>(Platform)!;\n }\n\n get adapter() {\n return this.#adapter;\n }\n\n /**\n * Return the settings configured by the decorator @@Configuration@@.\n *\n * ```typescript\n * @Configuration({\n * rootDir: Path.resolve(__dirname),\n * port: 8000,\n * httpsPort: 8080,\n * mount: {\n * \"/rest\": \"${rootDir}/controllers/**\\/*.js\"\n * }\n * })\n * export class Server {\n * $onInit(){\n * console.log(this.settings); // {rootDir, port, httpsPort,...}\n * }\n * }\n * ```\n *\n * @returns {PlatformConfiguration}\n */\n get settings() {\n return this.injector.settings;\n }\n\n get logger() {\n return this.injector.logger;\n }\n\n get disableBootstrapLog() {\n return this.settings.get(\"logger.disableBootstrapLog\");\n }\n\n static create<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>) {\n return this.build(module, {\n httpsPort: false,\n httpPort: false,\n ...settings\n });\n }\n\n static build<App = TsED.Application, Router = TsED.Router>(\n module: Type<any>,\n {adapter, ...settings}: PlatformBuilderSettings<App, Router>\n ) {\n return new PlatformBuilder(adapter, module, settings);\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>) {\n return this.build<App, Router>(module, settings).bootstrap();\n }\n\n callback(): (req: IncomingMessage, res: ServerResponse) => void;\n callback(req: IncomingMessage, res: ServerResponse): void;\n callback(req?: IncomingMessage, res?: ServerResponse) {\n if (req && res) {\n return this.app.callback()(req, res);\n }\n\n return this.app.callback();\n }\n\n log(...data: any[]) {\n return !this.disableBootstrapLog && this.logger.info(...data, this.diff());\n }\n\n /**\n * Add classes to the components list\n * @param classes\n */\n public addComponents(classes: Type | Type[]) {\n this.settings.set(\"imports\", this.settings.get<any[]>(\"imports\", []).concat(classes));\n\n return this;\n }\n\n /**\n * Add classes decorated by @@Controller@@ to components container.\n *\n * ### Example\n *\n * ```typescript\n * @Controller('/ctrl')\n * class MyController{\n * }\n *\n * platform.addControllers('/rest', [MyController])\n * ```\n *\n * ::: tip\n * If the MyController class isn't decorated, the class will be ignored.\n * :::\n *\n * @param {string} endpoint\n * @param {any[]} controllers\n */\n public addControllers(endpoint: string, controllers: TokenProvider | TokenProvider[]) {\n [].concat(controllers).forEach((token) => {\n this.settings.routes.push({token, route: endpoint});\n });\n }\n\n public async runLifecycle() {\n setLoggerConfiguration(this.injector);\n\n await this.loadInjector();\n\n this.#adapter.useContext && this.#adapter.useContext();\n this.#adapter.useRouter && this.#adapter.useRouter();\n\n await this.loadRoutes();\n await this.logRoutes();\n\n return this;\n }\n\n async loadInjector() {\n const {injector} = this;\n this.log(\"Build providers\");\n\n await injector.loadModule(this.#rootModule);\n\n this.log(\"Settings and injector loaded...\");\n\n await this.callHook(\"$afterInit\");\n }\n\n async listen(network = true) {\n if (!this.#promise) {\n await this.bootstrap();\n }\n\n await this.callHook(\"$beforeListen\");\n\n if (network) {\n await this.listenServers();\n }\n\n await this.callHook(\"$afterListen\");\n\n await this.ready();\n }\n\n async stop() {\n await this.callHook(\"$onDestroy\");\n await this.injector.destroy();\n\n this.#listeners.map((server) => {\n return new Promise((resolve) => server.close(() => resolve(undefined)));\n });\n }\n\n public async ready() {\n const {startedAt} = this;\n\n await this.callHook(\"$onReady\");\n await this.injector.emit(\"$onServerReady\");\n\n this.log(`Started in ${new Date().getTime() - startedAt.getTime()} ms`);\n }\n\n async callHook(hook: string, ...args: any[]) {\n const {injector} = this;\n\n if (!this.disableBootstrapLog) {\n injector.logger.debug(`\\x1B[1mCall hook ${hook}\\x1B[22m`);\n }\n\n // Load middlewares for the given hook\n this.loadMiddlewaresFor(hook);\n\n // call hooks added by providers\n await injector.emit(hook, ...args);\n }\n\n async loadStatics(hook: string): Promise<void> {\n const statics = this.settings.get<PlatformStaticsSettings>(\"statics\");\n\n getStaticsOptions(statics).forEach(({path, options}) => {\n if (options.hook === hook) {\n this.platform.app.statics(path, options);\n }\n });\n }\n\n useProvider(token: Type<any>, settings?: Partial<ProviderOpts>) {\n this.injector.addProvider(token, settings);\n\n return this;\n }\n\n async bootstrap() {\n this.#promise = this.#promise || this.runLifecycle();\n\n return this.#promise;\n }\n\n protected async loadRoutes() {\n this.#adapter.beforeLoadRoutes && (await this.#adapter.beforeLoadRoutes());\n\n // istanbul ignore next\n if (this.settings.get(\"logger.level\") !== \"off\") {\n const {PlatformLogMiddleware} = await import(\"@tsed/platform-log-middleware\");\n this.app.use(PlatformLogMiddleware);\n }\n\n this.log(\"Load routes\");\n\n if (this.rootModule.$beforeRoutesInit) {\n await this.rootModule.$beforeRoutesInit();\n this.rootModule.$beforeRoutesInit = () => {};\n }\n\n await this.loadStatics(\"$beforeRoutesInit\");\n await this.callHook(\"$beforeRoutesInit\");\n\n const routes = this.injector.settings.get<Route[]>(\"routes\");\n\n this.platform.addRoutes(routes);\n\n await this.callHook(\"$onRoutesInit\");\n\n await this.loadStatics(\"$afterRoutesInit\");\n\n await this.callHook(\"$afterRoutesInit\");\n\n this.#adapter.afterLoadRoutes && (await this.#adapter.afterLoadRoutes());\n }\n\n protected diff() {\n const ms = colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);\n this.current = new Date();\n return ms;\n }\n\n /**\n * Load middlewares from configuration for the given hook\n * @param hook\n * @protected\n */\n protected loadMiddlewaresFor(hook: string): void {\n return getMiddlewaresForHook(hook, this.settings, \"$beforeRoutesInit\").forEach(({use}) => {\n this.app.use(use);\n });\n }\n\n protected createHttpServers() {\n this.#servers = [createHttpServer(this.#injector, this.callback()), createHttpsServer(this.#injector, this.callback())].filter(\n Boolean\n ) as any[];\n }\n\n protected async listenServers(): Promise<void> {\n this.#listeners = await Promise.all(this.#servers.map((cb) => cb && cb()));\n }\n\n protected async logRoutes() {\n const {logger, platform} = this;\n\n this.log(\"Routes mounted...\");\n\n if (!this.settings.get(\"logger.disableRoutesSummary\") && !this.disableBootstrapLog) {\n logger.info(printRoutes(await this.injector.alterAsync(\"$logRoutes\", platform.getRoutes())));\n }\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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AAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IAC7E,CAAC;IAES,KAAK,CAAC,SAAS,CAAC,MAAuB;QAC/C,MAAM,EAAC,MAAM,EAAC,GAAG,IAAI,CAAC;QAEtB,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAE9B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,6BAA6B,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;YAClF,MAAM,MAAM,GAA2B,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC1D,OAAO;oBACL,GAAG,EAAE,KAAK,CAAC,IAAI;oBACf,MAAM,EAAE,KAAK,CAAC,MAAM;oBACpB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS,gBAAgB;oBACpE,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS;oBAC3D,eAAe,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe,IAAI,EAAE;iBAC1B,CAAC;YAC5B,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,IAAI,CAAC,IAAA,yBAAW,EAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;SAChF;IACH,CAAC;CACF;AAlVD,0CAkVC","sourcesContent":["import {nameOf, Type} from \"@tsed/core\";\nimport {colors, InjectorService, ProviderOpts, setLoggerConfiguration, TokenProvider} from \"@tsed/di\";\nimport {getMiddlewaresForHook} from \"@tsed/platform-middlewares\";\nimport {PlatformLayer} from \"@tsed/platform-router\";\nimport type {IncomingMessage, Server, ServerResponse} from \"http\";\nimport type Https from \"https\";\nimport {PlatformStaticsSettings} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\nimport {Route} from \"../interfaces/Route\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformAdapter, PlatformBuilderSettings} from \"../services/PlatformAdapter\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {createHttpServer} from \"../utils/createHttpServer\";\nimport {createHttpsServer} from \"../utils/createHttpsServer\";\nimport {createInjector} from \"../utils/createInjector\";\nimport {getConfiguration} from \"../utils/getConfiguration\";\nimport {getStaticsOptions} from \"../utils/getStaticsOptions\";\nimport {printRoutes} from \"../utils/printRoutes\";\n\n/**\n * @platform\n */\nexport class PlatformBuilder<App = TsED.Application> {\n public static adapter: Type<PlatformAdapter<any>>;\n\n readonly name: string = \"\";\n protected startedAt = new Date();\n protected current = new Date();\n readonly #injector: InjectorService;\n readonly #rootModule: Type<any>;\n readonly #adapter: PlatformAdapter<App>;\n #promise: Promise<this>;\n #servers: (() => Promise<Server | Https.Server>)[];\n #listeners: (Server | Https.Server)[] = [];\n\n protected constructor(adapter: Type<PlatformAdapter<App>> | undefined, module: Type, settings: Partial<TsED.Configuration>) {\n this.#rootModule = module;\n\n const configuration = getConfiguration(settings, module);\n const adapterKlass: Type<PlatformAdapter<App>> = adapter || (PlatformBuilder.adapter as any);\n const name = nameOf(adapterKlass).replace(\"Platform\", \"\").toLowerCase();\n\n configuration.PLATFORM_NAME = name;\n this.name = name;\n\n this.#injector = createInjector({\n adapter: adapterKlass,\n settings: configuration\n });\n\n this.#adapter = this.#injector.get<PlatformAdapter<App>>(PlatformAdapter)!;\n\n this.createHttpServers();\n\n this.#adapter.onInit && this.#adapter.onInit();\n\n this.log(\"Injector created...\");\n }\n\n get injector(): InjectorService {\n return this.#injector;\n }\n\n get rootModule(): any {\n return this.#injector.get(this.#rootModule);\n }\n\n get app(): PlatformApplication<App> {\n return this.injector.get<PlatformApplication<App>>(PlatformApplication)!;\n }\n\n get platform() {\n return this.injector.get<Platform>(Platform)!;\n }\n\n get adapter() {\n return this.#adapter;\n }\n\n /**\n * Return the settings configured by the decorator @@Configuration@@.\n *\n * ```typescript\n * @Configuration({\n * rootDir: Path.resolve(__dirname),\n * port: 8000,\n * httpsPort: 8080,\n * mount: {\n * \"/rest\": \"${rootDir}/controllers/**\\/*.js\"\n * }\n * })\n * export class Server {\n * $onInit(){\n * console.log(this.settings); // {rootDir, port, httpsPort,...}\n * }\n * }\n * ```\n *\n * @returns {PlatformConfiguration}\n */\n get settings() {\n return this.injector.settings;\n }\n\n get logger() {\n return this.injector.logger;\n }\n\n get disableBootstrapLog() {\n return this.settings.get(\"logger.disableBootstrapLog\");\n }\n\n static create<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>) {\n return this.build(module, {\n httpsPort: false,\n httpPort: false,\n ...settings\n });\n }\n\n static build<App = TsED.Application>(module: Type<any>, {adapter, ...settings}: PlatformBuilderSettings<App>) {\n return new PlatformBuilder(adapter, module, settings);\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>) {\n return this.build<App>(module, settings).bootstrap();\n }\n\n callback(): (req: IncomingMessage, res: ServerResponse) => any;\n callback(req: IncomingMessage, res: ServerResponse): any;\n callback(req?: IncomingMessage, res?: ServerResponse) {\n return this.app.callback(req!, res!);\n }\n\n log(...data: any[]) {\n return !this.disableBootstrapLog && this.logger.info(...data, this.diff());\n }\n\n /**\n * Add classes to the components list\n * @param classes\n */\n public addComponents(classes: Type | Type[]) {\n this.settings.set(\"imports\", this.settings.get<any[]>(\"imports\", []).concat(classes));\n\n return this;\n }\n\n /**\n * Add classes decorated by @@Controller@@ to components container.\n *\n * ### Example\n *\n * ```typescript\n * @Controller('/ctrl')\n * class MyController{\n * }\n *\n * platform.addControllers('/rest', [MyController])\n * ```\n *\n * ::: tip\n * If the MyController class isn't decorated, the class will be ignored.\n * :::\n *\n * @param {string} endpoint\n * @param {any[]} controllers\n */\n public addControllers(endpoint: string, controllers: TokenProvider | TokenProvider[]) {\n [].concat(controllers).forEach((token) => {\n this.settings.routes.push({token, route: endpoint});\n });\n }\n\n public async runLifecycle() {\n setLoggerConfiguration(this.injector);\n\n await this.loadInjector();\n\n this.#adapter.useContext();\n\n await this.loadRoutes();\n\n return this;\n }\n\n async loadInjector() {\n const {injector} = this;\n this.log(\"Build providers\");\n\n await injector.loadModule(this.#rootModule);\n\n this.log(\"Settings and injector loaded...\");\n\n await this.callHook(\"$afterInit\");\n }\n\n async listen(network = true) {\n if (!this.#promise) {\n await this.bootstrap();\n }\n\n await this.callHook(\"$beforeListen\");\n\n if (network) {\n await this.listenServers();\n }\n\n await this.callHook(\"$afterListen\");\n\n await this.ready();\n }\n\n async stop() {\n await this.callHook(\"$onDestroy\");\n await this.injector.destroy();\n\n this.#listeners.map((server) => {\n return new Promise((resolve) => server.close(() => resolve(undefined)));\n });\n }\n\n public async ready() {\n const {startedAt} = this;\n\n await this.callHook(\"$onReady\");\n await this.injector.emit(\"$onServerReady\");\n\n this.log(`Started in ${new Date().getTime() - startedAt.getTime()} ms`);\n }\n\n async callHook(hook: string, ...args: any[]) {\n const {injector} = this;\n\n if (!this.disableBootstrapLog) {\n injector.logger.debug(`\\x1B[1mCall hook ${hook}\\x1B[22m`);\n }\n\n // Load middlewares for the given hook\n this.loadMiddlewaresFor(hook);\n\n // call hooks added by providers\n await injector.emit(hook, ...args);\n }\n\n async loadStatics(hook: string): Promise<void> {\n const statics = this.settings.get<PlatformStaticsSettings>(\"statics\");\n\n getStaticsOptions(statics).forEach(({path, options}) => {\n if (options.hook === hook) {\n this.platform.app.statics(path, options);\n }\n });\n }\n\n useProvider(token: Type<any>, settings?: Partial<ProviderOpts>) {\n this.injector.addProvider(token, settings);\n\n return this;\n }\n\n async bootstrap() {\n this.#promise = this.#promise || this.runLifecycle();\n\n return this.#promise;\n }\n\n protected async loadRoutes() {\n this.#adapter.beforeLoadRoutes && (await this.#adapter.beforeLoadRoutes());\n\n // istanbul ignore next\n if (this.settings.get(\"logger.level\") !== \"off\") {\n const {PlatformLogMiddleware} = await import(\"@tsed/platform-log-middleware\");\n this.app.use(PlatformLogMiddleware);\n }\n\n this.log(\"Load routes\");\n\n if (this.rootModule.$beforeRoutesInit) {\n await this.rootModule.$beforeRoutesInit();\n this.rootModule.$beforeRoutesInit = () => {};\n }\n\n await this.loadStatics(\"$beforeRoutesInit\");\n await this.callHook(\"$beforeRoutesInit\");\n\n const routes = this.injector.settings.get<Route[]>(\"routes\");\n\n this.platform.addRoutes(routes);\n\n await this.callHook(\"$onRoutesInit\");\n\n await this.loadStatics(\"$afterRoutesInit\");\n\n await this.callHook(\"$afterRoutesInit\");\n\n this.#adapter.afterLoadRoutes && (await this.#adapter.afterLoadRoutes());\n\n await this.mapRouters();\n }\n\n protected async mapRouters() {\n const layers = this.platform.getLayers();\n\n this.#adapter.mapLayers(layers);\n\n return this.logRoutes(layers.filter((layer) => layer.isProvider()));\n }\n\n protected diff() {\n const ms = colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);\n this.current = new Date();\n return ms;\n }\n\n /**\n * Load middlewares from configuration for the given hook\n * @param hook\n * @protected\n */\n protected loadMiddlewaresFor(hook: string): void {\n return getMiddlewaresForHook(hook, this.settings, \"$beforeRoutesInit\").forEach(({use}) => {\n this.app.use(use);\n });\n }\n\n protected createHttpServers() {\n this.#servers = [createHttpServer(this.#injector, this.callback()), createHttpsServer(this.#injector, this.callback())].filter(\n Boolean\n ) as any[];\n }\n\n protected async listenServers(): Promise<void> {\n this.#listeners = await Promise.all(this.#servers.map((cb) => cb && cb()));\n }\n\n protected async logRoutes(layers: PlatformLayer[]) {\n const {logger} = this;\n\n this.log(\"Routes mounted...\");\n\n if (!this.settings.get(\"logger.disableRoutesSummary\") && !this.disableBootstrapLog) {\n const routes: PlatformRouteDetails[] = layers.map((layer) => {\n return {\n url: layer.path,\n method: layer.method,\n name: layer.opts.name || `${layer.provider.className}.constructor()`,\n className: layer.opts.className || layer.provider.className,\n methodClassName: layer.opts.methodClassName || \"\"\n } as PlatformRouteDetails;\n });\n\n logger.info(printRoutes(await this.injector.alterAsync(\"$logRoutes\", routes)));\n }\n }\n}\n"]}
@@ -11,7 +11,7 @@ const platform_params_1 = require("@tsed/platform-params");
11
11
  function Err() {
12
12
  return (0, platform_params_1.UseParam)({
13
13
  paramType: platform_params_1.ParamTypes.ERR,
14
- dataPath: "err",
14
+ dataPath: "$ctx.error",
15
15
  useValidation: false,
16
16
  useConverter: false
17
17
  });
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../src/decorators/params/error.ts"],"names":[],"mappings":";;;AAAA,2DAA2D;AAE3D;;;;;GAKG;AACH,SAAgB,GAAG;IACjB,OAAO,IAAA,0BAAQ,EAAC;QACd,SAAS,EAAE,4BAAU,CAAC,GAAG;QACzB,QAAQ,EAAE,KAAK;QACf,aAAa,EAAE,KAAK;QACpB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;AACL,CAAC;AAPD,kBAOC","sourcesContent":["import {ParamTypes, UseParam} from \"@tsed/platform-params\";\n\n/**\n * @returns {Function}\n * @decorator\n * @operation\n * @input\n */\nexport function Err(): Function {\n return UseParam({\n paramType: ParamTypes.ERR,\n dataPath: \"err\",\n useValidation: false,\n useConverter: false\n });\n}\n"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../src/decorators/params/error.ts"],"names":[],"mappings":";;;AAAA,2DAA2D;AAE3D;;;;;GAKG;AACH,SAAgB,GAAG;IACjB,OAAO,IAAA,0BAAQ,EAAC;QACd,SAAS,EAAE,4BAAU,CAAC,GAAG;QACzB,QAAQ,EAAE,YAAY;QACtB,aAAa,EAAE,KAAK;QACpB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;AACL,CAAC;AAPD,kBAOC","sourcesContent":["import {ParamTypes, UseParam} from \"@tsed/platform-params\";\n\n/**\n * @returns {Function}\n * @decorator\n * @operation\n * @input\n */\nexport function Err(): Function {\n return UseParam({\n paramType: ParamTypes.ERR,\n dataPath: \"$ctx.error\",\n useValidation: false,\n useConverter: false\n });\n}\n"]}
@@ -4,11 +4,9 @@ exports.AnyToPromiseWithCtx = void 0;
4
4
  const core_1 = require("@tsed/core");
5
5
  class AnyToPromiseWithCtx extends core_1.AnyToPromise {
6
6
  $ctx;
7
- err;
8
- constructor({ $ctx, err }) {
7
+ constructor($ctx) {
9
8
  super();
10
9
  this.$ctx = $ctx;
11
- this.err = err;
12
10
  }
13
11
  isDone() {
14
12
  const { $ctx } = this;
@@ -1 +1 @@
1
- {"version":3,"file":"AnyToPromiseWithCtx.js","sourceRoot":"","sources":["../../../src/domain/AnyToPromiseWithCtx.ts"],"names":[],"mappings":";;;AAAA,qCAA0D;AAW1D,MAAa,mBAAoB,SAAQ,mBAAY;IAC5C,IAAI,CAAkB;IACtB,GAAG,CAAU;IAEpB,YAAY,EAAC,IAAI,EAAE,GAAG,EAAwB;QAC5C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,MAAM;QACJ,MAAM,EAAC,IAAI,EAAC,GAAG,IAAI,CAAC;QAEpB,OAAO,IAAI,EAAE,MAAM,EAAE,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAY;QACrB,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;QACL,IAAI,CAAC,IAAI,GAAG,IAAW,CAAC;IAC1B,CAAC;IAED,kBAAkB,CAAC,OAAY;QAC7B,OAAO,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IAC7C,CAAC;CACF;AA3BD,kDA2BC","sourcesContent":["import {AnyPromiseResult, AnyToPromise} from \"@tsed/core\";\nimport {PlatformContext} from \"./PlatformContext\";\n\n/**\n * @ignore\n */\nexport interface HandlerContextOptions {\n $ctx: PlatformContext;\n err?: any;\n}\n\nexport class AnyToPromiseWithCtx extends AnyToPromise {\n public $ctx: PlatformContext;\n public err: unknown;\n\n constructor({$ctx, err}: HandlerContextOptions) {\n super();\n this.$ctx = $ctx;\n this.err = err;\n }\n\n isDone(): boolean {\n const {$ctx} = this;\n\n return $ctx?.isDone() || super.isDone();\n }\n\n async call(cb: Function): Promise<AnyPromiseResult<any>> {\n return super.call(() => cb(this));\n }\n\n destroy() {\n this.$ctx = null as any;\n }\n\n isCanceledResponse(process: any) {\n return process === this.$ctx.getResponse();\n }\n}\n"]}
1
+ {"version":3,"file":"AnyToPromiseWithCtx.js","sourceRoot":"","sources":["../../../src/domain/AnyToPromiseWithCtx.ts"],"names":[],"mappings":";;;AAAA,qCAA0D;AAG1D,MAAa,mBAAoB,SAAQ,mBAAY;IAC5C,IAAI,CAAkB;IAE7B,YAAY,IAAqB;QAC/B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,MAAM;QACJ,MAAM,EAAC,IAAI,EAAC,GAAG,IAAI,CAAC;QAEpB,OAAO,IAAI,EAAE,MAAM,EAAE,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAY;QACrB,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;QACJ,IAAI,CAAC,IAAY,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,kBAAkB,CAAC,OAAY;QAC7B,OAAO,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IAC7C,CAAC;CACF;AAzBD,kDAyBC","sourcesContent":["import {AnyPromiseResult, AnyToPromise} from \"@tsed/core\";\nimport {PlatformContext} from \"./PlatformContext\";\n\nexport class AnyToPromiseWithCtx extends AnyToPromise {\n public $ctx: PlatformContext;\n\n constructor($ctx: PlatformContext) {\n super();\n this.$ctx = $ctx;\n }\n\n isDone(): boolean {\n const {$ctx} = this;\n\n return $ctx?.isDone() || super.isDone();\n }\n\n async call(cb: Function): Promise<AnyPromiseResult<any>> {\n return super.call(() => cb(this));\n }\n\n destroy() {\n (this.$ctx as any) = null;\n }\n\n isCanceledResponse(process: any) {\n return process === this.$ctx.getResponse();\n }\n}\n"]}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PlatformContext = void 0;
4
4
  const di_1 = require("@tsed/di");
5
+ const platform_router_1 = require("@tsed/platform-router");
5
6
  const schema_1 = require("@tsed/schema");
6
7
  const PlatformApplication_1 = require("../services/PlatformApplication");
7
8
  const PlatformRequest_1 = require("../services/PlatformRequest");
@@ -16,6 +17,10 @@ class PlatformContext extends di_1.DIContext {
16
17
  * The error caught by the current handler
17
18
  */
18
19
  error;
20
+ /**
21
+ *
22
+ */
23
+ next;
19
24
  /**
20
25
  * The current @@PlatformResponse@@.
21
26
  */
@@ -37,7 +42,7 @@ class PlatformContext extends di_1.DIContext {
37
42
  this.container.set(PlatformResponse_1.PlatformResponse, this.response);
38
43
  this.container.set(PlatformRequest_1.PlatformRequest, this.request);
39
44
  this.container.set(PlatformContext, this);
40
- this.response.setHeader("x-request-id", this.id);
45
+ this.event.response.setHeader("x-request-id", this.id);
41
46
  }
42
47
  /**
43
48
  * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
@@ -48,6 +53,18 @@ class PlatformContext extends di_1.DIContext {
48
53
  set endpoint(endpoint) {
49
54
  this.set(schema_1.EndpointMetadata, endpoint);
50
55
  }
56
+ /**
57
+ * The current @@PlatformHandlerMetadata@@ resolved by Ts.ED during the request.
58
+ */
59
+ get handlerMetadata() {
60
+ return this.get(platform_router_1.PlatformHandlerMetadata);
61
+ }
62
+ /**
63
+ * The current @@PlatformHandlerMetadata@@ resolved by Ts.ED during the request.
64
+ */
65
+ set handlerMetadata(metadata) {
66
+ this.set(platform_router_1.PlatformHandlerMetadata, metadata);
67
+ }
51
68
  get url() {
52
69
  return this.request.url;
53
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":";;;AAAA,iCAAqE;AACrE,yCAA8C;AAG9C,yEAAoE;AACpE,iEAA4D;AAC5D,mEAA8D;AAc9D,MAAa,eACX,SAAQ,cAAS;IAGV,KAAK,CAAgB;IAC5B;;OAEG;IACI,IAAI,CAAM;IACjB;;OAEG;IACI,KAAK,CAAW;IACvB;;OAEG;IACM,QAAQ,CAAO;IACxB;;OAEG;IACM,OAAO,CAAO;IAEf,iBAAiB,GAAa,EAAE,CAAC;IACzC,YAAY,GAAY,KAAK,CAAC;IAE9B,YAAY,OAA+B;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEvD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,mCAAgB,CAAC,CAAC,IAAI,CAAC,CAAC;QACtE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,iCAAe,CAAC,CAAC,IAAI,CAAC,CAAC;QAEnE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,mCAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,iCAAe,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S,EAAE,IAAI,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC;IACnF,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAO,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAO,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAS,CAAC;IAClC,CAAC;IAED,OAAO,CAAC,KAAoB;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AA/HD,0CA+HC","sourcesContent":["import {ContextMethods, DIContext, DIContextOptions} from \"@tsed/di\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {IncomingEvent} from \"../interfaces/IncomingEvent\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\ndeclare global {\n namespace TsED {\n export interface Context extends PlatformContext {}\n }\n}\n\nexport interface PlatformContextOptions extends DIContextOptions {\n event: IncomingEvent;\n ignoreUrlPatterns?: any[];\n endpoint?: EndpointMetadata;\n}\n\nexport class PlatformContext<PReq extends PlatformRequest = PlatformRequest, PRes extends PlatformResponse = PlatformResponse>\n extends DIContext\n implements ContextMethods\n{\n public event: IncomingEvent;\n /**\n * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n */\n public data: any;\n /**\n * The error caught by the current handler\n */\n public error?: unknown;\n /**\n * The current @@PlatformResponse@@.\n */\n readonly response: PRes;\n /**\n * The current @@PlatformRequest@@.\n */\n readonly request: PReq;\n\n private ignoreUrlPatterns: RegExp[] = [];\n #isDestroyed: boolean = false;\n\n constructor(options: PlatformContextOptions) {\n super(options);\n\n options.endpoint && (this.endpoint = options.endpoint);\n\n this.event = options.event;\n this.response = new (options.ResponseKlass || PlatformResponse)(this);\n this.request = new (options.RequestKlass || PlatformRequest)(this);\n\n this.request.request.$ctx = this;\n this.request.request.id = this.id;\n this.container.set(PlatformResponse, this.response);\n this.container.set(PlatformRequest, this.request);\n this.container.set(PlatformContext, this);\n\n this.response.setHeader(\"x-request-id\", this.id);\n }\n\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n get endpoint(): EndpointMetadata {\n return this.get(EndpointMetadata);\n }\n\n set endpoint(endpoint: EndpointMetadata) {\n this.set(EndpointMetadata, endpoint);\n }\n\n get url() {\n return this.request.url;\n }\n\n get app() {\n return this.injector.get<PlatformApplication>(PlatformApplication)!;\n }\n\n async destroy() {\n await super.destroy();\n\n this.upgrade({\n response: {\n isDone: true,\n statusCode: this.statusCode\n },\n request: {\n method: this.method,\n url: this.url,\n headers: this.headers,\n body: this.body,\n query: this.query,\n params: this.params\n }\n } as any);\n\n this.response.destroy();\n this.request.destroy();\n this.#isDestroyed = true;\n }\n\n isDone() {\n return this.request?.isAborted() || this.response?.isDone() || this.#isDestroyed;\n }\n\n /**\n * Return the framework request instance (Express, Koa, etc...)\n */\n getRequest<Req = any>(): Req {\n return this.request.getRequest<Req>();\n }\n\n /**\n * Return the framework response instance (Express, Koa, etc...)\n */\n getResponse<Res = any>(): Res {\n return this.response.getResponse<Res>();\n }\n\n /**\n * Get Node.js request\n */\n getReq(): IncomingMessage {\n return this.request.getReq();\n }\n\n /**\n * Get Node.js response\n */\n getRes(): ServerResponse {\n return this.response.getRes();\n }\n\n /**\n * Return the original application instance.\n */\n getApp<T = any>(): T {\n return this.app.getApp() as any;\n }\n\n upgrade(event: IncomingEvent) {\n this.event = event;\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":";;;AAAA,iCAAqE;AACrE,2DAA8D;AAC9D,yCAA8C;AAG9C,yEAAoE;AACpE,iEAA4D;AAC5D,mEAA8D;AAc9D,MAAa,eACX,SAAQ,cAAS;IAGV,KAAK,CAAgB;IAC5B;;OAEG;IACI,IAAI,CAAM;IACjB;;OAEG;IACI,KAAK,CAAW;IACvB;;OAEG;IACI,IAAI,CAAO;IAClB;;OAEG;IACM,QAAQ,CAAO;IACxB;;OAEG;IACM,OAAO,CAAO;IAEf,iBAAiB,GAAa,EAAE,CAAC;IACzC,YAAY,GAAY,KAAK,CAAC;IAE9B,YAAY,OAA+B;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEvD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,mCAAgB,CAAC,CAAC,IAAI,CAAC,CAAC;QACtE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,iCAAe,CAAC,CAAC,IAAI,CAAC,CAAC;QAEnE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,mCAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,iCAAe,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAClD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AC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC;IACnF,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAO,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAO,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAS,CAAC;IAClC,CAAC;IAED,OAAO,CAAC,KAAoB;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAjJD,0CAiJC","sourcesContent":["import {ContextMethods, DIContext, DIContextOptions} from \"@tsed/di\";\nimport {PlatformHandlerMetadata} from \"@tsed/platform-router\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {IncomingEvent} from \"../interfaces/IncomingEvent\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\ndeclare global {\n namespace TsED {\n export interface Context extends PlatformContext {}\n }\n}\n\nexport interface PlatformContextOptions extends DIContextOptions {\n event: IncomingEvent;\n ignoreUrlPatterns?: any[];\n endpoint?: EndpointMetadata;\n}\n\nexport class PlatformContext<PReq extends PlatformRequest = PlatformRequest, PRes extends PlatformResponse = PlatformResponse>\n extends DIContext\n implements ContextMethods\n{\n public event: IncomingEvent;\n /**\n * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n */\n public data: any;\n /**\n * The error caught by the current handler\n */\n public error?: unknown;\n /**\n *\n */\n public next?: any;\n /**\n * The current @@PlatformResponse@@.\n */\n readonly response: PRes;\n /**\n * The current @@PlatformRequest@@.\n */\n readonly request: PReq;\n\n private ignoreUrlPatterns: RegExp[] = [];\n #isDestroyed: boolean = false;\n\n constructor(options: PlatformContextOptions) {\n super(options);\n\n options.endpoint && (this.endpoint = options.endpoint);\n\n this.event = options.event;\n this.response = new (options.ResponseKlass || PlatformResponse)(this);\n this.request = new (options.RequestKlass || PlatformRequest)(this);\n\n this.request.request.$ctx = this;\n this.request.request.id = this.id;\n this.container.set(PlatformResponse, this.response);\n this.container.set(PlatformRequest, this.request);\n this.container.set(PlatformContext, this);\n\n this.event.response.setHeader(\"x-request-id\", this.id);\n }\n\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n get endpoint() {\n return this.get(EndpointMetadata);\n }\n\n set endpoint(endpoint: EndpointMetadata) {\n this.set(EndpointMetadata, endpoint);\n }\n\n /**\n * The current @@PlatformHandlerMetadata@@ resolved by Ts.ED during the request.\n */\n get handlerMetadata() {\n return this.get(PlatformHandlerMetadata);\n }\n\n /**\n * The current @@PlatformHandlerMetadata@@ resolved by Ts.ED during the request.\n */\n set handlerMetadata(metadata: PlatformHandlerMetadata) {\n this.set(PlatformHandlerMetadata, metadata);\n }\n\n get url() {\n return this.request.url;\n }\n\n get app() {\n return this.injector.get<PlatformApplication>(PlatformApplication)!;\n }\n\n async destroy() {\n await super.destroy();\n\n this.upgrade({\n response: {\n isDone: true,\n statusCode: this.statusCode\n },\n request: {\n method: this.method,\n url: this.url,\n headers: this.headers,\n body: this.body,\n query: this.query,\n params: this.params\n }\n } as any);\n\n this.response.destroy();\n this.request.destroy();\n this.#isDestroyed = true;\n }\n\n isDone() {\n return this.request?.isAborted() || this.response?.isDone() || this.#isDestroyed;\n }\n\n /**\n * Return the framework request instance (Express, Koa, etc...)\n */\n getRequest<Req = any>(): Req {\n return this.request.getRequest<Req>();\n }\n\n /**\n * Return the framework response instance (Express, Koa, etc...)\n */\n getResponse<Res = any>(): Res {\n return this.response.getResponse<Res>();\n }\n\n /**\n * Get Node.js request\n */\n getReq(): IncomingMessage {\n return this.request.getReq();\n }\n\n /**\n * Get Node.js response\n */\n getRes(): ServerResponse {\n return this.response.getRes();\n }\n\n /**\n * Return the original application instance.\n */\n getApp<T = any>(): T {\n return this.app.getApp() as any;\n }\n\n upgrade(event: IncomingEvent) {\n this.event = event;\n }\n}\n"]}
@@ -1,28 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlatformRouteDetails = void 0;
4
- const platform_params_1 = require("@tsed/platform-params");
5
- const schema_1 = require("@tsed/schema");
6
- class PlatformRouteDetails extends schema_1.JsonOperationRoute {
7
- rawBody;
8
- provider;
9
- constructor(options) {
10
- super(options);
11
- this.rawBody = !!this.endpoint.parameters.find((param) => param.paramType === platform_params_1.ParamTypes.RAW_BODY);
12
- // TMP FIX
13
- this.endpoint.set("route", this.url);
14
- }
15
- toJSON() {
16
- return {
17
- method: this.method,
18
- name: this.name,
19
- url: this.url,
20
- className: this.className,
21
- methodClassName: this.methodClassName,
22
- parameters: this.parameters,
23
- rawBody: this.rawBody
24
- };
25
- }
26
- }
27
- exports.PlatformRouteDetails = PlatformRouteDetails;
28
3
  //# sourceMappingURL=PlatformRouteDetails.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformRouteDetails.js","sourceRoot":"","sources":["../../../src/domain/PlatformRouteDetails.ts"],"names":[],"mappings":";;;AAAA,2DAAiD;AACjD,yCAAkE;AAGlE,MAAa,oBAAqB,SAAQ,2BAAoC;IACnE,OAAO,CAAU;IACjB,QAAQ,CAAqB;IAEtC,YAAY,OAAsC;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,4BAAU,CAAC,QAAQ,CAAC,CAAC;QAEnG,UAAU;QACV,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,MAAM;QACJ,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF;AAvBD,oDAuBC","sourcesContent":["import {ParamTypes} from \"@tsed/platform-params\";\nimport {EndpointMetadata, JsonOperationRoute} from \"@tsed/schema\";\nimport {ControllerProvider} from \"./ControllerProvider\";\n\nexport class PlatformRouteDetails extends JsonOperationRoute<EndpointMetadata> {\n readonly rawBody: boolean;\n readonly provider: ControllerProvider;\n\n constructor(options: Partial<PlatformRouteDetails>) {\n super(options);\n this.rawBody = !!this.endpoint.parameters.find((param) => param.paramType === ParamTypes.RAW_BODY);\n\n // TMP FIX\n this.endpoint.set(\"route\", this.url);\n }\n\n toJSON() {\n return {\n method: this.method,\n name: this.name,\n url: this.url,\n className: this.className,\n methodClassName: this.methodClassName,\n parameters: this.parameters,\n rawBody: this.rawBody\n };\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformRouteDetails.js","sourceRoot":"","sources":["../../../src/domain/PlatformRouteDetails.ts"],"names":[],"mappings":"","sourcesContent":["export interface PlatformRouteDetails {\n method: string;\n name: string;\n url: string;\n className: string;\n methodClassName: string;\n}\n"]}
@@ -12,6 +12,7 @@ tslib_1.__exportStar(require("@tsed/platform-cache"), exports);
12
12
  tslib_1.__exportStar(require("@tsed/platform-middlewares"), exports);
13
13
  tslib_1.__exportStar(require("@tsed/components-scan"), exports);
14
14
  tslib_1.__exportStar(require("@tsed/platform-log-middleware"), exports);
15
+ tslib_1.__exportStar(require("@tsed/platform-router"), exports);
15
16
  var logger_1 = require("@tsed/logger");
16
17
  Object.defineProperty(exports, "$log", { enumerable: true, get: function () { return logger_1.$log; } });
17
18
  Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
@@ -1 +1 @@
1
- {"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":";;;;AAAA,wBAAsB;AACtB,6BAA2B;AAE3B,mDAAyB;AACzB,gEAAsC;AACtC,oEAA0C;AAC1C,yEAA+C;AAC/C,+DAAqC;AACrC,qEAA2C;AAC3C,gEAAsC;AACtC,wEAA8C;AAE9C,uCAA0C;AAAlC,8FAAA,IAAI,OAAA;AAAE,gGAAA,MAAM,OAAA;AAEpB,uCAAqH;AAA7G,oGAAA,UAAU,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,6FAAA,GAAG,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,6FAAA,GAAG,OAAA;AAAE,+FAAA,KAAK,OAAA;AAAE,gGAAA,MAAM,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,iGAAA,OAAO,OAAA;AAAE,6FAAA,GAAG,OAAA","sourcesContent":["import \"@tsed/logger\";\nimport \"@tsed/logger-file\";\n\nexport * from \"@tsed/di\";\nexport * from \"@tsed/platform-params\";\nexport * from \"@tsed/platform-exceptions\";\nexport * from \"@tsed/platform-response-filter\";\nexport * from \"@tsed/platform-cache\";\nexport * from \"@tsed/platform-middlewares\";\nexport * from \"@tsed/components-scan\";\nexport * from \"@tsed/platform-log-middleware\";\n\nexport {$log, Logger} from \"@tsed/logger\";\n\nexport {AcceptMime, Location, Redirect, View, Get, Post, Put, Patch, Delete, Head, Options, All} from \"@tsed/schema\";\n"]}
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":";;;;AAAA,wBAAsB;AACtB,6BAA2B;AAE3B,mDAAyB;AACzB,gEAAsC;AACtC,oEAA0C;AAC1C,yEAA+C;AAC/C,+DAAqC;AACrC,qEAA2C;AAC3C,gEAAsC;AACtC,wEAA8C;AAC9C,gEAAsC;AAEtC,uCAA0C;AAAlC,8FAAA,IAAI,OAAA;AAAE,gGAAA,MAAM,OAAA;AAEpB,uCAAqH;AAA7G,oGAAA,UAAU,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,6FAAA,GAAG,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,6FAAA,GAAG,OAAA;AAAE,+FAAA,KAAK,OAAA;AAAE,gGAAA,MAAM,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,iGAAA,OAAO,OAAA;AAAE,6FAAA,GAAG,OAAA","sourcesContent":["import \"@tsed/logger\";\nimport \"@tsed/logger-file\";\n\nexport * from \"@tsed/di\";\nexport * from \"@tsed/platform-params\";\nexport * from \"@tsed/platform-exceptions\";\nexport * from \"@tsed/platform-response-filter\";\nexport * from \"@tsed/platform-cache\";\nexport * from \"@tsed/platform-middlewares\";\nexport * from \"@tsed/components-scan\";\nexport * from \"@tsed/platform-log-middleware\";\nexport * from \"@tsed/platform-router\";\n\nexport {$log, Logger} from \"@tsed/logger\";\n\nexport {AcceptMime, Location, Redirect, View, Get, Post, Put, Patch, Delete, Head, Options, All} from \"@tsed/schema\";\n"]}
package/lib/cjs/index.js CHANGED
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const tslib_1 = require("tslib");
7
7
  tslib_1.__exportStar(require("./exports"), exports);
8
8
  tslib_1.__exportStar(require("./builder/PlatformBuilder"), exports);
9
- tslib_1.__exportStar(require("./builder/PlatformControllerBuilder"), exports);
10
9
  tslib_1.__exportStar(require("./config/interfaces/ConverterSettings"), exports);
11
10
  tslib_1.__exportStar(require("./config/interfaces/PlatformLoggerSettings"), exports);
12
11
  tslib_1.__exportStar(require("./config/interfaces/PlatformMulterSettings"), exports);
@@ -21,9 +20,7 @@ tslib_1.__exportStar(require("./decorators/params/next"), exports);
21
20
  tslib_1.__exportStar(require("./decorators/params/request"), exports);
22
21
  tslib_1.__exportStar(require("./decorators/params/response"), exports);
23
22
  tslib_1.__exportStar(require("./domain/AnyToPromiseWithCtx"), exports);
24
- tslib_1.__exportStar(require("./domain/ControllerProvider"), exports);
25
23
  tslib_1.__exportStar(require("./domain/EndpointMetadata"), exports);
26
- tslib_1.__exportStar(require("./domain/HandlerMetadata"), exports);
27
24
  tslib_1.__exportStar(require("./domain/PlatformContext"), exports);
28
25
  tslib_1.__exportStar(require("./domain/PlatformRouteDetails"), exports);
29
26
  tslib_1.__exportStar(require("./interfaces/AfterInit"), exports);
@@ -43,7 +40,6 @@ tslib_1.__exportStar(require("./interfaces/ResponseErrorObject"), exports);
43
40
  tslib_1.__exportStar(require("./interfaces/Route"), exports);
44
41
  tslib_1.__exportStar(require("./middlewares/PlatformAcceptMimesMiddleware"), exports);
45
42
  tslib_1.__exportStar(require("./middlewares/PlatformMulterMiddleware"), exports);
46
- tslib_1.__exportStar(require("./middlewares/bindEndpointMiddleware"), exports);
47
43
  tslib_1.__exportStar(require("./services/FakeAdapter"), exports);
48
44
  tslib_1.__exportStar(require("./services/Platform"), exports);
49
45
  tslib_1.__exportStar(require("./services/PlatformAdapter"), exports);
@@ -52,17 +48,15 @@ tslib_1.__exportStar(require("./services/PlatformHandler"), exports);
52
48
  tslib_1.__exportStar(require("./services/PlatformMiddlewaresChain"), exports);
53
49
  tslib_1.__exportStar(require("./services/PlatformRequest"), exports);
54
50
  tslib_1.__exportStar(require("./services/PlatformResponse"), exports);
55
- tslib_1.__exportStar(require("./services/PlatformRouter"), exports);
56
51
  tslib_1.__exportStar(require("./services/PlatformTest"), exports);
57
52
  tslib_1.__exportStar(require("./utils/createContext"), exports);
58
- tslib_1.__exportStar(require("./utils/createHandlerMetadata"), exports);
59
53
  tslib_1.__exportStar(require("./utils/createHttpServer"), exports);
60
54
  tslib_1.__exportStar(require("./utils/createHttpsServer"), exports);
61
55
  tslib_1.__exportStar(require("./utils/createInjector"), exports);
56
+ tslib_1.__exportStar(require("./utils/ensureContext"), exports);
62
57
  tslib_1.__exportStar(require("./utils/getStaticsOptions"), exports);
63
58
  tslib_1.__exportStar(require("./utils/listenServer"), exports);
64
59
  tslib_1.__exportStar(require("./utils/mapReturnedResponse"), exports);
65
60
  tslib_1.__exportStar(require("./utils/printRoutes"), exports);
66
61
  tslib_1.__exportStar(require("./utils/setResponseHeaders"), exports);
67
- tslib_1.__exportStar(require("./utils/useCtxHandler"), exports);
68
62
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,oDAA0B;AAC1B,oEAA0C;AAC1C,8EAAoD;AACpD,gFAAsD;AACtD,qFAA2D;AAC3D,qFAA2D;AAC3D,sFAA4D;AAC5D,kFAAwD;AACxD,oEAA0C;AAC1C,6EAAmD;AACnD,4EAAkD;AAClD,4EAAkD;AAClD,oEAA0C;AAC1C,mEAAyC;AACzC,sEAA4C;AAC5C,uEAA6C;AAC7C,uEAA6C;AAC7C,sEAA4C;AAC5C,oEAA0C;AAC1C,mEAAyC;AACzC,mEAAyC;AACzC,wEAA8C;AAC9C,iEAAuC;AACvC,mEAAyC;AACzC,uEAA6C;AAC7C,kEAAwC;AACxC,oEAA0C;AAC1C,wEAA8C;AAC9C,mEAAyC;AACzC,qEAA2C;AAC3C,+DAAqC;AACrC,iEAAuC;AACvC,kEAAwC;AACxC,oEAA0C;AAC1C,4EAAkD;AAClD,2EAAiD;AACjD,6DAAmC;AACnC,sFAA4D;AAC5D,iFAAuD;AACvD,+EAAqD;AACrD,iEAAuC;AACvC,8DAAoC;AACpC,qEAA2C;AAC3C,yEAA+C;AAC/C,qEAA2C;AAC3C,8EAAoD;AACpD,qEAA2C;AAC3C,sEAA4C;AAC5C,oEAA0C;AAC1C,kEAAwC;AACxC,gEAAsC;AACtC,wEAA8C;AAC9C,mEAAyC;AACzC,oEAA0C;AAC1C,iEAAuC;AACvC,oEAA0C;AAC1C,+DAAqC;AACrC,sEAA4C;AAC5C,8DAAoC;AACpC,qEAA2C;AAC3C,gEAAsC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./builder/PlatformBuilder\";\nexport * from \"./builder/PlatformControllerBuilder\";\nexport * from \"./config/interfaces/ConverterSettings\";\nexport * from \"./config/interfaces/PlatformLoggerSettings\";\nexport * from \"./config/interfaces/PlatformMulterSettings\";\nexport * from \"./config/interfaces/PlatformStaticsSettings\";\nexport * from \"./config/services/PlatformConfiguration\";\nexport * from \"./constants/routerOptions\";\nexport * from \"./decorators/multer/multerFileSize\";\nexport * from \"./decorators/multer/multerOptions\";\nexport * from \"./decorators/multer/multipartFile\";\nexport * from \"./decorators/params/error\";\nexport * from \"./decorators/params/next\";\nexport * from \"./decorators/params/request\";\nexport * from \"./decorators/params/response\";\nexport * from \"./domain/AnyToPromiseWithCtx\";\nexport * from \"./domain/ControllerProvider\";\nexport * from \"./domain/EndpointMetadata\";\nexport * from \"./domain/HandlerMetadata\";\nexport * from \"./domain/PlatformContext\";\nexport * from \"./domain/PlatformRouteDetails\";\nexport * from \"./interfaces/AfterInit\";\nexport * from \"./interfaces/AfterListen\";\nexport * from \"./interfaces/AfterRoutesInit\";\nexport * from \"./interfaces/BeforeInit\";\nexport * from \"./interfaces/BeforeListen\";\nexport * from \"./interfaces/BeforeRoutesInit\";\nexport * from \"./interfaces/HandlerType\";\nexport * from \"./interfaces/IncomingEvent\";\nexport * from \"./interfaces/OnReady\";\nexport * from \"./interfaces/OnRequest\";\nexport * from \"./interfaces/OnResponse\";\nexport * from \"./interfaces/OnRoutesInit\";\nexport * from \"./interfaces/PlatformRouteOptions\";\nexport * from \"./interfaces/ResponseErrorObject\";\nexport * from \"./interfaces/Route\";\nexport * from \"./middlewares/PlatformAcceptMimesMiddleware\";\nexport * from \"./middlewares/PlatformMulterMiddleware\";\nexport * from \"./middlewares/bindEndpointMiddleware\";\nexport * from \"./services/FakeAdapter\";\nexport * from \"./services/Platform\";\nexport * from \"./services/PlatformAdapter\";\nexport * from \"./services/PlatformApplication\";\nexport * from \"./services/PlatformHandler\";\nexport * from \"./services/PlatformMiddlewaresChain\";\nexport * from \"./services/PlatformRequest\";\nexport * from \"./services/PlatformResponse\";\nexport * from \"./services/PlatformRouter\";\nexport * from \"./services/PlatformTest\";\nexport * from \"./utils/createContext\";\nexport * from \"./utils/createHandlerMetadata\";\nexport * from \"./utils/createHttpServer\";\nexport * from \"./utils/createHttpsServer\";\nexport * from \"./utils/createInjector\";\nexport * from \"./utils/getStaticsOptions\";\nexport * from \"./utils/listenServer\";\nexport * from \"./utils/mapReturnedResponse\";\nexport * from \"./utils/printRoutes\";\nexport * from \"./utils/setResponseHeaders\";\nexport * from \"./utils/useCtxHandler\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,oDAA0B;AAC1B,oEAA0C;AAC1C,gFAAsD;AACtD,qFAA2D;AAC3D,qFAA2D;AAC3D,sFAA4D;AAC5D,kFAAwD;AACxD,oEAA0C;AAC1C,6EAAmD;AACnD,4EAAkD;AAClD,4EAAkD;AAClD,oEAA0C;AAC1C,mEAAyC;AACzC,sEAA4C;AAC5C,uEAA6C;AAC7C,uEAA6C;AAC7C,oEAA0C;AAC1C,mEAAyC;AACzC,wEAA8C;AAC9C,iEAAuC;AACvC,mEAAyC;AACzC,uEAA6C;AAC7C,kEAAwC;AACxC,oEAA0C;AAC1C,wEAA8C;AAC9C,mEAAyC;AACzC,qEAA2C;AAC3C,+DAAqC;AACrC,iEAAuC;AACvC,kEAAwC;AACxC,oEAA0C;AAC1C,4EAAkD;AAClD,2EAAiD;AACjD,6DAAmC;AACnC,sFAA4D;AAC5D,iFAAuD;AACvD,iEAAuC;AACvC,8DAAoC;AACpC,qEAA2C;AAC3C,yEAA+C;AAC/C,qEAA2C;AAC3C,8EAAoD;AACpD,qEAA2C;AAC3C,sEAA4C;AAC5C,kEAAwC;AACxC,gEAAsC;AACtC,mEAAyC;AACzC,oEAA0C;AAC1C,iEAAuC;AACvC,gEAAsC;AACtC,oEAA0C;AAC1C,+DAAqC;AACrC,sEAA4C;AAC5C,8DAAoC;AACpC,qEAA2C","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./builder/PlatformBuilder\";\nexport * from \"./config/interfaces/ConverterSettings\";\nexport * from \"./config/interfaces/PlatformLoggerSettings\";\nexport * from \"./config/interfaces/PlatformMulterSettings\";\nexport * from \"./config/interfaces/PlatformStaticsSettings\";\nexport * from \"./config/services/PlatformConfiguration\";\nexport * from \"./constants/routerOptions\";\nexport * from \"./decorators/multer/multerFileSize\";\nexport * from \"./decorators/multer/multerOptions\";\nexport * from \"./decorators/multer/multipartFile\";\nexport * from \"./decorators/params/error\";\nexport * from \"./decorators/params/next\";\nexport * from \"./decorators/params/request\";\nexport * from \"./decorators/params/response\";\nexport * from \"./domain/AnyToPromiseWithCtx\";\nexport * from \"./domain/EndpointMetadata\";\nexport * from \"./domain/PlatformContext\";\nexport * from \"./domain/PlatformRouteDetails\";\nexport * from \"./interfaces/AfterInit\";\nexport * from \"./interfaces/AfterListen\";\nexport * from \"./interfaces/AfterRoutesInit\";\nexport * from \"./interfaces/BeforeInit\";\nexport * from \"./interfaces/BeforeListen\";\nexport * from \"./interfaces/BeforeRoutesInit\";\nexport * from \"./interfaces/HandlerType\";\nexport * from \"./interfaces/IncomingEvent\";\nexport * from \"./interfaces/OnReady\";\nexport * from \"./interfaces/OnRequest\";\nexport * from \"./interfaces/OnResponse\";\nexport * from \"./interfaces/OnRoutesInit\";\nexport * from \"./interfaces/PlatformRouteOptions\";\nexport * from \"./interfaces/ResponseErrorObject\";\nexport * from \"./interfaces/Route\";\nexport * from \"./middlewares/PlatformAcceptMimesMiddleware\";\nexport * from \"./middlewares/PlatformMulterMiddleware\";\nexport * from \"./services/FakeAdapter\";\nexport * from \"./services/Platform\";\nexport * from \"./services/PlatformAdapter\";\nexport * from \"./services/PlatformApplication\";\nexport * from \"./services/PlatformHandler\";\nexport * from \"./services/PlatformMiddlewaresChain\";\nexport * from \"./services/PlatformRequest\";\nexport * from \"./services/PlatformResponse\";\nexport * from \"./services/PlatformTest\";\nexport * from \"./utils/createContext\";\nexport * from \"./utils/createHttpServer\";\nexport * from \"./utils/createHttpsServer\";\nexport * from \"./utils/createInjector\";\nexport * from \"./utils/ensureContext\";\nexport * from \"./utils/getStaticsOptions\";\nexport * from \"./utils/listenServer\";\nexport * from \"./utils/mapReturnedResponse\";\nexport * from \"./utils/printRoutes\";\nexport * from \"./utils/setResponseHeaders\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Route.js","sourceRoot":"","sources":["../../../src/interfaces/Route.ts"],"names":[],"mappings":"","sourcesContent":["import {TokenProvider} from \"@tsed/di\";\nimport {ControllerProvider} from \"../domain/ControllerProvider\";\n\nexport interface Route extends Record<string, any> {\n route: string;\n token: TokenProvider;\n}\n\nexport interface RouteController {\n route: string;\n provider: ControllerProvider;\n}\n"]}
1
+ {"version":3,"file":"Route.js","sourceRoot":"","sources":["../../../src/interfaces/Route.ts"],"names":[],"mappings":"","sourcesContent":["import {Provider, TokenProvider} from \"@tsed/di\";\n\nexport interface Route extends Record<string, any> {\n route: string;\n token: TokenProvider;\n}\n\nexport interface RouteController {\n route: string;\n provider: Provider;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";;;;;AACA,iCAAiD;AACjD,iDAA4C;AAC5C,qEAAyE;AACzE,2DAA8C;AAE9C,yEAAoE;AAMpE,MAAa,eAAgB,SAAQ,uBAAU;IAC7C,YAAY,EAAe;QACzB,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;IACtB,CAAC;CACF;AAND,0CAMC;AAED;;GAEG;AAEH,IAAa,wBAAwB,gCAArC,MAAa,wBAAwB;IAEzB,QAAQ,CAAyB;IAGjC,GAAG,CAAsB;IAEnC,KAAK,CAAC,GAAG,CAAY,GAAY;QAC/B,IAAI;YACF,MAAM,EAAC,MAAM,EAAE,OAAO,GAAG,EAAE,EAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,0BAAwB,CAAC,CAAC;YAC1E,MAAM,QAAQ,GAA2B;gBACvC,GAAG,IAAI,CAAC,QAAQ;gBAChB,GAAG,OAAO;aACX,CAAC;YAEF,0BAA0B;YAC1B,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACpB,OAAO,QAAQ,CAAC,IAAI,CAAC;aACtB;YAED,MAAM,UAAU,GAAQ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC,CAAC;YAEnF,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;SAC9D;QAAC,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,CAAC,IAAI,EAAE;gBACX,MAAM,IAAI,eAAe,CAAC,EAAE,CAAC,CAAC;aAC/B;YAED,MAAM,EAAE,CAAC;SACV;IACH,CAAC;IAES,SAAS,CAAC,IAAwB;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AAjCC;IADC,IAAA,UAAK,EAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,4EAA4E;;;0DACtD;AAG3C;IADC,IAAA,WAAM,GAAE;sCACM,yCAAmB;qDAAC;AAEnC;IAAW,mBAAA,IAAA,yBAAO,GAAE,CAAA;;;;mDAuBnB;AA9BU,wBAAwB;IADpC,IAAA,iCAAU,GAAE;GACA,wBAAwB,CAmCpC;AAnCY,4DAAwB","sourcesContent":["import type {MulterError} from \"multer\";\nimport {Constant, Inject, Value} from \"@tsed/di\";\nimport {BadRequest} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\nimport {PlatformMulterField, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\n\nexport interface MulterInputOptions {\n fields: PlatformMulterField[];\n}\n\nexport class MulterException extends BadRequest {\n constructor(er: MulterError) {\n super(er.message);\n this.origin = er;\n this.name = er.code;\n }\n}\n\n/**\n * @middleware\n */\n@Middleware()\nexport class PlatformMulterMiddleware implements MiddlewareMethods {\n @Value(\"multer\", {}) // NOTE: don't use constant to getting multer configuration. See issue #1840\n protected settings: PlatformMulterSettings;\n\n @Inject()\n protected app: PlatformApplication;\n\n async use(@Context() ctx: Context) {\n try {\n const {fields, options = {}} = ctx.endpoint.get(PlatformMulterMiddleware);\n const settings: PlatformMulterSettings = {\n ...this.settings,\n ...options\n };\n\n /* istanbul ignore next */\n if (settings.storage) {\n delete settings.dest;\n }\n\n const middleware: any = this.app.multer(settings).fields(this.getFields({fields}));\n\n return await middleware(ctx.getRequest(), ctx.getResponse());\n } catch (er) {\n if (er.code) {\n throw new MulterException(er);\n }\n\n throw er;\n }\n }\n\n protected getFields(conf: MulterInputOptions) {\n return conf.fields.map(({name, maxCount}) => ({name, maxCount}));\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";;;;;AAAA,iCAAuC;AACvC,iDAA4C;AAC5C,qEAAyE;AACzE,2DAA8C;AAG9C,yEAAoE;AAMpE,MAAa,eAAgB,SAAQ,uBAAU;IAC7C,YAAY,EAAe;QACzB,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;IACtB,CAAC;CACF;AAND,0CAMC;AAED;;GAEG;AAEH,IAAa,wBAAwB,gCAArC,MAAa,wBAAwB;IAEzB,QAAQ,CAAyB;IAGjC,GAAG,CAAsB;IAEnC,KAAK,CAAC,GAAG,CAAY,GAAY;QAC/B,IAAI;YACF,MAAM,EAAC,MAAM,EAAE,OAAO,GAAG,EAAE,EAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,0BAAwB,CAAC,CAAC;YAC1E,MAAM,QAAQ,GAA2B;gBACvC,GAAG,IAAI,CAAC,QAAQ;gBAChB,GAAG,OAAO;aACX,CAAC;YAEF,0BAA0B;YAC1B,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACpB,OAAO,QAAQ,CAAC,IAAI,CAAC;aACtB;YAED,MAAM,UAAU,GAAQ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC,CAAC;YAEnF,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;SAC9D;QAAC,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,CAAC,IAAI,EAAE;gBACX,MAAM,IAAI,eAAe,CAAC,EAAE,CAAC,CAAC;aAC/B;YAED,MAAM,EAAE,CAAC;SACV;IACH,CAAC;IAES,SAAS,CAAC,IAAwB;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AAjCC;IADC,IAAA,UAAK,EAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,4EAA4E;;;0DACtD;AAG3C;IADC,IAAA,WAAM,GAAE;sCACM,yCAAmB;qDAAC;AAEnC;IAAW,mBAAA,IAAA,yBAAO,GAAE,CAAA;;;;mDAuBnB;AA9BU,wBAAwB;IADpC,IAAA,iCAAU,GAAE;GACA,wBAAwB,CAmCpC;AAnCY,4DAAwB","sourcesContent":["import {Inject, Value} from \"@tsed/di\";\nimport {BadRequest} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\nimport type {MulterError} from \"multer\";\nimport {PlatformMulterField, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\n\nexport interface MulterInputOptions {\n fields: PlatformMulterField[];\n}\n\nexport class MulterException extends BadRequest {\n constructor(er: MulterError) {\n super(er.message);\n this.origin = er;\n this.name = er.code;\n }\n}\n\n/**\n * @middleware\n */\n@Middleware()\nexport class PlatformMulterMiddleware implements MiddlewareMethods {\n @Value(\"multer\", {}) // NOTE: don't use constant to getting multer configuration. See issue #1840\n protected settings: PlatformMulterSettings;\n\n @Inject()\n protected app: PlatformApplication;\n\n async use(@Context() ctx: Context) {\n try {\n const {fields, options = {}} = ctx.endpoint.get(PlatformMulterMiddleware);\n const settings: PlatformMulterSettings = {\n ...this.settings,\n ...options\n };\n\n /* istanbul ignore next */\n if (settings.storage) {\n delete settings.dest;\n }\n\n const middleware: any = this.app.multer(settings).fields(this.getFields({fields}));\n\n return await middleware(ctx.getRequest(), ctx.getResponse());\n } catch (er) {\n if (er.code) {\n throw new MulterException(er);\n }\n\n throw er;\n }\n }\n\n protected getFields(conf: MulterInputOptions) {\n return conf.fields.map(({name, maxCount}) => ({name, maxCount}));\n }\n}\n"]}
@@ -33,21 +33,17 @@ class FakeAdapter {
33
33
  multipart(options) {
34
34
  return {};
35
35
  }
36
- router(routerOptions) {
37
- const router = FakeAdapter.createFakeRawDriver();
38
- return {
39
- router,
40
- callback() {
41
- return router;
42
- }
43
- };
44
- }
45
36
  statics(endpoint, options) {
46
37
  return {};
47
38
  }
48
39
  bodyParser(type) {
49
40
  return () => { };
50
41
  }
42
+ mapLayers(layers) { }
43
+ mapHandler(handler) {
44
+ return handler;
45
+ }
46
+ useContext() { }
51
47
  }
52
48
  exports.FakeAdapter = FakeAdapter;
53
49
  //# sourceMappingURL=FakeAdapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FakeAdapter.js","sourceRoot":"","sources":["../../../src/services/FakeAdapter.ts"],"names":[],"mappings":";;;AAKA,MAAa,WAAW;IACtB,SAAS,GAAmB,EAAE,CAAC;IAE/B,MAAM,CAAC,mBAAmB;QACxB,uBAAuB;QACvB,SAAS,aAAa,KAAI,CAAC;QAE3B,uBAAuB;QACvB,SAAS,GAAG;YACV,OAAO,IAAI,CAAC;QACd,CAAC;QAED,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,KAAK,GAAG,GAAG,CAAC;QAC1B,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;QACzB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;QACzB,aAAa,CAAC,MAAM,GAAG,GAAG,CAAC;QAC3B,aAAa,CAAC,OAAO,GAAG,GAAG,CAAC;QAE5B,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,GAAG;QACD,MAAM,GAAG,GAAG,WAAW,CAAC,mBAAmB,EAAE,CAAC;QAC9C,OAAO;YACL,GAAG;YACH,QAAQ;gBACN,OAAO,GAAG,CAAC;YACb,CAAC;SACF,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,OAA+B;QACvC,OAAO,EAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,aAAkB;QACvB,MAAM,MAAM,GAAG,WAAW,CAAC,mBAAmB,EAAE,CAAC;QACjD,OAAO;YACL,MAAM;YACN,QAAQ;gBACN,OAAO,MAAM,CAAC;YAChB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,OAA+B;QACvD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC;CACF;AAxDD,kCAwDC","sourcesContent":["import {ProviderOpts} from \"@tsed/di\";\nimport {PlatformAdapter} from \"./PlatformAdapter\";\nimport {PlatformMulter, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformStaticsOptions} from \"../config/interfaces/PlatformStaticsSettings\";\n\nexport class FakeAdapter implements PlatformAdapter<any, any> {\n providers: ProviderOpts[] = [];\n\n static createFakeRawDriver() {\n // istanbul ignore next\n function FakeRawDriver() {}\n\n // istanbul ignore next\n function use() {\n return this;\n }\n\n FakeRawDriver.use = use;\n FakeRawDriver.all = use;\n FakeRawDriver.get = use;\n FakeRawDriver.patch = use;\n FakeRawDriver.post = use;\n FakeRawDriver.put = use;\n FakeRawDriver.head = use;\n FakeRawDriver.delete = use;\n FakeRawDriver.options = use;\n\n return FakeRawDriver;\n }\n\n app(): {app: any; callback(): any} {\n const app = FakeAdapter.createFakeRawDriver();\n return {\n app,\n callback() {\n return app;\n }\n };\n }\n\n multipart(options: PlatformMulterSettings): PlatformMulter {\n return {} as any;\n }\n\n router(routerOptions: any): {router: any; callback(): any} {\n const router = FakeAdapter.createFakeRawDriver();\n return {\n router,\n callback() {\n return router;\n }\n };\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions): any {\n return {};\n }\n\n bodyParser(type: string): any {\n return () => {};\n }\n}\n"]}
1
+ {"version":3,"file":"FakeAdapter.js","sourceRoot":"","sources":["../../../src/services/FakeAdapter.ts"],"names":[],"mappings":";;;AAOA,MAAa,WAAW;IACtB,SAAS,GAAmB,EAAE,CAAC;IAE/B,MAAM,CAAC,mBAAmB;QACxB,uBAAuB;QACvB,SAAS,aAAa,KAAI,CAAC;QAE3B,uBAAuB;QACvB,SAAS,GAAG;YACV,OAAO,IAAI,CAAC;QACd,CAAC;QAED,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,KAAK,GAAG,GAAG,CAAC;QAC1B,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;QACzB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;QACzB,aAAa,CAAC,MAAM,GAAG,GAAG,CAAC;QAC3B,aAAa,CAAC,OAAO,GAAG,GAAG,CAAC;QAE5B,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,GAAG;QACD,MAAM,GAAG,GAAG,WAAW,CAAC,mBAAmB,EAAE,CAAC;QAC9C,OAAO;YACL,GAAG;YACH,QAAQ;gBACN,OAAO,GAAG,CAAC;YACb,CAAC;SACF,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,OAA+B;QACvC,OAAO,EAAS,CAAC;IACnB,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,OAA+B;QACvD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC;IAED,SAAS,CAAC,MAAuB,IAAG,CAAC;IAErC,UAAU,CAAC,OAAgD;QACzD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,UAAU,KAAI,CAAC;CAChB;AAtDD,kCAsDC","sourcesContent":["import {ProviderOpts} from \"@tsed/di\";\nimport {PlatformContextHandler, PlatformLayer} from \"@tsed/platform-router\";\nimport {PlatformMulter, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformStaticsOptions} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {PlatformContext} from \"../domain/PlatformContext\";\nimport {PlatformAdapter} from \"./PlatformAdapter\";\n\nexport class FakeAdapter implements PlatformAdapter<any> {\n providers: ProviderOpts[] = [];\n\n static createFakeRawDriver() {\n // istanbul ignore next\n function FakeRawDriver() {}\n\n // istanbul ignore next\n function use() {\n return this;\n }\n\n FakeRawDriver.use = use;\n FakeRawDriver.all = use;\n FakeRawDriver.get = use;\n FakeRawDriver.patch = use;\n FakeRawDriver.post = use;\n FakeRawDriver.put = use;\n FakeRawDriver.head = use;\n FakeRawDriver.delete = use;\n FakeRawDriver.options = use;\n\n return FakeRawDriver;\n }\n\n app(): {app: any; callback(): any} {\n const app = FakeAdapter.createFakeRawDriver();\n return {\n app,\n callback() {\n return app;\n }\n };\n }\n\n multipart(options: PlatformMulterSettings): PlatformMulter {\n return {} as any;\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions): any {\n return {};\n }\n\n bodyParser(type: string): any {\n return () => {};\n }\n\n mapLayers(layers: PlatformLayer[]) {}\n\n mapHandler(handler: PlatformContextHandler<PlatformContext>) {\n return handler;\n }\n\n useContext() {}\n}\n"]}