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

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 (151) hide show
  1. package/jest.config.js +14 -0
  2. package/lib/cjs/builder/PlatformBuilder.js +68 -63
  3. package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
  4. package/lib/cjs/builder/PlatformControllerBuilder.js +1 -1
  5. package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -1
  6. package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -1
  7. package/lib/cjs/config/services/PlatformConfiguration.js +0 -64
  8. package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -1
  9. package/lib/cjs/domain/AnyToPromiseWithCtx.js +4 -3
  10. package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -1
  11. package/lib/cjs/domain/ControllerProvider.js +1 -0
  12. package/lib/cjs/domain/ControllerProvider.js.map +1 -1
  13. package/lib/cjs/domain/HandlerMetadata.js +10 -5
  14. package/lib/cjs/domain/HandlerMetadata.js.map +1 -1
  15. package/lib/cjs/domain/PlatformContext.js +54 -31
  16. package/lib/cjs/domain/PlatformContext.js.map +1 -1
  17. package/lib/cjs/domain/PlatformRouteDetails.js +5 -1
  18. package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -1
  19. package/lib/cjs/index.js +0 -2
  20. package/lib/cjs/index.js.map +1 -1
  21. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +2 -1
  22. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  23. package/lib/cjs/middlewares/PlatformMulterMiddleware.js +2 -0
  24. package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -1
  25. package/lib/cjs/services/FakeAdapter.js +1 -3
  26. package/lib/cjs/services/FakeAdapter.js.map +1 -1
  27. package/lib/cjs/services/Platform.js +4 -2
  28. package/lib/cjs/services/Platform.js.map +1 -1
  29. package/lib/cjs/services/PlatformAdapter.js +12 -0
  30. package/lib/cjs/services/PlatformAdapter.js.map +1 -1
  31. package/lib/cjs/services/PlatformApplication.js +2 -0
  32. package/lib/cjs/services/PlatformApplication.js.map +1 -1
  33. package/lib/cjs/services/PlatformHandler.js +7 -4
  34. package/lib/cjs/services/PlatformHandler.js.map +1 -1
  35. package/lib/cjs/services/PlatformMiddlewaresChain.js +3 -1
  36. package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
  37. package/lib/cjs/services/PlatformRequest.js +16 -11
  38. package/lib/cjs/services/PlatformRequest.js.map +1 -1
  39. package/lib/cjs/services/PlatformResponse.js +15 -11
  40. package/lib/cjs/services/PlatformResponse.js.map +1 -1
  41. package/lib/cjs/services/PlatformRouter.js +7 -1
  42. package/lib/cjs/services/PlatformRouter.js.map +1 -1
  43. package/lib/cjs/services/PlatformTest.js +27 -9
  44. package/lib/cjs/services/PlatformTest.js.map +1 -1
  45. package/lib/cjs/utils/createContext.js +28 -13
  46. package/lib/cjs/utils/createContext.js.map +1 -1
  47. package/lib/cjs/utils/createHttpServer.js +3 -3
  48. package/lib/cjs/utils/createHttpServer.js.map +1 -1
  49. package/lib/cjs/utils/createHttpsServer.js +3 -3
  50. package/lib/cjs/utils/createHttpsServer.js.map +1 -1
  51. package/lib/cjs/utils/createInjector.js +6 -6
  52. package/lib/cjs/utils/createInjector.js.map +1 -1
  53. package/lib/cjs/utils/getConfiguration.js +6 -12
  54. package/lib/cjs/utils/getConfiguration.js.map +1 -1
  55. package/lib/cjs/utils/setResponseHeaders.js +7 -13
  56. package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
  57. package/lib/esm/builder/PlatformBuilder.js +45 -63
  58. package/lib/esm/builder/PlatformBuilder.js.map +1 -1
  59. package/lib/esm/builder/PlatformControllerBuilder.js +1 -1
  60. package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -1
  61. package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -1
  62. package/lib/esm/config/services/PlatformConfiguration.js +0 -64
  63. package/lib/esm/config/services/PlatformConfiguration.js.map +1 -1
  64. package/lib/esm/domain/AnyToPromiseWithCtx.js +4 -3
  65. package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -1
  66. package/lib/esm/domain/ControllerProvider.js +1 -0
  67. package/lib/esm/domain/ControllerProvider.js.map +1 -1
  68. package/lib/esm/domain/HandlerMetadata.js +10 -5
  69. package/lib/esm/domain/HandlerMetadata.js.map +1 -1
  70. package/lib/esm/domain/PlatformContext.js +54 -31
  71. package/lib/esm/domain/PlatformContext.js.map +1 -1
  72. package/lib/esm/domain/PlatformRouteDetails.js +5 -1
  73. package/lib/esm/domain/PlatformRouteDetails.js.map +1 -1
  74. package/lib/esm/index.js +0 -2
  75. package/lib/esm/index.js.map +1 -1
  76. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +2 -1
  77. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  78. package/lib/esm/middlewares/PlatformMulterMiddleware.js +2 -0
  79. package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -1
  80. package/lib/esm/services/FakeAdapter.js +1 -3
  81. package/lib/esm/services/FakeAdapter.js.map +1 -1
  82. package/lib/esm/services/Platform.js +4 -2
  83. package/lib/esm/services/Platform.js.map +1 -1
  84. package/lib/esm/services/PlatformAdapter.js +12 -0
  85. package/lib/esm/services/PlatformAdapter.js.map +1 -1
  86. package/lib/esm/services/PlatformApplication.js +2 -0
  87. package/lib/esm/services/PlatformApplication.js.map +1 -1
  88. package/lib/esm/services/PlatformHandler.js +8 -5
  89. package/lib/esm/services/PlatformHandler.js.map +1 -1
  90. package/lib/esm/services/PlatformMiddlewaresChain.js +3 -1
  91. package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
  92. package/lib/esm/services/PlatformRequest.js +16 -11
  93. package/lib/esm/services/PlatformRequest.js.map +1 -1
  94. package/lib/esm/services/PlatformResponse.js +15 -11
  95. package/lib/esm/services/PlatformResponse.js.map +1 -1
  96. package/lib/esm/services/PlatformRouter.js +7 -1
  97. package/lib/esm/services/PlatformRouter.js.map +1 -1
  98. package/lib/esm/services/PlatformTest.js +27 -9
  99. package/lib/esm/services/PlatformTest.js.map +1 -1
  100. package/lib/esm/utils/createContext.js +26 -12
  101. package/lib/esm/utils/createContext.js.map +1 -1
  102. package/lib/esm/utils/createHttpServer.js +3 -3
  103. package/lib/esm/utils/createHttpServer.js.map +1 -1
  104. package/lib/esm/utils/createHttpsServer.js +3 -3
  105. package/lib/esm/utils/createHttpsServer.js.map +1 -1
  106. package/lib/esm/utils/createInjector.js +7 -7
  107. package/lib/esm/utils/createInjector.js.map +1 -1
  108. package/lib/esm/utils/getConfiguration.js +8 -14
  109. package/lib/esm/utils/getConfiguration.js.map +1 -1
  110. package/lib/esm/utils/setResponseHeaders.js +7 -13
  111. package/lib/esm/utils/setResponseHeaders.js.map +1 -1
  112. package/lib/types/builder/PlatformBuilder.d.ts +6 -7
  113. package/lib/types/config/interfaces/PlatformLoggerSettings.d.ts +2 -43
  114. package/lib/types/config/services/PlatformConfiguration.d.ts +6 -22
  115. package/lib/types/domain/PlatformContext.d.ts +20 -14
  116. package/lib/types/domain/PlatformRouteDetails.d.ts +1 -7
  117. package/lib/types/index.d.ts +0 -2
  118. package/lib/types/services/PlatformRequest.d.ts +11 -8
  119. package/lib/types/services/PlatformResponse.d.ts +8 -9
  120. package/lib/types/services/PlatformTest.d.ts +2 -2
  121. package/lib/types/utils/createContext.d.ts +4 -1
  122. package/lib/types/utils/createHttpsServer.d.ts +1 -0
  123. package/lib/types/utils/createInjector.d.ts +1 -1
  124. package/lib/types/utils/listenServer.d.ts +2 -0
  125. package/package.json +26 -22
  126. package/readme.md +2 -1
  127. package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js +0 -3
  128. package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js.map +0 -1
  129. package/lib/cjs/middlewares/__mock__/FakeCtrl.js +0 -12
  130. package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +0 -1
  131. package/lib/cjs/utils/__mock__/Test1.js +0 -8
  132. package/lib/cjs/utils/__mock__/Test1.js.map +0 -1
  133. package/lib/cjs/utils/__mock__/Test2.js +0 -8
  134. package/lib/cjs/utils/__mock__/Test2.js.map +0 -1
  135. package/lib/cjs/utils/importProviders.js +0 -29
  136. package/lib/cjs/utils/importProviders.js.map +0 -1
  137. package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js +0 -2
  138. package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js.map +0 -1
  139. package/lib/esm/middlewares/__mock__/FakeCtrl.js +0 -9
  140. package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +0 -1
  141. package/lib/esm/utils/__mock__/Test1.js +0 -4
  142. package/lib/esm/utils/__mock__/Test1.js.map +0 -1
  143. package/lib/esm/utils/__mock__/Test2.js +0 -4
  144. package/lib/esm/utils/__mock__/Test2.js.map +0 -1
  145. package/lib/esm/utils/importProviders.js +0 -25
  146. package/lib/esm/utils/importProviders.js.map +0 -1
  147. package/lib/types/config/interfaces/EndpointDirectoriesSettings.d.ts +0 -3
  148. package/lib/types/middlewares/__mock__/FakeCtrl.d.ts +0 -2
  149. package/lib/types/utils/__mock__/Test1.d.ts +0 -3
  150. package/lib/types/utils/__mock__/Test2.d.ts +0 -3
  151. package/lib/types/utils/importProviders.d.ts +0 -10
