@tsed/common 6.89.0 → 6.92.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/lib/cjs/builder/PlatformBuilder.d.ts +15 -27
  2. package/lib/cjs/builder/PlatformBuilder.js +68 -41
  3. package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
  4. package/lib/cjs/config/interfaces/index.d.ts +10 -1
  5. package/lib/cjs/config/interfaces/index.js.map +1 -1
  6. package/lib/cjs/config/services/PlatformConfiguration.d.ts +9 -13
  7. package/lib/cjs/config/services/PlatformConfiguration.js +12 -29
  8. package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -1
  9. package/lib/cjs/decorators/httpServer.d.ts +1 -0
  10. package/lib/cjs/decorators/httpServer.js +1 -0
  11. package/lib/cjs/decorators/httpServer.js.map +1 -1
  12. package/lib/cjs/decorators/httpsServer.d.ts +1 -0
  13. package/lib/cjs/decorators/httpsServer.js +1 -0
  14. package/lib/cjs/decorators/httpsServer.js.map +1 -1
  15. package/lib/cjs/interfaces/PlatformAdapter.d.ts +19 -0
  16. package/lib/cjs/interfaces/PlatformAdapter.js +3 -0
  17. package/lib/cjs/interfaces/PlatformAdapter.js.map +1 -0
  18. package/lib/cjs/interfaces/index.d.ts +1 -0
  19. package/lib/cjs/interfaces/index.js +1 -0
  20. package/lib/cjs/interfaces/index.js.map +1 -1
  21. package/lib/cjs/services/PlatformTest.d.ts +5 -4
  22. package/lib/cjs/services/PlatformTest.js +9 -14
  23. package/lib/cjs/services/PlatformTest.js.map +1 -1
  24. package/lib/cjs/utils/createHttpServer.d.ts +3 -2
  25. package/lib/cjs/utils/createHttpServer.js +23 -24
  26. package/lib/cjs/utils/createHttpServer.js.map +1 -1
  27. package/lib/cjs/utils/createHttpsServer.d.ts +3 -2
  28. package/lib/cjs/utils/createHttpsServer.js +23 -25
  29. package/lib/cjs/utils/createHttpsServer.js.map +1 -1
  30. package/lib/cjs/utils/createInjector.js +0 -4
  31. package/lib/cjs/utils/createInjector.js.map +1 -1
  32. package/lib/cjs/utils/listenServer.d.ts +6 -9
  33. package/lib/cjs/utils/listenServer.js +11 -7
  34. package/lib/cjs/utils/listenServer.js.map +1 -1
  35. package/lib/esm/builder/PlatformBuilder.js +69 -42
  36. package/lib/esm/builder/PlatformBuilder.js.map +1 -1
  37. package/lib/esm/config/interfaces/index.js.map +1 -1
  38. package/lib/esm/config/services/PlatformConfiguration.js +12 -29
  39. package/lib/esm/config/services/PlatformConfiguration.js.map +1 -1
  40. package/lib/esm/decorators/httpServer.js +1 -0
  41. package/lib/esm/decorators/httpServer.js.map +1 -1
  42. package/lib/esm/decorators/httpsServer.js +1 -0
  43. package/lib/esm/decorators/httpsServer.js.map +1 -1
  44. package/lib/esm/interfaces/PlatformAdapter.js +2 -0
  45. package/lib/esm/interfaces/PlatformAdapter.js.map +1 -0
  46. package/lib/esm/interfaces/index.js +1 -0
  47. package/lib/esm/interfaces/index.js.map +1 -1
  48. package/lib/esm/services/PlatformTest.js +9 -14
  49. package/lib/esm/services/PlatformTest.js.map +1 -1
  50. package/lib/esm/utils/createHttpServer.js +22 -22
  51. package/lib/esm/utils/createHttpServer.js.map +1 -1
  52. package/lib/esm/utils/createHttpsServer.js +22 -23
  53. package/lib/esm/utils/createHttpsServer.js.map +1 -1
  54. package/lib/esm/utils/createInjector.js +0 -4
  55. package/lib/esm/utils/createInjector.js.map +1 -1
  56. package/lib/esm/utils/listenServer.js +11 -7
  57. package/lib/esm/utils/listenServer.js.map +1 -1
  58. package/lib/types/builder/PlatformBuilder.d.ts +15 -27
  59. package/lib/types/config/interfaces/index.d.ts +10 -1
  60. package/lib/types/config/services/PlatformConfiguration.d.ts +9 -13
  61. package/lib/types/decorators/httpServer.d.ts +1 -0
  62. package/lib/types/decorators/httpsServer.d.ts +1 -0
  63. package/lib/types/interfaces/PlatformAdapter.d.ts +19 -0
  64. package/lib/types/interfaces/index.d.ts +1 -0
  65. package/lib/types/services/PlatformTest.d.ts +5 -4
  66. package/lib/types/utils/createHttpServer.d.ts +3 -2
  67. package/lib/types/utils/createHttpsServer.d.ts +3 -2
  68. package/lib/types/utils/listenServer.d.ts +6 -9
  69. package/package.json +15 -16
