@tsed/platform-http 8.0.0-rc.5 → 8.0.0

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 (73) hide show
  1. package/lib/esm/common/builder/PlatformBuilder.js +55 -51
  2. package/lib/esm/common/builder/PlatformBuilder.js.map +1 -1
  3. package/lib/esm/common/builder/__fixtures__/PlatformCustom.js +35 -0
  4. package/lib/esm/common/builder/__fixtures__/PlatformCustom.js.map +1 -0
  5. package/lib/esm/common/decorators/PlatformProvider.js +6 -2
  6. package/lib/esm/common/decorators/PlatformProvider.js.map +1 -1
  7. package/lib/esm/common/domain/PlatformContext.js +5 -4
  8. package/lib/esm/common/domain/PlatformContext.js.map +1 -1
  9. package/lib/esm/common/fn/adapter.js +15 -0
  10. package/lib/esm/common/fn/adapter.js.map +1 -0
  11. package/lib/esm/common/fn/application.js +9 -0
  12. package/lib/esm/common/fn/application.js.map +1 -0
  13. package/lib/esm/common/index.js +4 -1
  14. package/lib/esm/common/index.js.map +1 -1
  15. package/lib/esm/common/middlewares/PlatformAcceptMimesMiddleware.js +7 -14
  16. package/lib/esm/common/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  17. package/lib/esm/common/middlewares/PlatformMulterMiddleware.js +9 -22
  18. package/lib/esm/common/middlewares/PlatformMulterMiddleware.js.map +1 -1
  19. package/lib/esm/common/services/Platform.js +13 -25
  20. package/lib/esm/common/services/Platform.js.map +1 -1
  21. package/lib/esm/common/services/PlatformAdapter.js +15 -56
  22. package/lib/esm/common/services/PlatformAdapter.js.map +1 -1
  23. package/lib/esm/common/services/PlatformApplication.js +8 -18
  24. package/lib/esm/common/services/PlatformApplication.js.map +1 -1
  25. package/lib/esm/common/services/PlatformHandler.js +12 -34
  26. package/lib/esm/common/services/PlatformHandler.js.map +1 -1
  27. package/lib/esm/common/services/PlatformMiddlewaresChain.js +8 -20
  28. package/lib/esm/common/services/PlatformMiddlewaresChain.js.map +1 -1
  29. package/lib/esm/common/services/PlatformRequest.js +4 -10
  30. package/lib/esm/common/services/PlatformRequest.js.map +1 -1
  31. package/lib/esm/common/services/PlatformResponse.js +4 -10
  32. package/lib/esm/common/services/PlatformResponse.js.map +1 -1
  33. package/lib/esm/common/utils/createContext.js +5 -5
  34. package/lib/esm/common/utils/createContext.js.map +1 -1
  35. package/lib/esm/common/utils/createHttpServer.js +5 -5
  36. package/lib/esm/common/utils/createHttpServer.js.map +1 -1
  37. package/lib/esm/common/utils/createHttpsServer.js +5 -5
  38. package/lib/esm/common/utils/createHttpsServer.js.map +1 -1
  39. package/lib/esm/common/utils/createInjector.js +18 -17
  40. package/lib/esm/common/utils/createInjector.js.map +1 -1
  41. package/lib/esm/common/utils/createServer.js +7 -8
  42. package/lib/esm/common/utils/createServer.js.map +1 -1
  43. package/lib/esm/common/utils/resolveControllers.js +48 -0
  44. package/lib/esm/common/utils/resolveControllers.js.map +1 -0
  45. package/lib/esm/testing/FakeAdapter.js +51 -1
  46. package/lib/esm/testing/FakeAdapter.js.map +1 -1
  47. package/lib/esm/testing/PlatformTest.js +12 -13
  48. package/lib/esm/testing/PlatformTest.js.map +1 -1
  49. package/lib/types/common/builder/PlatformBuilder.d.ts +12 -10
  50. package/lib/types/common/builder/__fixtures__/PlatformCustom.d.ts +17 -0
  51. package/lib/types/common/decorators/PlatformProvider.d.ts +4 -0
  52. package/lib/types/common/fn/adapter.d.ts +6 -0
  53. package/lib/types/common/fn/application.d.ts +6 -0
  54. package/lib/types/common/index.d.ts +4 -1
  55. package/lib/types/common/middlewares/PlatformMulterMiddleware.d.ts +2 -3
  56. package/lib/types/common/services/Platform.d.ts +3 -6
  57. package/lib/types/common/services/PlatformAdapter.d.ts +4 -33
  58. package/lib/types/common/services/PlatformApplication.d.ts +1 -3
  59. package/lib/types/common/services/PlatformHandler.d.ts +3 -3
  60. package/lib/types/common/services/PlatformMiddlewaresChain.d.ts +1 -3
  61. package/lib/types/common/utils/createContext.d.ts +1 -3
  62. package/lib/types/common/utils/createHttpServer.d.ts +1 -2
  63. package/lib/types/common/utils/createHttpsServer.d.ts +1 -2
  64. package/lib/types/common/utils/createInjector.d.ts +1 -8
  65. package/lib/types/common/utils/createServer.d.ts +3 -3
  66. package/lib/types/common/utils/resolveControllers.d.ts +8 -0
  67. package/lib/types/testing/FakeAdapter.d.ts +29 -1
  68. package/lib/types/testing/PlatformTest.d.ts +1 -3
  69. package/package.json +16 -18
  70. package/vitest.config.mts +9 -5
  71. package/lib/esm/common/utils/registerPlatformAdapter.js +0 -7
  72. package/lib/esm/common/utils/registerPlatformAdapter.js.map +0 -1
  73. package/lib/types/common/utils/registerPlatformAdapter.d.ts +0 -3