@@ -2,26 +2,40 @@ import { PlatformContext } from "../domain/PlatformContext.js";
2
2
  import { PlatformRequest } from "../services/PlatformRequest.js";
3
3
  import { PlatformResponse } from "../services/PlatformResponse.js";
4
4
  import { v4 } from "uuid";
5
- const defaultReqIdBuilder = (req) => req.get("x-request-id") || v4().replace(/-/gi, "");
5
+ function defaultReqIdBuilder(req) {
6
+ return req.get("x-request-id") || v4().split("-").join("");
7
+ }
8
+ function mapIgnoreUrlPatterns(ignoreUrlPatterns) {
9
+ return ignoreUrlPatterns.map((pattern) => (typeof pattern === "string" ? new RegExp(pattern, "gi") : pattern));
10
+ }
11
+ export function ignoreLog(ignoreUrlPatterns) {
12
+ if (ignoreUrlPatterns) {
13
+ ignoreUrlPatterns = mapIgnoreUrlPatterns(ignoreUrlPatterns);
14
+ return (ignore, data, url) => ignoreUrlPatterns?.find((reg) => !!url.match(reg));
15
+ }
16
+ }
6
17
  /**
7
18
  * Create the TsED context to wrap request, response, injector, etc...
8
19
  * @param injector
9
20
  * @ignore
10
21
  */