@@ -1,29 +1,29 @@
1
- import { ProviderScope, registerProvider } from "@tsed/di";
1
+ import { ProviderScope } from "@tsed/di";
2
+ import { getHostInfoFromPort } from "@tsed/core";
2
3
  import Http from "http";
3
- import { PlatformApplication } from "../services/PlatformApplication";
4
4
  import { HttpServer } from "../decorators/httpServer";
5
5
  import { listenServer } from "./listenServer";
6
- export function createHttpServer(injector) {
7
- injector.invoke(HttpServer);
8
- }
9
- registerProvider({
10
- provide: HttpServer,
11
- deps: [PlatformApplication],
12
- scope: ProviderScope.SINGLETON,
13
- global: true,
14
- useFactory(platformApplication) {
15
- return Http.createServer(platformApplication.callback());
16
- }
17
- });
18
- export async function listenHttpServer(injector) {
6
+ export function createHttpServer(injector, requestListener) {
19
7
  const { settings } = injector;
20
- const server = injector.get(HttpServer);
21
- if (settings.httpPort !== false && server) {
22
- const { address, port } = settings.getHttpPort();
23
- injector.logger.debug(`Start server on http://${address}:${port}`);
24
- const options = await listenServer(server, { address, port });
25
- settings.setHttpPort(options);
26
- injector.logger.info(`Listen server on http://${options.address}:${options.port}`);
8
+ const httpPort = settings.getRaw("httpPort");
9
+ const httpOptions = settings.getRaw("httpOptions");
10
+ const server = httpPort !== false ? Http.createServer(httpOptions, requestListener) : null;
11
+ injector.addProvider(HttpServer, {
12
+ scope: ProviderScope.SINGLETON,
13
+ useValue: server
14
+ });
15
+ injector.addProvider(Http.Server, {
16
+ scope: ProviderScope.SINGLETON,
17
+ useValue: server
18
+ });
19
+ injector.invoke(HttpServer);
20
+ injector.invoke(Http.Server);
21
+ if (httpPort !== false) {
22
+ const hostInfo = getHostInfoFromPort("http", httpPort);
23
+ return async () => {
24
+ const resolvedHostInfo = await listenServer(injector, server, hostInfo);
25
+ settings.setRaw("httpPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
26
+ };
27
27
  }
28
28
  }
29
29
  //# sourceMappingURL=createHttpServer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createHttpServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC1E,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,gBAAgB,CAAC,QAAyB;IACxD,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC;AAED,gBAAgB,CAAC;IACf,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,CAAC,mBAAmB,CAAC;IAC3B,KAAK,EAAE,aAAa,CAAC,SAAS;IAC9B,MAAM,EAAE,IAAI;IACZ,UAAU,CAAC,mBAAwC;QACjD,OAAO,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3D,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,QAAyB;IAC9D,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAa,UAAU,CAAC,CAAC;IAEpD,IAAI,QAAQ,CAAC,QAAQ,KAAK,KAAK,IAAI,MAAM,EAAE;QACzC,MAAM,EAAC,OAAO,EAAE,IAAI,EAAC,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC/C,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,OAAO,IAAI,IAAI,EAAE,CAAC,CAAC;QAEnE,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAC;QAC5D,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAE9B,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;KACpF;AACH,CAAC","sourcesContent":["import {InjectorService, ProviderScope, registerProvider} from \"@tsed/di\";\nimport Http from \"http\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {HttpServer} from \"../decorators/httpServer\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpServer(injector: InjectorService): void {\n injector.invoke(HttpServer);\n}\n\nregisterProvider({\n provide: HttpServer,\n deps: [PlatformApplication],\n scope: ProviderScope.SINGLETON,\n global: true,\n useFactory(platformApplication: PlatformApplication) {\n return Http.createServer(platformApplication.callback());\n }\n});\n\nexport async function listenHttpServer(injector: InjectorService) {\n const {settings} = injector;\n const server = injector.get<HttpServer>(HttpServer);\n\n if (settings.httpPort !== false && server) {\n const {address, port} = settings.getHttpPort();\n injector.logger.debug(`Start server on http://${address}:${port}`);\n\n const options = await listenServer(server, {address, port});\n settings.setHttpPort(options);\n\n injector.logger.info(`Listen server on http://${options.address}:${options.port}`);\n }\n}\n"]}
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,UAAU,EAAC,MAAM,0BAA0B,CAAC;AACpD,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,UAAU,EAAE;QAC/B,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,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,UAAU,CAAC,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE7B,IAAI,QAAQ,KAAK,KAAK,EAAE;QACtB,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;QACtF,CAAC,CAAC;KACH;AACH,CAAC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Http from \"http\";\nimport {HttpServer} from \"../decorators/httpServer\";\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(HttpServer, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.addProvider(Http.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(HttpServer);\n injector.invoke(Http.Server);\n\n if (httpPort !== false) {\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 };\n }\n}\n"]}
@@ -1,30 +1,29 @@
1
- import { Configuration, ProviderScope, registerProvider } from "@tsed/di";
1
+ import { ProviderScope } from "@tsed/di";
2
+ import { getHostInfoFromPort } from "@tsed/core";
2
3
  import Https from "https";
3
- import { PlatformApplication } from "../services/PlatformApplication";
4
4
  import { HttpsServer } from "../decorators/httpsServer";
5
5
  import { listenServer } from "./listenServer";
6
- export function createHttpsServer(injector) {
7
- injector.invoke(HttpsServer);
8
- }
9
- registerProvider({
10
- provide: HttpsServer,
11
- deps: [PlatformApplication, Configuration],
12
- scope: ProviderScope.SINGLETON,
13
- global: true,
14
- useFactory(platformApplication, settings) {
15
- const options = settings.httpsOptions;
16
- return Https.createServer(options, platformApplication.callback());
17
- }
18
- });
19
- export async function listenHttpsServer(injector) {
6
+ export function createHttpsServer(injector, requestListener) {
20
7
  const { settings } = injector;
21
- const server = injector.get(HttpsServer);
22
- if (settings.httpsPort !== false && server) {
23
- const { address, port } = settings.getHttpsPort();
24
- injector.logger.debug(`Start server on https://${address}:${port}`);
25
- const options = await listenServer(server, { address, port });
26
- settings.setHttpsPort(options);
27
- injector.logger.info(`Listen server on https://${options.address}:${options.port}`);
8
+ const httpsPort = settings.getRaw("httpsPort");
9
+ const httpsOptions = settings.getRaw("httpsOptions");
10
+ const server = httpsPort !== false ? Https.createServer(httpsOptions, requestListener) : null;
11
+ injector.addProvider(HttpsServer, {
12
+ scope: ProviderScope.SINGLETON,
13
+ useValue: server
14
+ });
15
+ injector.addProvider(Https.Server, {
16
+ scope: ProviderScope.SINGLETON,
17
+ useValue: server
18
+ });
19
+ injector.invoke(HttpsServer);
20
+ injector.invoke(Https.Server);
21
+ if (httpsPort !== false) {
22
+ const hostInfo = getHostInfoFromPort("https", httpsPort);
23
+ return async () => {
24
+ const resolvedHostInfo = await listenServer(injector, server, hostInfo);
25
+ settings.setRaw("httpsPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
26
+ };
28
27
  }
29
28
  }
30
29
  //# sourceMappingURL=createHttpsServer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createHttpsServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpsServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAmB,aAAa,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AACzF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,iBAAiB,CAAC,QAAyB;IACzD,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC;AAED,gBAAgB,CAAC;IACf,OAAO,EAAE,WAAW;IACpB,IAAI,EAAE,CAAC,mBAAmB,EAAE,aAAa,CAAC;IAC1C,KAAK,EAAE,aAAa,CAAC,SAAS;IAC9B,MAAM,EAAE,IAAI;IACZ,UAAU,CAAC,mBAAwC,EAAE,QAAuB;QAC1E,MAAM,OAAO,GAAG,QAAQ,CAAC,YAAa,CAAC;QAEvC,OAAO,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,mBAAmB,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrE,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,QAAyB;IAC/D,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAc,WAAW,CAAC,CAAC;IAEtD,IAAI,QAAQ,CAAC,SAAS,KAAK,KAAK,IAAI,MAAM,EAAE;QAC1C,MAAM,EAAC,OAAO,EAAE,IAAI,EAAC,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAC;QAChD,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,OAAO,IAAI,IAAI,EAAE,CAAC,CAAC;QAEpE,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAC;QAC5D,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAE/B,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;KACrF;AACH,CAAC","sourcesContent":["import {Configuration, InjectorService, ProviderScope, registerProvider} from \"@tsed/di\";\nimport Https from \"https\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {HttpsServer} from \"../decorators/httpsServer\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpsServer(injector: InjectorService): void {\n injector.invoke(HttpsServer);\n}\n\nregisterProvider({\n provide: HttpsServer,\n deps: [PlatformApplication, Configuration],\n scope: ProviderScope.SINGLETON,\n global: true,\n useFactory(platformApplication: PlatformApplication, settings: Configuration) {\n const options = settings.httpsOptions!;\n\n return Https.createServer(options, platformApplication.callback());\n }\n});\n\nexport async function listenHttpsServer(injector: InjectorService) {\n const {settings} = injector;\n const server = injector.get<HttpsServer>(HttpsServer);\n\n if (settings.httpsPort !== false && server) {\n const {address, port} = settings.getHttpsPort();\n injector.logger.debug(`Start server on https://${address}:${port}`);\n\n const options = await listenServer(server, {address, port});\n settings.setHttpsPort(options);\n\n injector.logger.info(`Listen server on https://${options.address}:${options.port}`);\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,WAAW,EAAC,MAAM,2BAA2B,CAAC;AACtD,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,MAAM,CAAC,WAAW,CAAC,CAAC;IAC/C,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAErD,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,WAAW,EAAE;QAChC,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,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,WAAW,CAAC,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B,IAAI,SAAS,KAAK,KAAK,EAAE;QACvB,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,MAAM,CAAC,WAAW,EAAE,GAAG,gBAAgB,CAAC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;QACvF,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 {HttpsServer} from \"../decorators/httpsServer\";\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(HttpsServer, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.addProvider(Https.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(HttpsServer);\n injector.invoke(Https.Server);\n\n if (httpsPort !== false) {\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 };\n }\n}\n"]}
@@ -8,8 +8,6 @@ import { PlatformRouter } from "../services/PlatformRouter";
8
8
  import { PlatformApplication } from "../services/PlatformApplication";
9
9
  import { Platform } from "../services/Platform";
10
10
  import { PlatformRequest } from "../services/PlatformRequest";
11
- import { createHttpsServer } from "./createHttpsServer";
12
- import { createHttpServer } from "./createHttpServer";
13
11
  $log.name = "TSED";
14
12
  const DEFAULT_PROVIDERS = [
15
13
  { provide: PlatformHandler },
@@ -31,8 +29,6 @@ export function createInjector({ providers = [], settings = {} }) {
31
29
  injector.addProvider(token, provider);
32
30
  });
33
31
  injector.invoke(PlatformApplication);
34
- createHttpsServer(injector);
35
- createHttpServer(injector);
36
32
  return injector;
37
33
  }
38
34
  //# sourceMappingURL=createInjector.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../src/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAa,cAAc,EAAC,MAAM,UAAU,CAAC;AACpE,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;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAEpD,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,SAAS,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAwB;IACnF,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,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEzB,SAAS,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,SAAS,CAAC,CAAC;IAEjD,KAAK,CAAiB,SAAS,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QACtE,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IACrC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5B,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAE3B,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {InjectorService, IProvider, 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 {createHttpsServer} from \"./createHttpsServer\";\nimport {createHttpServer} from \"./createHttpServer\";\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 providers?: IProvider[];\n settings?: Partial<TsED.Configuration>;\n}\n\nexport function createInjector({providers = [], 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 setLoggerLevel(injector);\n\n providers = [...DEFAULT_PROVIDERS, ...providers];\n\n toMap<any, IProvider>(providers, \"provide\").forEach((provider, token) => {\n injector.addProvider(token, provider);\n });\n\n injector.invoke(PlatformApplication);\n createHttpsServer(injector);\n createHttpServer(injector);\n\n return injector;\n}\n"]}
1
+ {"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../src/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAa,cAAc,EAAC,MAAM,UAAU,CAAC;AACpE,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,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;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAE5D,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,SAAS,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAwB;IACnF,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,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEzB,SAAS,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,SAAS,CAAC,CAAC;IAEjD,KAAK,CAAiB,SAAS,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QACtE,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, IProvider, setLoggerLevel} from \"@tsed/di\";\nimport {$log} from \"@tsed/logger\";\nimport {toMap} 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\";\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 providers?: IProvider[];\n settings?: Partial<TsED.Configuration>;\n}\n\nexport function createInjector({providers = [], 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 setLoggerLevel(injector);\n\n providers = [...DEFAULT_PROVIDERS, ...providers];\n\n toMap<any, IProvider>(providers, \"provide\").forEach((provider, token) => {\n injector.addProvider(token, provider);\n });\n\n injector.invoke(PlatformApplication);\n\n return injector;\n}\n"]}
@@ -1,13 +1,17 @@
1
- export function listenServer(http, settings) {
2
- const { address, port } = settings;
1
+ export function listenServer(injector, server, hostInfo) {
2
+ const { protocol, address, port } = hostInfo;
3
+ const url = `${protocol}://${address}:${port}`;
4
+ injector.logger.debug(`Start server on ${url}`);
3
5
  const promise = new Promise((resolve, reject) => {
4
- http.on("listening", resolve);
5
- http.on("error", reject);
6
+ server.on("listening", resolve);
7
+ server.on("error", reject);
6
8
  }).then(() => {
7
- const port = http.address().port;
8
- return { address: settings.address, port };
9
+ const port = server.address().port;
10
+ const info = { ...hostInfo, port };
11
+ injector.logger.info(`Listen server on ${info.toString()}`);
12
+ return info;
9
13
  });
10
- http.listen(port, address);
14
+ server.listen(port, address);
11
15
  return promise;
12
16
  }
13
17
  //# sourceMappingURL=listenServer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"listenServer.js","sourceRoot":"","sources":["../../../src/utils/listenServer.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,YAAY,CAC1B,IAAgC,EAChC,QAAkD;IAElD,MAAM,EAAC,OAAO,EAAE,IAAI,EAAC,GAAG,QAAQ,CAAC;IAEjC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9C,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QACX,MAAM,IAAI,GAAI,IAAI,CAAC,OAAO,EAAU,CAAC,IAAI,CAAC;QAE1C,OAAO,EAAC,OAAO,EAAE,QAAQ,CAAC,OAAiB,EAAE,IAAI,EAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,OAAc,CAAC,CAAC;IAElC,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import Http from \"http\";\nimport Https from \"https\";\n\nexport function listenServer(\n http: Http.Server | Https.Server,\n settings: {address: string | number; port: number}\n): Promise<{address: string; port: number}> {\n const {address, port} = settings;\n\n const promise = new Promise((resolve, reject) => {\n http.on(\"listening\", resolve);\n http.on(\"error\", reject);\n }).then(() => {\n const port = (http.address() as any).port;\n\n return {address: settings.address as string, port};\n });\n\n http.listen(port, address as any);\n\n return promise;\n}\n"]}
1
+ {"version":3,"file":"listenServer.js","sourceRoot":"","sources":["../../../src/utils/listenServer.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,YAAY,CAC1B,QAAyB,EACzB,MAAsD,EACtD,QAAgD;IAEhD,MAAM,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAC,GAAG,QAAQ,CAAC;IAC3C,MAAM,GAAG,GAAG,GAAG,QAAQ,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;IAC/C,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC;IAEhD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9C,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAChC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QACX,MAAM,IAAI,GAAI,MAAM,CAAC,OAAO,EAAU,CAAC,IAAI,CAAC;QAC5C,MAAM,IAAI,GAAG,EAAC,GAAG,QAAQ,EAAE,IAAI,EAAC,CAAC;QAEjC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAc,CAAC,CAAC;IAEpC,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type Http from \"http\";\nimport type Https from \"https\";\nimport type Http2 from \"http2\";\nimport {InjectorService} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\n\nexport function listenServer(\n injector: InjectorService,\n server: Http.Server | Https.Server | Http2.Http2Server,\n hostInfo: ReturnType<typeof getHostInfoFromPort>\n): Promise<ReturnType<typeof getHostInfoFromPort>> {\n const {protocol, address, port} = hostInfo;\n const url = `${protocol}://${address}:${port}`;\n injector.logger.debug(`Start server on ${url}`);\n\n const promise = new Promise((resolve, reject) => {\n server.on(\"listening\", resolve);\n server.on(\"error\", reject);\n }).then(() => {\n const port = (server.address() as any).port;\n const info = {...hostInfo, port};\n\n injector.logger.info(`Listen server on ${info.toString()}`);\n\n return info;\n });\n\n server.listen(port, address as any);\n\n return promise;\n}\n"]}
@@ -4,35 +4,17 @@ import { InjectorService, IProvider } from "@tsed/di";
4
4
  import { Platform } from "../services/Platform";
5
5
  import { PlatformApplication } from "../services/PlatformApplication";
6
6
  import { IncomingMessage, ServerResponse } from "http";
7
- /**
8
- * @ignore
9
- */
10
- export interface PlatformType<T = any> extends Type<T> {
11
- providers: IProvider[];
12
- }
13
- /**
14
- * @ignore
15
- */
16
- export interface PlatformBootstrap {
17
- create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder;
18
- bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder>;
19
- }
20
- export interface PlatformBuilderOptions {
21
- name: string;
22
- providers: IProvider[];
23
- settings: any;
24
- module: Type<any>;
25
- }
7
+ import { PlatformAdapter, PlatformBuilderSettings } from "../interfaces/PlatformAdapter";
26
8
  /**
27
9
  * @platform
28
10
  */
29
- export declare abstract class PlatformBuilder<App = TsED.Application, Router = TsED.Router> {
11
+ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Router> {
30
12
  #private;
31
- static currentPlatform: Type<PlatformBuilder<any, any>> & PlatformBootstrap;
13
+ static adapter: Type<PlatformAdapter>;
32
14
  readonly name: string;
33
15
  protected startedAt: Date;
34
16
  protected current: Date;
35
- constructor({ name, providers, settings, module }: PlatformBuilderOptions);
17
+ protected constructor(adapter: Type<PlatformAdapter<App, Router>> | undefined, module: Type, settings: Partial<TsED.Configuration>);
36
18
  get injector(): InjectorService;
37
19
  get rootModule(): any;
38
20
  get app(): PlatformApplication<App, Router>;
@@ -61,7 +43,14 @@ export declare abstract class PlatformBuilder<App = TsED.Application, Router = T
61
43
  get settings(): TsED.Configuration & import("@tsed/di").DIConfiguration;
62
44
  get logger(): import("@tsed/di").DILogger;
63
45
  get disableBootstrapLog(): boolean | undefined;
64
- static build<T extends PlatformBuilder<any, any>>(platformBuildClass: PlatformType<T>, module: Type<any>, settings?: Partial<TsED.Configuration>): T;
46
+ static create<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>): PlatformBuilder<App, Router>;
47
+ static build<App = TsED.Application, Router = TsED.Router>(module: Type<any>, { adapter, ...settings }: PlatformBuilderSettings<App, Router>): PlatformBuilder<App, Router>;
48
+ /**
49
+ * Bootstrap a server application
50
+ * @param module
51
+ * @param settings
52
+ */
53
+ static bootstrap<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>): Promise<PlatformBuilder<App, Router>>;
65
54
  callback(): (req: IncomingMessage, res: ServerResponse) => void;
66
55
  callback(req: IncomingMessage, res: ServerResponse): void;
67
56
  log(...data: any[]): any;
@@ -93,13 +82,14 @@ export declare abstract class PlatformBuilder<App = TsED.Application, Router = T
93
82
  addControllers(endpoint: string, controllers: any | string | (any | string)[]): void;
94
83
  runLifecycle(): Promise<this>;
95
84
  loadInjector(): Promise<void>;
96
- listen(): Promise<void>;
85
+ listen(network?: boolean): Promise<void>;
97
86
  stop(): Promise<void>;
98
87
  ready(): Promise<void>;
99
88
  callHook(hook: string, ...args: any[]): Promise<void>;
100
89
  loadStatics(hook: string): Promise<void>;
101
90
  useProvider(token: Type<any>, settings?: Partial<IProvider>): this;
102
91
  bootstrap(): Promise<this>;
92
+ protected loadRoutes(): Promise<void>;
103
93
  protected diff(): string;
104
94
  protected importProviders(): Promise<void>;
105
95
  /**
@@ -108,9 +98,7 @@ export declare abstract class PlatformBuilder<App = TsED.Application, Router = T
108
98
  * @protected
109
99
  */
110
100
  protected loadMiddlewaresFor(hook: string): void;
111
- protected useRouter(): this;
112
- protected useContext(): this;
101
+ protected createHttpServers(): void;
113
102
  protected listenServers(): Promise<void>;
114
103
  protected logRoutes(): Promise<void>;
115
- protected loadRoutes(): Promise<void>;
116
104
  }
@@ -1,11 +1,12 @@
1
1
  /// <reference types="node" />
2
2
  import { Env } from "@tsed/core";
3
- import Https from "https";
4
3
  import { ConverterSettings } from "./ConverterSettings";
5
4
  import { EndpointDirectoriesSettings } from "./EndpointDirectoriesSettings";
6
5
  import { PlatformLoggerSettings } from "./PlatformLoggerSettings";
7
6
  import { PlatformMulterSettings } from "./PlatformMulterSettings";
8
7
  import { PlatformStaticsSettings } from "./PlatformStaticsSettings";
8
+ import type Http from "http";
9
+ import type Https from "https";
9
10
  declare global {
10
11
  namespace TsED {
11
12
  interface LoggerConfiguration extends Partial<PlatformLoggerSettings> {
@@ -27,6 +28,14 @@ declare global {
27
28
  * Port number for the [HTTP.Server](https://nodejs.org/api/http.html#http_class_http_server).
28
29
  */
29
30
  httpPort: string | number | boolean;
31
+ /**
32
+ * [Https.ServerOptions](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener)):
33
+ * - `key` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | &lt;Object[]&gt;: The private key of the server in PEM format. To support multiple keys using different algorithms an array can be provided either as a plain array of key strings or an array of objects in the format `{pem: key, passphrase: passphrase}`. This option is required for ciphers that make use of private keys.
34
+ * - `passphrase` &lt;string&gt; A string containing the passphrase for the private key or pfx.
35
+ * - `cert` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | [&lt;Buffer[]&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer): A string, Buffer, array of strings, or array of Buffers containing the certificate key of the server in PEM format. (Required)
36
+ * - `ca` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | [&lt;Buffer[]&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer): A string, Buffer, array of strings, or array of Buffers of trusted certificates in PEM format. If this is omitted several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections.
37
+ */
38
+ httpOptions: Http.ServerOptions;
30
39
  /**
31
40
  * Port number for the [HTTPs.Server](https://nodejs.org/api/https.html#https_class_https_server).
32
41
  */
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Env } from "@tsed/core";
2
+ import { Env, getHostInfoFromPort } from "@tsed/core";
3
3
  import { DIConfiguration } from "@tsed/di";
4
4
  import Https from "https";
5
5
  import { EndpointDirectoriesSettings, PlatformLoggerSettings } from "../interfaces";
@@ -39,20 +39,11 @@ export declare class PlatformConfiguration extends DIConfiguration {
39
39
  set logger(value: Partial<PlatformLoggerSettings>);
40
40
  get exclude(): string[];
41
41
  set exclude(exclude: string[]);
42
- /**
43
- *
44
- * @param addressPort
45
- * @returns {{address: string, port: number}}
46
- */
47
- private static buildAddressAndPort;
48
42
  /**
49
43
  *
50
44
  * @returns {string|number}
51
45
  */
52
- getHttpPort(): {
53
- address: string;
54
- port: number;
55
- };
46
+ getHttpPort(): ReturnType<typeof getHostInfoFromPort>;
56
47
  /**
57
48
  *
58
49
  * @param settings
@@ -66,8 +57,10 @@ export declare class PlatformConfiguration extends DIConfiguration {
66
57
  * @returns {string|number}
67
58
  */
68
59
  getHttpsPort(): {
60
+ protocol: string;
69
61
  address: string;
70
62
  port: number;
63
+ toString(): string;
71
64
  };
72
65
  /**
73
66
  *
@@ -78,8 +71,11 @@ export declare class PlatformConfiguration extends DIConfiguration {
78
71
  port: number;
79
72
  }): void;
80
73
  getBestHost(): {
74
+ protocol: string;
81
75
  address: string;
82
76
  port: number;
83
- protocol: string;
84
- } | undefined;
77
+ toString(): string;
78
+ } | {
79
+ toString(): string;
80
+ };
85
81
  }
@@ -22,6 +22,7 @@ import Http from "http";
22
22
  * @param {TypedPropertyDescriptor<Function> | number} descriptor
23
23
  * @returns {any}
24
24
  * @decorator
25
+ * @deprecated Use Https.Server from "http"
25
26
  */
26
27
  export declare function HttpServer(target: Type<any>, targetKey: string, descriptor: TypedPropertyDescriptor<Function> | number): any;
27
28
  export declare type HttpServer = Http.Server;
@@ -22,6 +22,7 @@ import Https from "https";
22
22
  * @param {TypedPropertyDescriptor<Function> | number} descriptor
23
23
  * @returns {any}
24
24
  * @decorator
25
+ * @deprecated Use Https.Server from "https"
25
26
  */
26
27
  export declare function HttpsServer(target: Type<any>, targetKey: string, descriptor: TypedPropertyDescriptor<Function> | number): any;
27
28
  export declare type HttpsServer = Https.Server;
@@ -0,0 +1,19 @@
1
+ import { Type } from "@tsed/core";
2
+ import { IProvider } from "@tsed/di";
3
+ export interface PlatformAdapter<App = TsED.Application, Router = TsED.Router> {
4
+ /**
5
+ * Load providers in top priority
6
+ */
7
+ readonly providers: IProvider[];
8
+ /**
9
+ * Called after the injector instantiation
10
+ */
11
+ onInit?: () => any;
12
+ beforeLoadRoutes?: () => Promise<any>;
13
+ afterLoadRoutes?: () => Promise<any>;
14
+ useRouter?: () => any;
15
+ useContext?: () => any;
16
+ }
17
+ export interface PlatformBuilderSettings<App = TsED.Application, Router = TsED.Router> extends Partial<TsED.Configuration> {
18
+ adapter?: Type<PlatformAdapter<App, Router>>;
19
+ }
@@ -14,3 +14,4 @@ export * from "./OnRequest";
14
14
  export * from "./OnResponse";
15
15
  export * from "./Route";
16
16
  export * from "./IncomingEvent";
17
+ export * from "./PlatformAdapter";
@@ -1,12 +1,12 @@
1
- import { Type } from "@tsed/core";
2
1
  import { DITest, InjectorService } from "@tsed/di";
3
- import { PlatformBuilder } from "../builder/PlatformBuilder";
4
2
  import { PlatformContext, PlatformContextOptions } from "../domain/PlatformContext";
3
+ import { PlatformAdapter, PlatformBuilderSettings } from "../interfaces/PlatformAdapter";
4
+ import { Type } from "@tsed/core";
5
5
  /**
6
6
  * @platform
7
7
  */
8
8
  export declare class PlatformTest extends DITest {
9
- static platformBuilder: Type<PlatformBuilder<any, any>>;
9
+ static adapter: Type<PlatformAdapter>;
10
10
  static create(settings?: Partial<TsED.Configuration>): Promise<void>;
11
11
  /**
12
12
  * Create a new injector with the right default services
@@ -16,10 +16,11 @@ export declare class PlatformTest extends DITest {
16
16
  * Load the server silently without listening port and configure it on test profile.
17
17
  * @decorator
18
18
  * @param mod
19
+ * @param listen
19
20
  * @param settings
20
21
  * @returns {Promise<void>}
21
22
  */
22
- static bootstrap(mod: any, settings?: Partial<TsED.Configuration & {
23
+ static bootstrap(mod: any, { listen, ...settings }?: Partial<PlatformBuilderSettings & {
23
24
  listen: boolean;
24
25
  }>): () => Promise<void>;
25
26
  /**
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { InjectorService } from "@tsed/di";
2
- export declare function createHttpServer(injector: InjectorService): void;
3
- export declare function listenHttpServer(injector: InjectorService): Promise<void>;
3
+ import Http from "http";
4
+ export declare function createHttpServer(injector: InjectorService, requestListener: Http.RequestListener): (() => Promise<void>) | undefined;
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { InjectorService } from "@tsed/di";
2
- export declare function createHttpsServer(injector: InjectorService): void;
3
- export declare function listenHttpsServer(injector: InjectorService): Promise<void>;
3
+ import Http from "http";
4
+ export declare function createHttpsServer(injector: InjectorService, requestListener?: Http.RequestListener): (() => Promise<void>) | undefined;
@@ -1,10 +1,7 @@
1
1
  /// <reference types="node" />
2
- import Http from "http";
3
- import Https from "https";
4
- export declare function listenServer(http: Http.Server | Https.Server, settings: {
5
- address: string | number;
6
- port: number;
7
- }): Promise<{
8
- address: string;
9
- port: number;
10
- }>;
2
+ import type Http from "http";
3
+ import type Https from "https";
4
+ import type Http2 from "http2";
5
+ import { InjectorService } from "@tsed/di";
6
+ import { getHostInfoFromPort } from "@tsed/core";
7
+ export declare function listenServer(injector: InjectorService, server: Http.Server | Https.Server | Http2.Http2Server, hostInfo: ReturnType<typeof getHostInfoFromPort>): Promise<ReturnType<typeof getHostInfoFromPort>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/common",
3
- "version": "6.89.0",
3
+ "version": "6.92.1",
4
4
  "description": "A TypeScript Framework on top of Express",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -59,24 +59,23 @@
59
59
  }
60
60
  ],
61
61
  "dependencies": {
62
- "@tsed/components-scan": "6.89.0",
63
- "@tsed/core": "6.89.0",
64
- "@tsed/di": "6.89.0",
65
- "@tsed/exceptions": "6.89.0",
66
- "@tsed/json-mapper": "6.89.0",
62
+ "@tsed/components-scan": "6.92.1",
63
+ "@tsed/core": "6.92.1",
64
+ "@tsed/di": "6.92.1",
65
+ "@tsed/exceptions": "6.92.1",
66
+ "@tsed/json-mapper": "6.92.1",
67
67
  "@tsed/logger": "^6.0.0",
68
68
  "@tsed/logger-file": "^6.0.0",
69
- "@tsed/perf": "6.89.0",
70
- "@tsed/platform-cache": "6.89.0",
71
- "@tsed/platform-exceptions": "6.89.0",
72
- "@tsed/platform-log-middleware": "6.89.0",
73
- "@tsed/platform-middlewares": "6.89.0",
74
- "@tsed/platform-params": "6.89.0",
75
- "@tsed/platform-response-filter": "6.89.0",
76
- "@tsed/platform-views": "6.89.0",
77
- "@tsed/schema": "6.89.0",
69
+ "@tsed/perf": "6.92.1",
70
+ "@tsed/platform-cache": "6.92.1",
71
+ "@tsed/platform-exceptions": "6.92.1",
72
+ "@tsed/platform-log-middleware": "6.92.1",
73
+ "@tsed/platform-middlewares": "6.92.1",
74
+ "@tsed/platform-params": "6.92.1",
75
+ "@tsed/platform-response-filter": "6.92.1",
76
+ "@tsed/platform-views": "6.92.1",
77
+ "@tsed/schema": "6.92.1",
78
78
  "@types/json-schema": "7.0.7",
79
- "json-schema": "^0.2.3",
80
79
  "on-finished": "2.3.0",
81
80
  "tslib": "2.2.0",
82
81
  "uuid": "8.3.2"