@@ -1 +1 @@
1
- {"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../../src/common/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAO,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAgB,sBAAsB,EAAC,MAAM,UAAU,CAAC;AACxE,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAElC,OAAO,EAAC,qBAAqB,EAAC,MAAM,6CAA6C,CAAC;AAClF,OAAO,EAAC,QAAQ,EAAC,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,mBAAmB,EAAC,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAEjE,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,OAA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AAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAEhD,GAAG;SACA,WAAW,CAAC,eAAe,EAAE;QAC5B,QAAQ,EAAE,YAAY;KACvB,CAAC;SACD,KAAK,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;IAE7C,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAE5C,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,EAAE,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1E,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAkB,eAAe,CAAE,CAAC;IAE5D,KAAK,CAAoB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QAChF,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,iBAAiB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAE7D,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1,27 +1,26 @@
1
1
  import { getHostInfoFromPort } from "@tsed/core";
2
- import { ProviderScope } from "@tsed/di";
2
+ import { configuration, injector, logger, ProviderScope } from "@tsed/di";
3
3
  import { listenServer } from "./listenServer.js";
4
- export function createServer(injector, { token, type, port, server: get, listen }) {
5
- const { settings } = injector;
4
+ export function createServer({ token, type, port, server: get, listen }) {
6
5
  const server = port !== false ? get() : null;
7
- injector.addProvider(token, {
6
+ injector().addProvider(token, {
8
7
  scope: ProviderScope.SINGLETON,
9
8
  useValue: server
10
9
  });
11
- injector.invoke(token);
10
+ injector().invoke(token);
12
11
  if (server) {
13
12
  const hostInfo = getHostInfoFromPort(type, port);
14
13
  return async () => {
15
14
  const url = `${hostInfo.protocol}://${hostInfo.address}:${port}`;
16
- injector.logger.debug(`Start server on ${url}`);
15
+ logger().debug(`Start server on ${url}`);
17
16
  await (listen ? listen(hostInfo) : listenServer(server, hostInfo));
18
17
  const address = server.address();
19
18
  if (address && typeof address !== "string") {
20
19
  hostInfo.address = address.address;
21
20
  hostInfo.port = address.port;
22
21
  }
23
- injector.logger.info(`Listen server on ${hostInfo.toString()}`);
24
- settings.set(`${type}Port`, `${hostInfo.address}:${hostInfo.port}`);
22
+ logger().info(`Listen server on ${hostInfo.toString()}`);
23
+ configuration().set(`${type}Port`, `${hostInfo.address}:${hostInfo.port}`);
25
24
  return server;
26
25
  };
27
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createServer.js","sourceRoot":"","sources":["../../../../src/common/utils/createServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAyB,MAAM,YAAY,CAAC;AACvE,OAAO,EAAkB,aAAa,EAAgB,MAAM,UAAU,CAAC;AAKvE,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAY/C,MAAM,UAAU,YAAY,CAC1B,QAAyB,EACzB,EAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAsB;IAE7D,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAE7C,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE;QAC1B,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEvB,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEjD,OAAO,KA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AC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { isArray, isClass } from "@tsed/core";
2
+ import { GlobalProviders, ProviderType } from "@tsed/di";
3
+ const lookupProperties = ["mount", "imports"];
4
+ /**
5
+ * @ignore
6
+ */
7
+ function getTokens(config) {
8
+ if (!config) {
9
+ return [];
10
+ }
11
+ if (isArray(config)) {
12
+ return config.filter(isClass).map((value) => {
13
+ return { token: value };
14
+ });
15
+ }
16
+ return Object.keys(config).reduce((list, route) => {
17
+ return [
18
+ ...list,
19
+ ...[]
20
+ .concat(config[route])
21
+ .filter(isClass)
22
+ .map((token) => ({
23
+ route,
24
+ token
25
+ }))
26
+ ];
27
+ }, []);
28
+ }
29
+ /**
30
+ * @ignore
31
+ */
32
+ function resolveRecursively(providers) {
33
+ return providers
34
+ .map(({ token }) => GlobalProviders.get(token))
35
+ .filter((provider) => provider?.type === ProviderType.MODULE && provider.configuration)
36
+ .flatMap((provider) => resolveControllers(provider.configuration));
37
+ }
38
+ /**
39
+ * Return controllers and is base route according to his configuration in module configuration.
40
+ *
41
+ * @param settings
42
+ * @ignore
43
+ */
44
+ export function resolveControllers(settings) {
45
+ const providers = lookupProperties.flatMap((property) => getTokens(settings[property]));
46
+ return [...resolveRecursively(providers), ...providers].filter((provider) => !!provider.route);
47
+ }
48
+ //# sourceMappingURL=resolveControllers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveControllers.js","sourceRoot":"","sources":["../../../../src/common/utils/resolveControllers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAC,eAAe,EAAY,YAAY,EAAsC,MAAM,UAAU,CAAC;AAEtG,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAE9C;;GAEG;AACH,SAAS,SAAS,CAAC,MAAW;IAC5B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,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,GAAG,kBAAkB,CAAC,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAU,CAAC;AAC1G,CAAC"}
@@ -1,2 +1,52 @@
1
- export { FakeAdapter } from "../common/services/PlatformAdapter.js";
1
+ import { injectable } from "@tsed/di";
2
+ import { PlatformAdapter } from "../common/index.js";
3
+ export class FakeAdapter extends PlatformAdapter {
4
+ constructor() {
5
+ super(...arguments);
6
+ this.NAME = "FAKE_ADAPTER";
7
+ this.providers = [];
8
+ }
9
+ static createFakeRawDriver() {
10
+ // istanbul ignore next
11
+ function FakeRawDriver() { }
12
+ // istanbul ignore next
13
+ function use() {
14
+ return this;
15
+ }
16
+ FakeRawDriver.use = use;
17
+ FakeRawDriver.all = use;
18
+ FakeRawDriver.get = use;
19
+ FakeRawDriver.patch = use;
20
+ FakeRawDriver.post = use;
21
+ FakeRawDriver.put = use;
22
+ FakeRawDriver.head = use;
23
+ FakeRawDriver.delete = use;
24
+ FakeRawDriver.options = use;
25
+ return FakeRawDriver;
26
+ }
27
+ createApp() {
28
+ const app = FakeAdapter.createFakeRawDriver();
29
+ return {
30
+ app,
31
+ callback() {
32
+ return app;
33
+ }
34
+ };
35
+ }
36
+ multipart(options) {
37
+ return {};
38
+ }
39
+ statics(endpoint, options) {
40
+ return {};
41
+ }
42
+ bodyParser(type) {
43
+ return () => { };
44
+ }
45
+ mapLayers(layers) { }
46
+ mapHandler(handler) {
47
+ return handler;
48
+ }
49
+ useContext() { }
50
+ }
51
+ injectable(PlatformAdapter).class(FakeAdapter);
2
52
  //# sourceMappingURL=FakeAdapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FakeAdapter.js","sourceRoot":"","sources":["../../../src/testing/FakeAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,uCAAuC,CAAC"}
1
+ {"version":3,"file":"FakeAdapter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AAG,CAAC;IAErC,UAAU,CAAC,OAAgD;QACzD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,UAAU,KAAI,CAAC;CAChB;AAED,UAAU,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC"}
@@ -1,16 +1,25 @@
1
- import { DITest, hasInjector, injector } from "@tsed/di";
1
+ import { DITest, injector } from "@tsed/di";
2
2
  import accepts from "accepts";
3
3
  import { PlatformBuilder } from "../common/builder/PlatformBuilder.js";
4
4
  import { PlatformContext } from "../common/domain/PlatformContext.js";
5
+ import { PlatformAdapter } from "../common/services/PlatformAdapter.js";
5
6
  import { PlatformApplication } from "../common/services/PlatformApplication.js";
6
7
  import { createInjector } from "../common/utils/createInjector.js";
7
8
  import { getConfiguration } from "../common/utils/getConfiguration.js";
9
+ import { FakeAdapter } from "./FakeAdapter.js";
8
10
  import { FakeResponse } from "./FakeResponse.js";
9
11
  /**
10
12
  * @platform
11
13
  */
12
14
  export class PlatformTest extends DITest {
13
15
  static async create(settings = {}) {
16
+ settings.imports = [
17
+ {
18
+ token: PlatformAdapter,
19
+ useClass: FakeAdapter
20
+ },
21
+ ...(settings.imports || [])
22
+ ];
14
23
  PlatformTest.createInjector(getConfiguration(settings));
15
24
  await DITest.createContainer();
16
25
  }
@@ -18,9 +27,7 @@ export class PlatformTest extends DITest {
18
27
  * Create a new injector with the right default services
19
28
  */
20
29
  static createInjector(settings = {}) {
21
- return createInjector({
22
- settings: DITest.configure({ httpPort: false, httpsPort: false, ...settings })
23
- });
30
+ return createInjector(DITest.configure({ httpPort: false, httpsPort: false, ...settings }));
24
31
  }
25
32
  /**
26
33
  * Load the server silently without listening port and configure it on test profile.
@@ -33,14 +40,8 @@ export class PlatformTest extends DITest {
33
40
  static bootstrap(mod, { listen, ...settings } = {}) {
34
41
  return async function before() {
35
42
  let instance;
36
- const adapter = settings.platform || settings.adapter || PlatformTest.adapter;
37
- /* istanbul ignore next */
38
- if (!adapter) {
39
- throw new Error("Platform adapter is not specified. Have you added at least `import @tsed/platform-express` (or equivalent) on your Server.ts ?");
40
- }
41
43
  // @ts-ignore
42
44
  settings = DITest.configure(settings);
43
- settings.adapter = adapter;
44
45
  const configuration = getConfiguration(settings, mod);
45
46
  instance = await PlatformBuilder.build(mod, configuration).bootstrap();
46
47
  await instance.listen(!!listen);
@@ -60,9 +61,7 @@ export class PlatformTest extends DITest {
60
61
  */
61
62
  static inject(targets, func) {
62
63
  return async () => {
63
- if (!hasInjector()) {
64
- await PlatformTest.create();
65
- }
64
+ await PlatformTest.create();
66
65
  const inj = injector();
67
66
  const deps = [];
68
67
  for (const target of targets) {
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformTest.js","sourceRoot":"","sources":["../../../src/testing/PlatformTest.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAkB,MAAM,UAAU,CAAC;AACxE,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,OAAO,EAAC,eAAe,EAAC,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAC,eAAe,EAAyB,MAAM,qCAAqC,CAAC;AAE5F,OAAO,EAAC,mBAAmB,EAAC,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAC,cAAc,EAAC,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAC,gBAAgB,EAAC,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAM;IAGtC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAwC,EAAE;QAC5D,YAAY,CAAC,cAAc,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;QACxD,MAAM,MAAM,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,WAAgB,EAAE;QACtC,OAAO,cAAc,CAAC;YACpB,QAAQ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/B,EAAE,EAAE,IAAI;YACR,GAAG,EAAE,GAAG;YACR,GAAG,OAAO;YACV,KAAK;SACN,CAAC,CAAC;QAEH,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACnC,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -11,16 +11,14 @@ import { PlatformApplication } from "../services/PlatformApplication.js";
11
11
  */
12
12
  export declare class PlatformBuilder<App = TsED.Application> {
13
13
  #private;
14
- static adapter: Type<PlatformAdapter<any>>;
15
- readonly name: string;
16
14
  protected startedAt: Date;
17
15
  protected current: Date;
18
- protected constructor(adapter: Type<PlatformAdapter<App>> | undefined, module: Type, settings: Partial<TsED.Configuration>);
19
- get injector(): InjectorService;
16
+ protected constructor(module: Type, settings: Partial<TsED.Configuration>);
17
+ get name(): string;
20
18
  get rootModule(): any;
21
19
  get app(): PlatformApplication<App>;
22
20
  get platform(): Platform;
23
- get adapter(): PlatformAdapter<App>;
21
+ get adapter(): PlatformAdapter<any>;
24
22
  /**
25
23
  * Return the settings configured by the decorator @@Configuration@@.
26
24
  *
@@ -41,17 +39,21 @@ export declare class PlatformBuilder<App = TsED.Application> {
41
39
  *
42
40
  * @returns {PlatformConfiguration}
43
41
  */
44
- get settings(): import("@tsed/di").DIConfiguration;
42
+ get settings(): TsED.DIConfiguration & import("@tsed/di").DIConfiguration;
45
43
  get logger(): import("@tsed/di").DILogger;
46
- get disableBootstrapLog(): any;
47
- static create<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>): PlatformBuilder<App>;
48
- static build<App = TsED.Application>(module: Type<any>, { adapter, ...settings }: PlatformBuilderSettings<App>): PlatformBuilder<App>;
44
+ get disableBootstrapLog(): boolean | undefined;
45
+ /**
46
+ * @deprecated use injector() instead of this method.
47
+ */
48
+ get injector(): InjectorService;
49
+ static create<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>): PlatformBuilder<TsED.Application>;
50
+ static build<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>): PlatformBuilder<TsED.Application>;
49
51
  /**
50
52
  * Bootstrap a server application
51
53
  * @param module
52
54
  * @param settings
53
55
  */
54
- static bootstrap<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>): Promise<PlatformBuilder<App>>;
56
+ static bootstrap<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>): Promise<PlatformBuilder<TsED.Application>>;
55
57
  callback(): (req: IncomingMessage, res: ServerResponse) => void;
56
58
  callback(req: IncomingMessage, res: ServerResponse): void;
57
59
  log(...data: any[]): any;
@@ -0,0 +1,17 @@
1
+ import { Type } from "@tsed/core";
2
+ import { FakeAdapter } from "../../../testing/index.js";
3
+ import { PlatformBuilder } from "../PlatformBuilder.js";
4
+ export declare class PlatformCustom extends FakeAdapter {
5
+ readonly NAME = "custom";
6
+ readonly providers: {
7
+ token: {
8
+ new (): {};
9
+ };
10
+ }[];
11
+ static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<TsED.Application>;
12
+ static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<TsED.Application>>;
13
+ afterLoadRoutes(): Promise<any>;
14
+ beforeLoadRoutes(): Promise<any>;
15
+ useContext(): any;
16
+ useRouter(): any;
17
+ }
@@ -1,3 +1,7 @@
1
1
  import { Type } from "@tsed/core";
2
2
  import { PlatformAdapter } from "../services/PlatformAdapter.js";
3
+ /**
4
+ * Register a new platform adapter.
5
+ * @decorator
6
+ */
3
7
  export declare function PlatformProvider(): (klass: Type<PlatformAdapter>) => void;
@@ -0,0 +1,6 @@
1
+ import { Type } from "@tsed/core";
2
+ import { PlatformAdapter } from "../services/PlatformAdapter.js";
3
+ /**
4
+ * Set the platform adapter
5
+ */
6
+ export declare function adapter(adapter?: Type<PlatformAdapter<any>>): Type<PlatformAdapter<any>>;
@@ -0,0 +1,6 @@
1
+ import type { PlatformApplication } from "../services/PlatformApplication.js";
2
+ /**
3
+ * Return the injectable Application instance.
4
+ * @note Application is only available after PlatformExpress/PlatformKoa instance creation.
5
+ */
6
+ export declare function application<App = TsED.Application>(): PlatformApplication<App>;
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @file Automatically generated by @tsed/barrels.
3
3
  */
4
+ export * from "./builder/__fixtures__/PlatformCustom.js";
4
5
  export * from "./builder/PlatformBuilder.js";
5
6
  export * from "./config/interfaces/PlatformJsonMapperSettings.js";
6
7
  export * from "./config/interfaces/PlatformMulterSettings.js";
@@ -21,6 +22,8 @@ export * from "./domain/EndpointMetadata.js";
21
22
  export * from "./domain/PlatformContext.js";
22
23
  export * from "./domain/PlatformRouteDetails.js";
23
24
  export * from "./exports.js";
25
+ export * from "./fn/adapter.js";
26
+ export * from "./fn/application.js";
24
27
  export * from "./interfaces/AfterInit.js";
25
28
  export * from "./interfaces/AfterListen.js";
26
29
  export * from "./interfaces/AfterRoutesInit.js";
@@ -56,5 +59,5 @@ export * from "./utils/getStaticsOptions.js";
56
59
  export * from "./utils/listenServer.js";
57
60
  export * from "./utils/mapReturnedResponse.js";
58
61
  export * from "./utils/printRoutes.js";
59
- export * from "./utils/registerPlatformAdapter.js";
62
+ export * from "./utils/resolveControllers.js";
60
63
  export * from "./utils/setResponseHeaders.js";
@@ -1,7 +1,7 @@
1
1
  import { BadRequest } from "@tsed/exceptions";
2
2
  import { MiddlewareMethods } from "@tsed/platform-middlewares";
3
3
  import type { MulterError } from "multer";
4
- import { PlatformMulterField, PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings.js";
4
+ import { PlatformMulterField } from "../config/interfaces/PlatformMulterSettings.js";
5
5
  import { PlatformContext } from "../domain/PlatformContext.js";
6
6
  import { PlatformApplication } from "../services/PlatformApplication.js";
7
7
  export interface MulterInputOptions {
@@ -14,8 +14,7 @@ export declare class MulterException extends BadRequest {
14
14
  * @middleware
15
15
  */
16
16
  export declare class PlatformMulterMiddleware implements MiddlewareMethods {
17
- protected settings: PlatformMulterSettings;
18
- protected app: PlatformApplication;
17
+ protected app: PlatformApplication<any>;
19
18
  use(ctx: PlatformContext): Promise<any>;
20
19
  protected getFields(conf: MulterInputOptions): {
21
20
  name: string;
@@ -1,7 +1,6 @@
1
- import { InjectorService, TokenProvider } from "@tsed/di";
1
+ import { TokenProvider } from "@tsed/di";
2
2
  import { PlatformLayer, PlatformRouters } from "@tsed/platform-router";
3
3
  import { Route, RouteController } from "../interfaces/Route.js";
4
- import { PlatformApplication } from "./PlatformApplication.js";
5
4
  /**
6
5
  * `Platform` is used to provide all routes collected by annotation `@Controller`.
7
6
  *
@@ -9,11 +8,9 @@ import { PlatformApplication } from "./PlatformApplication.js";
9
8
  */
10
9
  export declare class Platform {
11
10
  #private;
12
- readonly injector: InjectorService;
13
- readonly platformApplication: PlatformApplication;
14
11
  readonly platformRouters: PlatformRouters;
15
- constructor(injector: InjectorService, platformApplication: PlatformApplication, platformRouters: PlatformRouters);
16
- get app(): PlatformApplication<TsED.Application>;
12
+ constructor();
13
+ get app(): import("./PlatformApplication.js").PlatformApplication<TsED.Application>;
17
14
  addRoutes(routes: Route[]): void;
18
15
  addRoute(route: string, token: TokenProvider): this;
19
16
  getLayers(): PlatformLayer[];
@@ -1,21 +1,18 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  import { Type } from "@tsed/core";
3
- import { InjectorService, ProviderOpts } from "@tsed/di";
4
- import { PlatformContextHandler, PlatformHandlerMetadata, PlatformLayer } from "@tsed/platform-router";
3
+ import { ProviderOpts } from "@tsed/di";
4
+ import { PlatformHandlerMetadata, PlatformLayer } from "@tsed/platform-router";
5
5
  import { IncomingMessage, ServerResponse } from "http";
6
6
  import { PlatformMulter, PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings.js";
7
7
  import { PlatformStaticsOptions } from "../config/interfaces/PlatformStaticsSettings.js";
8
- import { PlatformContext } from "../domain/PlatformContext.js";
9
8
  import { CreateServerReturn } from "../utils/createServer.js";
10
9
  import type { PlatformApplication } from "./PlatformApplication.js";
11
10
  export declare abstract class PlatformAdapter<App = TsED.Application> {
12
- protected injector: InjectorService;
13
- static readonly NAME: string;
11
+ abstract readonly NAME: string;
14
12
  /**
15
13
  * Load providers in top priority
16
14
  */
17
15
  providers: ProviderOpts[];
18
- constructor(injector: InjectorService);
19
16
  get app(): PlatformApplication<App>;
20
17
  getServers(): CreateServerReturn[];
21
18
  onInit(): Promise<void> | void;
@@ -32,7 +29,7 @@ export declare abstract class PlatformAdapter<App = TsED.Application> {
32
29
  /**
33
30
  * Map handler to the targeted framework
34
31
  */
35
- abstract mapHandler(handler: Function, layer: PlatformHandlerMetadata): Function;
32
+ mapHandler(handler: Function, layer: PlatformHandlerMetadata): Function;
36
33
  /**
37
34
  * Return the app instance
38
35
  */
@@ -61,29 +58,3 @@ export declare abstract class PlatformAdapter<App = TsED.Application> {
61
58
  export interface PlatformBuilderSettings<App = TsED.Application> extends Partial<TsED.Configuration> {
62
59
  adapter?: Type<PlatformAdapter<App>>;
63
60
  }
64
- export declare class FakeAdapter extends PlatformAdapter<any> {
65
- providers: ProviderOpts[];
66
- static readonly NAME: string;
67
- static createFakeRawDriver(): {
68
- (): void;
69
- use: () => any;
70
- all: () => any;
71
- get: () => any;
72
- patch: () => any;
73
- post: () => any;
74
- put: () => any;
75
- head: () => any;
76
- delete: () => any;
77
- options: () => any;
78
- };
79
- createApp(): {
80
- app: any;
81
- callback(): any;
82
- };
83
- multipart(options: PlatformMulterSettings): PlatformMulter;
84
- statics(endpoint: string, options: PlatformStaticsOptions): any;
85
- bodyParser(type: string): any;
86
- mapLayers(layers: PlatformLayer[]): void;
87
- mapHandler(handler: PlatformContextHandler<PlatformContext>): PlatformContextHandler<PlatformContext<import("./PlatformRequest.js").PlatformRequest<any>, import("./PlatformResponse.js").PlatformResponse<any>>>;
88
- useContext(): void;
89
- }
@@ -1,6 +1,5 @@
1
1
  /// <reference types="multer" />
2
2
  /// <reference types="node" resolution-mode="require"/>
3
- import { InjectorService } from "@tsed/di";
4
3
  import { PlatformRouter } from "@tsed/platform-router";
5
4
  import { IncomingMessage, ServerResponse } from "http";
6
5
  import { PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings.js";
@@ -18,10 +17,9 @@ declare global {
18
17
  */
19
18
  export declare class PlatformApplication<App = TsED.Application> extends PlatformRouter {
20
19
  adapter: PlatformAdapter<App>;
21
- injector: InjectorService;
22
20
  rawApp: App;
23
21
  rawCallback: () => any;
24
- constructor(adapter: PlatformAdapter<App>, injector: InjectorService);
22
+ constructor();
25
23
  getApp(): App;
26
24
  multer(options: PlatformMulterSettings): import("multer").Multer;
27
25
  callback(): (req: IncomingMessage, res: ServerResponse) => any;
@@ -12,13 +12,13 @@ import { PlatformMiddlewaresChain } from "./PlatformMiddlewaresChain.js";
12
12
  * @platform
13
13
  */
14
14
  export declare class PlatformHandler {
15
- protected platformRouters: PlatformRouters;
16
15
  protected responseFilter: PlatformResponseFilter;
17
16
  protected platformParams: PlatformParams;
18
17
  protected platformExceptions: PlatformExceptions;
19
- protected platformApplication: PlatformApplication;
18
+ protected platformApplication: PlatformApplication<any>;
20
19
  protected platformMiddlewaresChain: PlatformMiddlewaresChain;
21
- constructor(platformRouters: PlatformRouters);
20
+ protected platformRouters: PlatformRouters;
21
+ constructor();
22
22
  createHandler(handlerMetadata: PlatformHandlerMetadata): any;
23
23
  /**
24
24
  * @param provider
@@ -1,11 +1,9 @@
1
- import { InjectorService } from "@tsed/di";
2
1
  import { AlterEndpointHandlersArg } from "@tsed/platform-router";
3
2
  import { JsonOperationRoute } from "@tsed/schema";
4
3
  import { PlatformAdapter } from "./PlatformAdapter.js";
5
4
  export declare class PlatformMiddlewaresChain {
6
5
  protected acceptMimes: string[];
7
- protected adapter: PlatformAdapter;
8
- protected injector: InjectorService;
6
+ protected adapter: PlatformAdapter<any>;
9
7
  get(handlers: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute): AlterEndpointHandlersArg;
10
8
  protected hasAcceptMimes(operationRoute: JsonOperationRoute): number;
11
9
  protected getParamTypes(middlewares: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute): {
@@ -1,10 +1,8 @@
1
- import { InjectorService } from "@tsed/di";
2
1
  import { PlatformContext } from "../domain/PlatformContext.js";
3
2
  import { IncomingEvent } from "../interfaces/IncomingEvent.js";
4
3
  export declare function buildIgnoreLog(ignoreUrlPatterns: any[] | undefined): ((ignore: boolean, data: any, url: string) => any) | undefined;
5
4
  /**
6
5
  * Create the TsED context to wrap request, response, injector, etc...
7
- * @param injector
8
6
  * @ignore
9
7
  */
10
- export declare function createContext(injector: InjectorService): (event: IncomingEvent) => PlatformContext;
8
+ export declare function createContext(): (event: IncomingEvent) => PlatformContext;
@@ -1,4 +1,3 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
- import { InjectorService } from "@tsed/di";
3
2
  import Http from "http";
4
- export declare function createHttpServer(injector: InjectorService, requestListener: Http.RequestListener): import("./createServer.js").CreateServerReturn | undefined;
3
+ export declare function createHttpServer(requestListener: Http.RequestListener): import("./createServer.js").CreateServerReturn | undefined;
@@ -1,4 +1,3 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
- import { InjectorService } from "@tsed/di";
3
2
  import Http from "http";
4
- export declare function createHttpsServer(injector: InjectorService, requestListener?: Http.RequestListener): import("./createServer.js").CreateServerReturn | undefined;
3
+ export declare function createHttpsServer(requestListener?: Http.RequestListener): import("./createServer.js").CreateServerReturn | undefined;
@@ -1,8 +1 @@
1
- import { Type } from "@tsed/core";
2
- import { PlatformAdapter } from "../services/PlatformAdapter.js";
3
- interface CreateInjectorOptions {
4
- adapter?: Type<PlatformAdapter<any>>;
5
- settings?: Partial<TsED.Configuration>;
6
- }
7
- export declare function createInjector({ adapter, settings }: CreateInjectorOptions): import("@tsed/di").InjectorService;
8
- export {};
1
+ export declare function createInjector(settings: Partial<TsED.Configuration>): import("@tsed/di").InjectorService;
@@ -2,16 +2,16 @@
2
2
  /// <reference types="node" resolution-mode="require"/>
3
3
  /// <reference types="node" resolution-mode="require"/>
4
4
  import { ReturnHostInfoFromPort } from "@tsed/core";
5
- import { InjectorService, TokenProvider } from "@tsed/di";
5
+ import { TokenProvider } from "@tsed/di";
6
6
  import Http from "http";
7
7
  import Http2 from "http2";
8
8
  import Https from "https";
9
9
  export interface CreateServerOptions {
10
10
  token: TokenProvider;
11
11
  type: "http" | "https";
12
- port: string | false;
12
+ port: string | false | undefined;
13
13
  listen?: (hostInfo: ReturnHostInfoFromPort) => Promise<any>;
14
14
  server: () => Http.Server | Https.Server | Http2.Http2Server;
15
15
  }
16
16
  export type CreateServerReturn = () => Promise<Http.Server | Https.Server | Http2.Http2Server>;
17
- export declare function createServer(injector: InjectorService, { token, type, port, server: get, listen }: CreateServerOptions): undefined | CreateServerReturn;
17
+ export declare function createServer({ token, type, port, server: get, listen }: CreateServerOptions): undefined | CreateServerReturn;
@@ -0,0 +1,8 @@
1
+ import { type TokenRoute } from "@tsed/di";
2
+ /**
3
+ * Return controllers and is base route according to his configuration in module configuration.
4
+ *
5
+ * @param settings
6
+ * @ignore
7
+ */
8
+ export declare function resolveControllers(settings: Partial<TsED.Configuration>): TokenRoute[];
@@ -1 +1,29 @@
1
- export { FakeAdapter } from "../common/services/PlatformAdapter.js";
1
+ import { type ProviderOpts } from "@tsed/di";
2
+ import { type PlatformContextHandler, PlatformLayer } from "@tsed/platform-router";
3
+ import { PlatformAdapter, PlatformContext, type PlatformMulter, type PlatformMulterSettings, type PlatformStaticsOptions } from "../common/index.js";
4
+ export declare class FakeAdapter extends PlatformAdapter<any> {
5
+ readonly NAME: string;
6
+ providers: ProviderOpts[];
7
+ static createFakeRawDriver(): {
8
+ (): void;
9
+ use: () => any;
10
+ all: () => any;
11
+ get: () => any;
12
+ patch: () => any;
13
+ post: () => any;
14
+ put: () => any;
15
+ head: () => any;
16
+ delete: () => any;
17
+ options: () => any;
18
+ };
19
+ createApp(): {
20
+ app: any;
21
+ callback(): any;
22
+ };
23
+ multipart(options: PlatformMulterSettings): PlatformMulter;
24
+ statics(endpoint: string, options: PlatformStaticsOptions): any;
25
+ bodyParser(type: string): any;
26
+ mapLayers(layers: PlatformLayer[]): void;
27
+ mapHandler(handler: PlatformContextHandler<PlatformContext>): PlatformContextHandler<PlatformContext<import("../common/index.js").PlatformRequest<any>, import("../common/index.js").PlatformResponse<any>>>;
28
+ useContext(): void;
29
+ }