11
22
  export function createContext(injector) {
12
- var _a, _b;
13
- const ResponseKlass = (_a = injector.getProvider(PlatformResponse)) === null || _a === void 0 ? void 0 : _a.useClass;
14
- const RequestKlass = (_b = injector.getProvider(PlatformRequest)) === null || _b === void 0 ? void 0 : _b.useClass;
15
- const { reqIdBuilder = defaultReqIdBuilder, ...loggerOptions } = injector.settings.logger || {};
16
- return async (event) => {
23
+ const ResponseKlass = injector.getProvider(PlatformResponse)?.useClass;
24
+ const RequestKlass = injector.getProvider(PlatformRequest)?.useClass;
25
+ const { reqIdBuilder = defaultReqIdBuilder, ...loggerOptions } = injector.settings.logger;
26
+ const opts = {
27
+ logger: injector.logger,
28
+ ...loggerOptions,
29
+ ignoreLog: ignoreLog(loggerOptions.ignoreUrlPatterns),
30
+ injector,
31
+ ResponseKlass,
32
+ RequestKlass
33
+ };
34
+ return async function invokeContext(event) {
17
35
  const ctx = new PlatformContext({
36
+ ...opts,
18
37
  event,
19
- id: reqIdBuilder(event.request),
20
- logger: injector.logger,
21
- ...loggerOptions,
22
- injector,
23
- ResponseKlass,
24
- RequestKlass
38
+ id: reqIdBuilder(event.request)
25
39
  });
26
40
  ctx.response.onEnd(async () => {
27
41
  await ctx.emit("$onResponse", ctx);
@@ -1 +1 @@
1
- {"version":3,"file":"createContext.js","sourceRoot":"","sources":["../../../src/utils/createContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,g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Context\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\nimport {IncomingEvent} from \"../interfaces/IncomingEvent\";\nimport {v4} from \"uuid\";\n\nconst defaultReqIdBuilder = (req: any) => req.get(\"x-request-id\") || v4().replace(/-/gi, \"\");\n\n/**\n * Create the TsED context to wrap request, response, injector, etc...\n * @param injector\n * @ignore\n */\nexport function createContext(injector: InjectorService) {\n const ResponseKlass = injector.getProvider(PlatformResponse)?.useClass;\n const RequestKlass = injector.getProvider(PlatformRequest)?.useClass;\n const {reqIdBuilder = defaultReqIdBuilder, ...loggerOptions} = injector.settings.logger || {};\n\n return async (event: IncomingEvent): Promise<PlatformContext> => {\n const ctx = new PlatformContext({\n event,\n id: reqIdBuilder(event.request),\n logger: injector.logger,\n ...loggerOptions,\n injector,\n ResponseKlass,\n RequestKlass\n });\n\n ctx.response.onEnd(async () => {\n await ctx.emit(\"$onResponse\", ctx);\n await ctx.destroy();\n });\n\n await ctx.emit(\"$onRequest\", ctx);\n\n return ctx;\n };\n}\n"]}
1
+ {"version":3,"file":"createContext.js","sourceRoot":"","sources":["../../../src/utils/createContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAC,EAAE,EAAC,MAAM,MAAM,CAAC;AAExB,SAAS,mBAAmB,CAAC,GAAQ;IACnC,OAAO,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,oBAAoB,CAAC,iBAAwB;IACpD,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAC,OAAwB,EAAE,EAAE,CAAC,CAAC,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AC,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;YACnC,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC,CAAC,CAAC;QAEH,MAAM,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;QAElC,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {InjectorService} from \"@tsed/di\";\nimport {PlatformContext} from \"../domain/PlatformContext\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\nimport {IncomingEvent} from \"../interfaces/IncomingEvent\";\nimport {v4} from \"uuid\";\n\nfunction defaultReqIdBuilder(req: any) {\n return req.get(\"x-request-id\") || v4().split(\"-\").join(\"\");\n}\n\nfunction mapIgnoreUrlPatterns(ignoreUrlPatterns: any[]) {\n return ignoreUrlPatterns.map((pattern: string | RegExp) => (typeof pattern === \"string\" ? new RegExp(pattern, \"gi\") : pattern));\n}\n\nexport function ignoreLog(ignoreUrlPatterns: any[] | undefined) {\n if (ignoreUrlPatterns) {\n ignoreUrlPatterns = mapIgnoreUrlPatterns(ignoreUrlPatterns);\n return (ignore: boolean, data: any, url: string) => ignoreUrlPatterns?.find((reg) => !!url.match(reg));\n }\n}\n\n/**\n * Create the TsED context to wrap request, response, injector, etc...\n * @param injector\n * @ignore\n */\nexport function createContext(injector: InjectorService) {\n const ResponseKlass = injector.getProvider(PlatformResponse)?.useClass;\n const RequestKlass = injector.getProvider(PlatformRequest)?.useClass;\n const {reqIdBuilder = defaultReqIdBuilder, ...loggerOptions} = injector.settings.logger;\n\n const opts = {\n logger: injector.logger,\n ...loggerOptions,\n ignoreLog: ignoreLog(loggerOptions.ignoreUrlPatterns),\n injector,\n ResponseKlass,\n RequestKlass\n };\n\n return async function invokeContext(event: IncomingEvent) {\n const ctx = new PlatformContext({\n ...opts,\n event,\n id: reqIdBuilder(event.request)\n });\n\n ctx.response.onEnd(async () => {\n await ctx.emit(\"$onResponse\", ctx);\n await ctx.destroy();\n });\n\n await ctx.emit(\"$onRequest\", ctx);\n\n return ctx;\n };\n}\n"]}
@@ -4,8 +4,8 @@ import Http from "http";
4
4
  import { listenServer } from "./listenServer.js";
5
5
  export function createHttpServer(injector, requestListener) {
6
6
  const { settings } = injector;
7
- const httpPort = settings.getRaw("httpPort");
8
- const httpOptions = settings.getRaw("httpOptions");
7
+ const httpPort = settings.get("httpPort");
8
+ const httpOptions = settings.get("httpOptions");
9
9
  const server = httpPort !== false ? Http.createServer(httpOptions, requestListener) : null;
10
10
  injector.addProvider(Http.Server, {
11
11
  scope: ProviderScope.SINGLETON,
@@ -16,7 +16,7 @@ export function createHttpServer(injector, requestListener) {
16
16
  const hostInfo = getHostInfoFromPort("http", httpPort);
17
17
  return async () => {
18
18
  const resolvedHostInfo = await listenServer(injector, server, hostInfo);
19
- settings.setRaw("httpPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
19
+ settings.set("httpPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
20
20
  return server;
21
21
  };
22
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createHttpServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAC,MAAM,UAAU,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,gBAAgB,CAAC,QAAyB,EAAE,eAAqC;IAC/F,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAEnD,MAAM,MAAM,GAAG,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3F,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE;QAChC,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE7B,IAAI,MAAM,EAAE;QACV,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEvD,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,MAAqB,EAAE,QAAQ,CAAC,CAAC;YACvF,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,gBAAgB,CAAC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;YACpF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH;AACH,CAAC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Http from \"http\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpServer(injector: InjectorService, requestListener: Http.RequestListener) {\n const {settings} = injector;\n const httpPort = settings.getRaw(\"httpPort\");\n const httpOptions = settings.getRaw(\"httpOptions\");\n\n const server = httpPort !== false ? Http.createServer(httpOptions, requestListener) : null;\n\n injector.addProvider(Http.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(Http.Server);\n\n if (server) {\n const hostInfo = getHostInfoFromPort(\"http\", httpPort);\n\n return async () => {\n const resolvedHostInfo = await listenServer(injector, server as Http.Server, hostInfo);\n settings.setRaw(\"httpPort\", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);\n return server;\n };\n }\n}\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H;AACH,CAAC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Http from \"http\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpServer(injector: InjectorService, requestListener: Http.RequestListener) {\n const {settings} = injector;\n const httpPort = settings.get(\"httpPort\");\n const httpOptions = settings.get(\"httpOptions\");\n\n const server = httpPort !== false ? Http.createServer(httpOptions, requestListener) : null;\n\n injector.addProvider(Http.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(Http.Server);\n\n if (server) {\n const hostInfo = getHostInfoFromPort(\"http\", httpPort);\n\n return async () => {\n const resolvedHostInfo = await listenServer(injector, server as Http.Server, hostInfo);\n settings.set(\"httpPort\", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);\n return server;\n };\n }\n}\n"]}
@@ -4,8 +4,8 @@ import Https from "https";
4
4
  import { listenServer } from "./listenServer.js";
5
5
  export function createHttpsServer(injector, requestListener) {
6
6
  const { settings } = injector;
7
- const httpsPort = settings.getRaw("httpsPort");
8
- const httpsOptions = settings.getRaw("httpsOptions");
7
+ const httpsPort = settings.get("httpsPort");
8
+ const httpsOptions = settings.get("httpsOptions");
9
9
  const server = httpsPort !== false ? Https.createServer(httpsOptions, requestListener) : null;
10
10
  injector.addProvider(Https.Server, {
11
11
  scope: ProviderScope.SINGLETON,
@@ -16,7 +16,7 @@ export function createHttpsServer(injector, requestListener) {
16
16
  const hostInfo = getHostInfoFromPort("https", httpsPort);
17
17
  return async () => {
18
18
  const resolvedHostInfo = await listenServer(injector, server, hostInfo);
19
- settings.setRaw("httpsPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
19
+ settings.set("httpsPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
20
20
  return server;
21
21
  };
22
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createHttpsServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpsServer.ts"],"names":[],"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\";\nimport Https from \"https\";\nimport Http from \"http\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpsServer(injector: InjectorService, requestListener?: Http.RequestListener) {\n const {settings} = injector;\n const httpsPort = settings.getRaw(\"httpsPort\");\n const httpsOptions = settings.getRaw(\"httpsOptions\");\n\n const server = httpsPort !== false ? Https.createServer(httpsOptions, requestListener) : null;\n\n injector.addProvider(Https.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(Https.Server);\n\n if (server) {\n const hostInfo = getHostInfoFromPort(\"https\", httpsPort);\n\n return async () => {\n const resolvedHostInfo = await listenServer(injector, server as Https.Server, hostInfo);\n settings.setRaw(\"httpsPort\", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);\n return server;\n };\n }\n}\n"]}
1
+ {"version":3,"file":"createHttpsServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpsServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAC,MAAM,UAAU,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,iBAAiB,CAAC,QAAyB,EAAE,eAAsC;IACjG,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC5C,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAElD,MAAM,MAAM,GAAG,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE9F,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE;QACjC,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B,IAAI,MAAM,EAAE;QACV,MAAM,QAAQ,GAAG,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAEzD,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,MAAsB,EAAE,QAAQ,CAAC,CAAC;YACxF,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,gBAAgB,CAAC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;YAClF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH;AACH,CAAC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Https from \"https\";\nimport Http from \"http\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpsServer(injector: InjectorService, requestListener?: Http.RequestListener) {\n const {settings} = injector;\n const httpsPort = settings.get(\"httpsPort\");\n const httpsOptions = settings.get(\"httpsOptions\");\n\n const server = httpsPort !== false ? Https.createServer(httpsOptions, requestListener) : null;\n\n injector.addProvider(Https.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(Https.Server);\n\n if (server) {\n const hostInfo = getHostInfoFromPort(\"https\", httpsPort);\n\n return async () => {\n const resolvedHostInfo = await listenServer(injector, server as Https.Server, hostInfo);\n settings.set(\"httpsPort\", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);\n return server;\n };\n }\n}\n"]}
@@ -1,14 +1,14 @@
1
- import { InjectorService, setLoggerLevel } from "@tsed/di";
2
- import { $log } from "@tsed/logger";
3
1
  import { toMap } from "@tsed/core";
2
+ import { InjectorService, setLoggerConfiguration } from "@tsed/di";
3
+ import { $log } from "@tsed/logger";
4
4
  import { PlatformConfiguration } from "../config/services/PlatformConfiguration.js";
5
+ import { Platform } from "../services/Platform.js";
6
+ import { PlatformAdapter } from "../services/PlatformAdapter.js";
7
+ import { PlatformApplication } from "../services/PlatformApplication.js";
5
8
  import { PlatformHandler } from "../services/PlatformHandler.js";
9
+ import { PlatformRequest } from "../services/PlatformRequest.js";
6
10
  import { PlatformResponse } from "../services/PlatformResponse.js";
7
11
  import { PlatformRouter } from "../services/PlatformRouter.js";
8
- import { PlatformApplication } from "../services/PlatformApplication.js";
9
- import { Platform } from "../services/Platform.js";
10
- import { PlatformRequest } from "../services/PlatformRequest.js";
11
- import { PlatformAdapter } from "../services/PlatformAdapter.js";
12
12
  $log.name = "TSED";
13
13
  const DEFAULT_PROVIDERS = [
14
14
  { provide: PlatformHandler },
@@ -30,7 +30,7 @@ export function createInjector({ adapter, settings = {} }) {
30
30
  });
31
31
  }
32
32
  injector.invoke(PlatformAdapter);
33
- setLoggerLevel(injector);
33
+ setLoggerConfiguration(injector);
34
34
  const instance = injector.get(PlatformAdapter);
35
35
  instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];
36
36
  toMap(instance.providers, "provide").forEach((provider, token) => {
@@ -1 +1 @@
1
- {"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../src/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAgB,cAAc,EAAC,MAAM,UAAU,CAAC;AACvE,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAC,KAAK,EAAO,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,qBAAqB,EAAC,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAC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SAAS,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QAClF,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAErC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {InjectorService, ProviderOpts, setLoggerLevel} from \"@tsed/di\";\nimport {$log} from \"@tsed/logger\";\nimport {toMap, Type} from \"@tsed/core\";\nimport {PlatformConfiguration} from \"../config/services/PlatformConfiguration\";\nimport {PlatformHandler} from \"../services/PlatformHandler\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\nimport {PlatformRouter} from \"../services/PlatformRouter\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformAdapter} from \"../services/PlatformAdapter\";\n\n$log.name = \"TSED\";\n\nconst DEFAULT_PROVIDERS = [\n {provide: PlatformHandler},\n {provide: PlatformResponse},\n {provide: PlatformRequest},\n {provide: PlatformRouter},\n {provide: PlatformApplication},\n {provide: Platform}\n];\n\ninterface CreateInjectorOptions {\n adapter?: Type<PlatformAdapter<any, any>>;\n settings?: Partial<TsED.Configuration>;\n}\n\nexport function createInjector({adapter, settings = {}}: CreateInjectorOptions) {\n const injector = new InjectorService();\n injector.addProvider(PlatformConfiguration);\n\n injector.settings = injector.invoke(PlatformConfiguration);\n injector.logger = $log;\n injector.settings.set(settings);\n\n if (adapter) {\n injector.addProvider(PlatformAdapter, {\n useClass: adapter\n });\n }\n\n injector.invoke(PlatformAdapter);\n\n setLoggerLevel(injector);\n\n const instance = injector.get<PlatformAdapter>(PlatformAdapter)!;\n\n instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];\n\n toMap<any, ProviderOpts>(instance.providers, \"provide\").forEach((provider, token) => {\n injector.addProvider(token, provider);\n });\n\n injector.invoke(PlatformApplication);\n\n return injector;\n}\n"]}
1
+ {"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../src/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAO,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,eAAe,EAAgB,sBAAsB,EAAC,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAC,qBAAqB,EAAC,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAE1D,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;AAEnB,MAAM,iBAAiB,GAAG;IACxB,EAAC,OAAO,EAAE,eAAe,EAAC;IAC1B,EAAC,OAAO,EAAE,gBAAgB,EAAC;IAC3B,EAAC,OAAO,EAAE,eAAe,EAAC;IAC1B,EAAC,OAAO,EAAE,cAAc,EAAC;IACzB,EAAC,OAAO,EAAE,mBAAmB,EAAC;IAC9B,EAAC,OAAO,EAAE,QAAQ,EAAC;CACpB,CAAC;AAOF,MAAM,UAAU,cAAc,CAAC,EAAC,OAAO,EAAE,QAAQ,GAAG,EAAE,EAAwB;IAC5E,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAE5C,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAC3D,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEhC,IAAI,OAAO,EAAE;QACX,QAAQ,CAAC,WAAW,CAAC,eAAe,EAAE;YACpC,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;KACJ;IAED,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAEjC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAEjC,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAkB,eAAe,CAAE,CAAC;IAEjE,QAAQ,CAAC,SAAS,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAEnE,KAAK,CAAoB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QAClF,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAErC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {toMap, Type} from \"@tsed/core\";\nimport {InjectorService, ProviderOpts, setLoggerConfiguration} from \"@tsed/di\";\nimport {$log} from \"@tsed/logger\";\nimport {PlatformConfiguration} from \"../config/services/PlatformConfiguration\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformAdapter} from \"../services/PlatformAdapter\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformHandler} from \"../services/PlatformHandler\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\nimport {PlatformRouter} from \"../services/PlatformRouter\";\n\n$log.name = \"TSED\";\n\nconst DEFAULT_PROVIDERS = [\n {provide: PlatformHandler},\n {provide: PlatformResponse},\n {provide: PlatformRequest},\n {provide: PlatformRouter},\n {provide: PlatformApplication},\n {provide: Platform}\n];\n\ninterface CreateInjectorOptions {\n adapter?: Type<PlatformAdapter<any, any>>;\n settings?: Partial<TsED.Configuration>;\n}\n\nexport function createInjector({adapter, settings = {}}: CreateInjectorOptions) {\n const injector = new InjectorService();\n injector.addProvider(PlatformConfiguration);\n\n injector.settings = injector.invoke(PlatformConfiguration);\n injector.logger = $log;\n injector.settings.set(settings);\n\n if (adapter) {\n injector.addProvider(PlatformAdapter, {\n useClass: adapter\n });\n }\n\n injector.invoke(PlatformAdapter);\n\n setLoggerConfiguration(injector);\n\n const instance = injector.get<PlatformAdapter>(PlatformAdapter)!;\n\n instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];\n\n toMap<any, ProviderOpts>(instance.providers, \"provide\").forEach((provider, token) => {\n injector.addProvider(token, provider);\n });\n\n injector.invoke(PlatformApplication);\n\n return injector;\n}\n"]}
@@ -1,11 +1,13 @@
1
- import { deepMerge, Env, Store } from "@tsed/core";
2
- import { ProviderScope, ProviderType } from "@tsed/di";
1
+ import { Env, Store } from "@tsed/core";
2
+ import { mergeMount, ProviderScope, ProviderType } from "@tsed/di";
3
3
  export function getConfiguration(configuration = {}, module = null) {
4
+ if (configuration.$$resolved) {
5
+ return configuration;
6
+ }
4
7
  const store = module ? Store.from(module).get("configuration") || {} : {};
5
8
  const env = configuration.env || store.env || process.env.NODE_ENV || Env.DEV;
6
- const config = {
7
- exclude: ["**/*.spec.ts", "**/*.spec.js"],
8
- componentsScan: ["${rootDir}/mvc/**/*.ts", "${rootDir}/services/**/*.ts", "${rootDir}/middlewares/**/*.ts"],
9
+ return {
10
+ $$resolved: true,
9
11
  env,
10
12
  httpPort: 8080,
11
13
  httpsPort: false,
@@ -16,11 +18,7 @@ export function getConfiguration(configuration = {}, module = null) {
16
18
  ...store.scopes,
17
19
  ...configuration.scopes
18
20
  },
19
- mount: store.mount || configuration.mount
20
- ? deepMerge(store.mount || {}, configuration.mount || {})
21
- : {
22
- "/rest": "${rootDir}/controllers/**/*.ts"
23
- },
21
+ mount: mergeMount(store.mount, configuration.mount),
24
22
  logger: {
25
23
  debug: false,
26
24
  level: env === Env.TEST ? "off" : "info",
@@ -30,9 +28,5 @@ export function getConfiguration(configuration = {}, module = null) {
30
28
  jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2
31
29
  }
32
30
  };
33
- if (!configuration.disableComponentsScan && store.componentsScan && configuration.componentsScan) {
34
- config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];
35
- }
36
- return config;
37
31
  }
38
32
  //# sourceMappingURL=getConfiguration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getConfiguration.js","sourceRoot":"","sources":["../../../src/utils/getConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,GAAG,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AACvD,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AAErD,MAAM,UAAU,gBAAgB,CAAC,gBAAqB,EAAE,EAAE,SAA2B,IAAI;IACvF,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAK,OAAO,CAAC,GAAG,CAAC,QAAgB,IAAI,GAAG,CAAC,GAAG,CAAC;IAEvF,MAAM,MAAM,GAAG;QACb,OAAO,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC;QACzC,cAAc,EAAE,CAAC,wBAAwB,EAAE,6BAA6B,EAAE,gCAAgC,CAAC;QAC3G,GAAG;QACH,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,KAAK;QAChB,GAAG,KAAK;QACR,GAAG,aAAa;QAChB,MAAM,EAAE;YACN,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,SAAS;YAClD,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;SACxB;QACD,KAAK,EACH,KAAK,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK;YAChC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,aAAa,CAAC,KAAK,IAAI,EAAE,CAAC;YACzD,CAAC,CAAC;gBACE,OAAO,EAAE,gCAAgC;aAC1C;QACP,MAAM,EAAE;YACN,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;YACxC,UAAU,EAAE,IAAI;YAChB,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;YACvB,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3D;KACF,CAAC;IAEF,IAAI,CAAC,aAAa,CAAC,qBAAqB,IAAI,KAAK,CAAC,cAAc,IAAI,aAAa,CAAC,cAAc,EAAE;QAChG,MAAM,CAAC,cAAc,GAAG,CAAC,GAAG,KAAK,CAAC,cAAc,EAAE,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;KACpF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import {deepMerge, Env, Store, Type} from \"@tsed/core\";\nimport {ProviderScope, ProviderType} from \"@tsed/di\";\n\nexport function getConfiguration(configuration: any = {}, module: Type<any> | null = null) {\n const store = module ? Store.from(module).get(\"configuration\") || {} : {};\n const env = configuration.env || store.env || (process.env.NODE_ENV as Env) || Env.DEV;\n\n const config = {\n exclude: [\"**/*.spec.ts\", \"**/*.spec.js\"],\n componentsScan: [\"${rootDir}/mvc/**/*.ts\", \"${rootDir}/services/**/*.ts\", \"${rootDir}/middlewares/**/*.ts\"],\n env,\n httpPort: 8080,\n httpsPort: false,\n ...store,\n ...configuration,\n scopes: {\n [ProviderType.CONTROLLER]: ProviderScope.SINGLETON,\n ...store.scopes,\n ...configuration.scopes\n },\n mount:\n store.mount || configuration.mount\n ? deepMerge(store.mount || {}, configuration.mount || {})\n : {\n \"/rest\": \"${rootDir}/controllers/**/*.ts\"\n },\n logger: {\n debug: false,\n level: env === Env.TEST ? \"off\" : \"info\",\n logRequest: true,\n ...store.logger,\n ...configuration.logger,\n jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2\n }\n };\n\n if (!configuration.disableComponentsScan && store.componentsScan && configuration.componentsScan) {\n config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];\n }\n\n return config;\n}\n"]}
1
+ {"version":3,"file":"getConfiguration.js","sourceRoot":"","sources":["../../../src/utils/getConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAE,aAAa,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AAEjE,MAAM,UAAU,gBAAgB,CAAC,gBAAqB,EAAE,EAAE,SAA2B,IAAI;IACvF,IAAI,aAAa,CAAC,UAAU,EAAE;QAC5B,OAAO,aAAa,CAAC;KACtB;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAK,OAAO,CAAC,GAAG,CAAC,QAAgB,IAAI,GAAG,CAAC,GAAG,CAAC;IAEvF,OAAO;QACL,UAAU,EAAE,IAAI;QAChB,GAAG;QACH,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,KAAK;QAChB,GAAG,KAAK;QACR,GAAG,aAAa;QAChB,MAAM,EAAE;YACN,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,SAAS;YAClD,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;SACxB;QACD,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC;QACnD,MAAM,EAAE;YACN,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;YACxC,UAAU,EAAE,IAAI;YAChB,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;YACvB,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3D;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {Env, Store, Type} from \"@tsed/core\";\nimport {mergeMount, ProviderScope, ProviderType} from \"@tsed/di\";\n\nexport function getConfiguration(configuration: any = {}, module: Type<any> | null = null) {\n if (configuration.$$resolved) {\n return configuration;\n }\n\n const store = module ? Store.from(module).get(\"configuration\") || {} : {};\n const env = configuration.env || store.env || (process.env.NODE_ENV as Env) || Env.DEV;\n\n return {\n $$resolved: true,\n env,\n httpPort: 8080,\n httpsPort: false,\n ...store,\n ...configuration,\n scopes: {\n [ProviderType.CONTROLLER]: ProviderScope.SINGLETON,\n ...store.scopes,\n ...configuration.scopes\n },\n mount: mergeMount(store.mount, configuration.mount),\n logger: {\n debug: false,\n level: env === Env.TEST ? \"off\" : \"info\",\n logRequest: true,\n ...store.logger,\n ...configuration.logger,\n jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2\n }\n };\n}\n"]}
@@ -1,12 +1,3 @@
1
- function mergeHeaders(specHeaders, headers) {
2
- return Object.entries(specHeaders).reduce((headers, [key, item]) => {
3
- key = key.toLowerCase();
4
- return {
5
- ...headers,
6
- [key]: headers[key] === undefined ? String(item.example) : headers[key]
7
- };
8
- }, headers);
9
- }
10
1
  /**
11
2
  * @ignore
12
3
  */
@@ -21,11 +12,14 @@ export function setResponseHeaders(ctx) {
21
12
  response.status(operation.getStatus());
22
13
  }
23
14
  const statusCode = response.statusCode;
24
- const headers = operation.getHeadersOf(response.statusCode);
25
- const mergedHeaders = mergeHeaders(headers, response.getHeaders());
26
- response.setHeaders(mergedHeaders);
15
+ const headers = operation.getHeadersOf(statusCode);
16
+ Object.entries(headers).forEach(([key, item]) => {
17
+ if (!response.get(key)) {
18
+ response.setHeader(key, String(item.example));
19
+ }
20
+ });
27
21
  if (operation.isRedirection(statusCode)) {
28
- response.redirect(statusCode, String(mergedHeaders["location"]));
22
+ response.redirect(statusCode, response.get("location"));
29
23
  }
30
24
  }
31
25
  //# sourceMappingURL=setResponseHeaders.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setResponseHeaders.js","sourceRoot":"","sources":["../../../src/utils/setResponseHeaders.ts"],"names":[],"mappings":"AAIA,SAAS,YAAY,CAAC,WAA2D,EAAE,OAA4B;IAC7G,OAAO,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;QACjE,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACxB,OAAO;YACL,GAAG,OAAO;YACV,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;SACxE,CAAC;IACJ,CAAC,EAAE,OAAO,CAAC,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAoB;IACrD,MAAM,EAAC,QAAQ,EAAE,QAAQ,EAAC,GAAG,GAAG,CAAC;IACjC,MAAM,EAAC,SAAS,EAAC,GAAG,QAAQ,CAAC;IAE7B,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE;QACrB,OAAO;KACR;IAED,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;QACzB,kDAAkD;QAClD,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;KACxC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;IACvC,MAAM,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAEnE,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAEnC,IAAI,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE;QACvC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;KAClE;AACH,CAAC","sourcesContent":["import {JsonHeader} from \"@tsed/schema\";\nimport {OutgoingHttpHeaders} from \"http\";\nimport {PlatformContext} from \"../domain/PlatformContext\";\n\nfunction mergeHeaders(specHeaders: Record<string, JsonHeader & {example: string}>, headers: OutgoingHttpHeaders) {\n return Object.entries(specHeaders).reduce((headers, [key, item]) => {\n key = key.toLowerCase();\n return {\n ...headers,\n [key]: headers[key] === undefined ? String(item.example) : headers[key]\n };\n }, headers);\n}\n\n/**\n * @ignore\n */\nexport function setResponseHeaders(ctx: PlatformContext) {\n const {response, endpoint} = ctx;\n const {operation} = endpoint;\n\n if (response.isDone()) {\n return;\n }\n\n if (!response.hasStatus()) {\n // apply status only if the isn't already modified\n response.status(operation.getStatus());\n }\n\n const statusCode = response.statusCode;\n const headers = operation.getHeadersOf(response.statusCode);\n const mergedHeaders = mergeHeaders(headers, response.getHeaders());\n\n response.setHeaders(mergedHeaders);\n\n if (operation.isRedirection(statusCode)) {\n response.redirect(statusCode, String(mergedHeaders[\"location\"]));\n }\n}\n"]}
1
+ {"version":3,"file":"setResponseHeaders.js","sourceRoot":"","sources":["../../../src/utils/setResponseHeaders.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAoB;IACrD,MAAM,EAAC,QAAQ,EAAE,QAAQ,EAAC,GAAG,GAAG,CAAC;IACjC,MAAM,EAAC,SAAS,EAAC,GAAG,QAAQ,CAAC;IAE7B,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE;QACrB,OAAO;KACR;IAED,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;QACzB,kDAAkD;QAClD,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;KACxC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;IACvC,MAAM,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAEnD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;QAC9C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACtB,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;SAC/C;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE;QACvC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;KACzD;AACH,CAAC","sourcesContent":["import {PlatformContext} from \"../domain/PlatformContext\";\n\n/**\n * @ignore\n */\nexport function setResponseHeaders(ctx: PlatformContext) {\n const {response, endpoint} = ctx;\n const {operation} = endpoint;\n\n if (response.isDone()) {\n return;\n }\n\n if (!response.hasStatus()) {\n // apply status only if the isn't already modified\n response.status(operation.getStatus());\n }\n\n const statusCode = response.statusCode;\n const headers = operation.getHeadersOf(statusCode);\n\n Object.entries(headers).forEach(([key, item]) => {\n if (!response.get(key)) {\n response.setHeader(key, String(item.example));\n }\n });\n\n if (operation.isRedirection(statusCode)) {\n response.redirect(statusCode, response.get(\"location\"));\n }\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  /// <reference types="node" />
2
2
  import { Type } from "@tsed/core";
3
- import { InjectorService, ProviderOpts } from "@tsed/di";
4
- import { Platform } from "../services/Platform";
5
- import { PlatformApplication } from "../services/PlatformApplication";
3
+ import { InjectorService, ProviderOpts, TokenProvider } from "@tsed/di";
6
4
  import type { IncomingMessage, ServerResponse } from "http";
5
+ import { Platform } from "../services/Platform";
7
6
  import { PlatformAdapter, PlatformBuilderSettings } from "../services/PlatformAdapter";
7
+ import { PlatformApplication } from "../services/PlatformApplication";
8
8
  /**
9
9
  * @platform
10
10
  */
@@ -41,7 +41,7 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
41
41
  *
42
42
  * @returns {PlatformConfiguration}
43
43
  */
44
- get settings(): TsED.Configuration & import("@tsed/di").DIConfiguration;
44
+ get settings(): import("@tsed/di").DIConfiguration;
45
45
  get logger(): import("@tsed/di").DILogger;
46
46
  get disableBootstrapLog(): any;
47
47
  static create<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>): PlatformBuilder<App, Router>;
@@ -59,7 +59,7 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
59
59
  * Add classes to the components list
60
60
  * @param classes
61
61
  */
62
- addComponents(classes: any | any[]): this;
62
+ addComponents(classes: Type | Type[]): this;
63
63
  /**
64
64
  * Add classes decorated by @@Controller@@ to components container.
65
65
  *
@@ -80,7 +80,7 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
80
80
  * @param {string} endpoint
81
81
  * @param {any[]} controllers
82
82
  */
83
- addControllers(endpoint: string, controllers: any | string | (any | string)[]): void;
83
+ addControllers(endpoint: string, controllers: TokenProvider | TokenProvider[]): void;
84
84
  runLifecycle(): Promise<this>;
85
85
  loadInjector(): Promise<void>;
86
86
  listen(network?: boolean): Promise<void>;
@@ -92,7 +92,6 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
92
92
  bootstrap(): Promise<this>;
93
93
  protected loadRoutes(): Promise<void>;
94
94
  protected diff(): string;
95
- protected importProviders(): Promise<void>;
96
95
  /**
97
96
  * Load middlewares from configuration for the given hook
98
97
  * @param hook
@@ -1,44 +1,3 @@
1
- export interface PlatformLoggerSettings {
2
- /**
3
- * Enable debug mode. By default debug is false.
4
- */
5
- debug?: boolean;
6
- /**
7
- * Enable info mode. By default debug is false.
8
- */
9
- level?: "debug" | "info" | "warn" | "error" | "off";
10
- /**
11
- * Enable log performance tracker and disable log server.
12
- */
13
- perf?: boolean;
14
- /**
15
- * List of regexp to ignore log.
16
- */
17
- ignoreUrlPatterns?: string[];
18
- /**
19
- * The number of space characters to use as white space in JSON output. Default is 2 (0 in production).
20
- */
21
- jsonIndentation?: number;
22
- /**
23
- * A function called for each incoming request to create a request id.
24
- * @returns {number}
25
- */
26
- reqIdBuilder?: (req: TsED.Request) => string;
27
- /**
28
- * Disable routes table displayed in the logger. By default debug is `false`.
29
- */
30
- disableRoutesSummary?: boolean;
31
- /**
32
- * Disable bootstrap log displayed in the logger. By default debug is `false`.
33
- */
34
- disableBootstrapLog?: boolean;
35
- /**
36
- * Specify log format. Example: `%[%d{[yyyy-MM-dd hh:mm:ss,SSS}] %p%] %m`. See [@tsed/logger configuration](https://tsedio.github.io/logger/).
37
- */
38
- format?: string;
39
- /**
40
- * Specify the log stack size for the context.logger. When the stack.length is reach, the logger is flushed during the request.
41
- * Default size is set to 30.
42
- */
43
- maxStackSize?: number;
1
+ import { DILoggerOptions } from "@tsed/di";
2
+ export interface PlatformLoggerSettings extends DILoggerOptions {
44
3
  }
@@ -1,19 +1,13 @@
1
1
  /// <reference types="node" />
2
- import { Env, getHostInfoFromPort } from "@tsed/core";
3
- import { DIConfiguration } from "@tsed/di";
2
+ import { getHostInfoFromPort } from "@tsed/core";
3
+ import { DIConfiguration, TokenProvider } from "@tsed/di";
4
4
  import Https from "https";
5
5
  import { ConverterSettings } from "../interfaces/ConverterSettings";
6
- import { EndpointDirectoriesSettings } from "../interfaces/EndpointDirectoriesSettings";
7
- import { PlatformLoggerSettings } from "../interfaces/PlatformLoggerSettings";
8
6
  /**
9
7
  * `PlatformConfiguration` contains all information about your Server configuration.
10
8
  */
11
9
  export declare class PlatformConfiguration extends DIConfiguration {
12
10
  constructor();
13
- get version(): string;
14
- set version(v: string);
15
- get rootDir(): string;
16
- set rootDir(value: string);
17
11
  get port(): string | number | false;
18
12
  set port(value: string | number | false);
19
13
  get httpsOptions(): Https.ServerOptions;
@@ -22,24 +16,14 @@ export declare class PlatformConfiguration extends DIConfiguration {
22
16
  set httpPort(value: string | number | false);
23
17
  get httpsPort(): string | number | false;
24
18
  set httpsPort(value: string | number | false);
25
- get env(): Env;
26
- set env(value: Env);
27
- get mount(): EndpointDirectoriesSettings;
28
- set mount(value: EndpointDirectoriesSettings);
29
- get componentsScan(): string[];
30
- set componentsScan(value: string[]);
31
- get statics(): EndpointDirectoriesSettings;
32
- set statics(value: EndpointDirectoriesSettings);
19
+ get mount(): Record<string, TokenProvider[]>;
20
+ set mount(value: Record<string, TokenProvider[]>);
21
+ get statics(): Record<string, (any | string)[]>;
22
+ set statics(value: Record<string, (any | string)[]>);
33
23
  get acceptMimes(): string[];
34
24
  set acceptMimes(value: string[]);
35
- get debug(): boolean;
36
- set debug(debug: boolean);
37
25
  get converter(): Partial<ConverterSettings>;
38
26
  set converter(options: Partial<ConverterSettings>);
39
- get logger(): Partial<PlatformLoggerSettings>;
40
- set logger(value: Partial<PlatformLoggerSettings>);
41
- get exclude(): string[];
42
- set exclude(exclude: string[]);
43
27
  get additionalProperties(): boolean;
44
28
  /**
45
29
  *
@@ -1,7 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import { ContextMethods, DIContext, DIContextOptions } from "@tsed/di";
3
- import { IncomingMessage, ServerResponse } from "http";
4
3
  import { EndpointMetadata } from "@tsed/schema";
4
+ import { IncomingMessage, ServerResponse } from "http";
5
+ import { IncomingEvent } from "../interfaces/IncomingEvent";
5
6
  import { PlatformApplication } from "../services/PlatformApplication";
6
7
  import { PlatformRequest } from "../services/PlatformRequest";
7
8
  import { PlatformResponse } from "../services/PlatformResponse";
@@ -12,36 +13,40 @@ declare global {
12
13
  }
13
14
  }
14
15
  export interface PlatformContextOptions extends DIContextOptions {
15
- event: {
16
- response?: ServerResponse;
17
- request?: IncomingMessage;
18
- };
16
+ event: IncomingEvent;
19
17
  ignoreUrlPatterns?: any[];
20
18
  endpoint?: EndpointMetadata;
21
19
  }
22
- export declare class PlatformContext extends DIContext implements ContextMethods {
23
- /**
24
- * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
25
- */
26
- endpoint: EndpointMetadata;
20
+ export declare class PlatformContext<PReq extends PlatformRequest = PlatformRequest, PRes extends PlatformResponse = PlatformResponse> extends DIContext implements ContextMethods {
21
+ #private;
22
+ event: IncomingEvent;
27
23
  /**
28
24
  * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.
29
25
  */
30
26
  data: any;
27
+ /**
28
+ * The error caught by the current handler
29
+ */
30
+ error?: unknown;
31
31
  /**
32
32
  * The current @@PlatformResponse@@.
33
33
  */
34
- response: PlatformResponse;
34
+ readonly response: PRes;
35
35
  /**
36
36
  * The current @@PlatformRequest@@.
37
37
  */
38
- request: PlatformRequest;
38
+ readonly request: PReq;
39
39
  private ignoreUrlPatterns;
40
- constructor({ event, endpoint, ignoreUrlPatterns, ResponseKlass, RequestKlass, ...options }: PlatformContextOptions);
40
+ constructor(options: PlatformContextOptions);
41
+ /**
42
+ * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
43
+ */
44
+ get endpoint(): EndpointMetadata;
45
+ set endpoint(endpoint: EndpointMetadata);
41
46
  get url(): string;
42
47
  get app(): PlatformApplication<TsED.Application, TsED.Router>;
43
48
  destroy(): Promise<void>;
44
- isDone(): boolean;
49
+ isDone(): any;
45
50
  /**
46
51
  * Return the framework request instance (Express, Koa, etc...)
47
52
  */
@@ -62,4 +67,5 @@ export declare class PlatformContext extends DIContext implements ContextMethods
62
67
  * Return the original application instance.
63
68
  */
64
69
  getApp<T = any>(): T;
70
+ upgrade(event: IncomingEvent): void;
65
71
  }
@@ -1,15 +1,9 @@
1
1
  import { EndpointMetadata, JsonOperationRoute } from "@tsed/schema";
2
2
  import { ControllerProvider } from "./ControllerProvider";
3
- export interface PlatformRouterDetailsOptions {
4
- provider: ControllerProvider;
5
- endpoint: EndpointMetadata;
6
- method: string;
7
- url: string;
8
- }
9
3
  export declare class PlatformRouteDetails extends JsonOperationRoute<EndpointMetadata> {
10
4
  readonly rawBody: boolean;
11
5
  readonly provider: ControllerProvider;
12
- constructor(options?: Partial<PlatformRouteDetails>);
6
+ constructor(options: Partial<PlatformRouteDetails>);
13
7
  toJSON(): {
14
8
  method: string;
15
9
  name: string;
@@ -5,7 +5,6 @@ export * from "./exports";
5
5
  export * from "./builder/PlatformBuilder";
6
6
  export * from "./builder/PlatformControllerBuilder";
7
7
  export * from "./config/interfaces/ConverterSettings";
8
- export * from "./config/interfaces/EndpointDirectoriesSettings";
9
8
  export * from "./config/interfaces/PlatformLoggerSettings";
10
9
  export * from "./config/interfaces/PlatformMulterSettings";
11
10
  export * from "./config/interfaces/PlatformStaticsSettings";
@@ -58,7 +57,6 @@ export * from "./utils/createHttpServer";
58
57
  export * from "./utils/createHttpsServer";
59
58
  export * from "./utils/createInjector";
60
59
  export * from "./utils/getStaticsOptions";
61
- export * from "./utils/importProviders";
62
60
  export * from "./utils/listenServer";
63
61
  export * from "./utils/mapReturnedResponse";
64
62
  export * from "./utils/printRoutes";
@@ -1,12 +1,14 @@
1
1
  /// <reference types="node" />
2
2
  import { IncomingHttpHeaders, IncomingMessage } from "http";
3
3
  import type { PlatformContext } from "../domain/PlatformContext";
4
- import { IncomingEvent } from "../interfaces/IncomingEvent";
5
4
  import type { PlatformResponse } from "./PlatformResponse";
6
5
  declare global {
7
6
  namespace TsED {
8
7
  interface Request {
9
8
  id: string;
9
+ /**
10
+ * @deprecated
11
+ */
10
12
  $ctx: PlatformContext;
11
13
  }
12
14
  }
@@ -15,16 +17,16 @@ declare global {
15
17
  * Platform Request abstraction layer.
16
18
  * @platform
17
19
  */
18
- export declare class PlatformRequest<T extends {
20
+ export declare class PlatformRequest<Req extends {
19
21
  [key: string]: any;
20
22
  } = any> {
21
- protected $ctx: PlatformContext;
22
- raw: T;
23
+ readonly $ctx: PlatformContext;
24
+ constructor($ctx: PlatformContext);
23
25
  /**
24
26
  * The current @@PlatformResponse@@.
25
27
  */
26
- response: PlatformResponse;
27
- constructor({ request }: IncomingEvent, $ctx: PlatformContext);
28
+ get response(): PlatformResponse;
29
+ get raw(): Req;
28
30
  get secure(): boolean;
29
31
  get host(): string;
30
32
  get protocol(): string;
@@ -72,10 +74,11 @@ export declare class PlatformRequest<T extends {
72
74
  [key: string]: any;
73
75
  };
74
76
  get files(): any;
77
+ get route(): any;
75
78
  /**
76
79
  * Return the original request framework instance
77
80
  */
78
- get request(): T;
81
+ get request(): Req;
79
82
  /**
80
83
  * Return the original request node.js instance
81
84
  */
@@ -104,7 +107,7 @@ export declare class PlatformRequest<T extends {
104
107
  /**
105
108
  * Return the Framework response object (express, koa, etc...)
106
109
  */
107
- getRequest<Req = T>(): Req;
110
+ getRequest<R = Req>(): R;
108
111
  /**
109
112
  * Return the Node.js response object
110
113
  */