@tsed/platform-http 8.16.0-rc.2 → 8.16.0-rc.3

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 (29) hide show
  1. package/lib/esm/common/builder/PlatformBuilder.js +16 -15
  2. package/lib/esm/common/config/PlatformConfiguration.js +5 -0
  3. package/lib/esm/common/config/defineConfiguration.js +44 -0
  4. package/lib/esm/common/index.js +4 -5
  5. package/lib/esm/common/utils/createInjector.js +2 -6
  6. package/lib/esm/common/utils/getBestHost.js +35 -0
  7. package/lib/esm/testing/PlatformTest.js +15 -16
  8. package/lib/types/common/builder/PlatformBuilder.d.ts +9 -11
  9. package/lib/types/common/config/PlatformConfiguration.d.ts +34 -0
  10. package/lib/types/common/config/{interfaces/PlatformStaticsSettings.d.ts → PlatformStaticsSettings.d.ts} +0 -9
  11. package/lib/types/common/config/defineConfiguration.d.ts +2 -0
  12. package/lib/types/common/index.d.ts +4 -5
  13. package/lib/types/common/services/PlatformAdapter.d.ts +1 -1
  14. package/lib/types/common/utils/getBestHost.d.ts +39 -0
  15. package/lib/types/common/utils/getStaticsOptions.d.ts +1 -1
  16. package/lib/types/testing/FakeAdapter.d.ts +2 -2
  17. package/lib/types/testing/PlatformTest.d.ts +6 -6
  18. package/package.json +21 -21
  19. package/lib/esm/common/config/interfaces/PlatformJsonMapperSettings.js +0 -1
  20. package/lib/esm/common/config/interfaces/PlatformMulterSettings.js +0 -1
  21. package/lib/esm/common/config/interfaces/PlatformRouterSettings.js +0 -1
  22. package/lib/esm/common/config/services/PlatformConfiguration.js +0 -118
  23. package/lib/esm/common/utils/getConfiguration.js +0 -31
  24. package/lib/types/common/config/interfaces/PlatformJsonMapperSettings.d.ts +0 -10
  25. package/lib/types/common/config/interfaces/PlatformMulterSettings.d.ts +0 -17
  26. package/lib/types/common/config/interfaces/PlatformRouterSettings.d.ts +0 -10
  27. package/lib/types/common/config/services/PlatformConfiguration.d.ts +0 -78
  28. package/lib/types/common/utils/getConfiguration.d.ts +0 -2
  29. /package/lib/esm/common/config/{interfaces/PlatformStaticsSettings.js → PlatformStaticsSettings.js} +0 -0
@@ -1,13 +1,13 @@
1
1
  import "@tsed/platform-accept-mimes";
2
2
  import { colors, configuration, constant, createContainer, destroyInjector, injector, logger, ProviderScope } from "@tsed/di";
3
3
  import { $alter, $asyncAlter, $asyncEmit } from "@tsed/hooks";
4
+ import { defineConfiguration } from "../config/defineConfiguration.js";
4
5
  import { application } from "../fn/application.js";
5
6
  import { Platform } from "../services/Platform.js";
6
7
  import { PlatformAdapter } from "../services/PlatformAdapter.js";
7
8
  import { PlatformApplication } from "../services/PlatformApplication.js";
8
9
  import { closeServer } from "../utils/closeServer.js";
9
10
  import { createInjector } from "../utils/createInjector.js";
10
- import { getConfiguration } from "../utils/getConfiguration.js";
11
11
  import { getStaticsOptions } from "../utils/getStaticsOptions.js";
12
12
  import { printRoutes } from "../utils/printRoutes.js";
13
13
  import { resolveControllers } from "../utils/resolveControllers.js";
@@ -24,8 +24,10 @@ export class PlatformBuilder {
24
24
  this.current = new Date();
25
25
  this.#listeners = [];
26
26
  this.#rootModule = module;
27
- const configuration = getConfiguration(settings, module);
28
- createInjector(configuration);
27
+ createInjector(defineConfiguration({
28
+ rootModule: module,
29
+ ...settings
30
+ }));
29
31
  this.log(`Loading ${this.name.toUpperCase()} platform adapter...`);
30
32
  this.createHttpServers();
31
33
  this.log("Injector created...");
@@ -50,20 +52,18 @@ export class PlatformBuilder {
50
52
  *
51
53
  * ```typescript
52
54
  * @Configuration({
53
- * port: 8000,
54
- * httpsPort: 8080,
55
- * mount: {
56
- * "/rest": "${rootDir}/controllers/**\/*.js"
57
- * }
55
+ * port: 8000,
56
+ * httpsPort: 8080,
57
+ * mount: {
58
+ * "/rest": "${rootDir}/controllers/**\/*.js"
59
+ * }
58
60
  * })
59
61
  * export class Server {
60
- * $onInit(){
61
- * console.log(this.settings); // {rootDir, port, httpsPort,...}
62
- * }
62
+ * $onInit(){
63
+ * console.log(this.settings); // {rootDir, port, httpsPort,...}
64
+ * }
63
65
  * }
64
66
  * ```
65
- *
66
- * @returns {PlatformConfiguration}
67
67
  */
68
68
  get settings() {
69
69
  return configuration();
@@ -126,7 +126,7 @@ export class PlatformBuilder {
126
126
  */
127
127
  addControllers(endpoint, controllers) {
128
128
  [].concat(controllers).forEach((token) => {
129
- configuration().routes.push({ token, route: endpoint });
129
+ configuration().get("routes").push({ token, route: endpoint });
130
130
  });
131
131
  }
132
132
  async runLifecycle() {
@@ -162,7 +162,8 @@ export class PlatformBuilder {
162
162
  async loadInjector() {
163
163
  this.log("Build providers");
164
164
  const settings = configuration();
165
- settings.set("routes", settings.get("routes").concat(resolveControllers(settings)));
165
+ const routes = settings.get("routes").concat(resolveControllers(settings));
166
+ settings.set("routes", routes);
166
167
  const container = createContainer();
167
168
  container.delete(this.#rootModule);
168
169
  container.addProvider(this.#rootModule, {
@@ -0,0 +1,5 @@
1
+ import { DIConfiguration } from "@tsed/di";
2
+ /**
3
+ * @deprecated
4
+ */
5
+ export const PlatformConfiguration = DIConfiguration;
@@ -0,0 +1,44 @@
1
+ import "./PlatformConfiguration.js";
2
+ import { Env, isBoolean, Store } from "@tsed/core";
3
+ import { configuration, mergeMount, ProviderScope, ProviderType } from "@tsed/di";
4
+ import { $on } from "@tsed/hooks";
5
+ import { JsonMapperSettings } from "@tsed/json-mapper";
6
+ export function defineConfiguration(input = {}) {
7
+ if (input.$$resolved) {
8
+ return input;
9
+ }
10
+ const store = input.rootModule ? Store.from(input.rootModule).get("configuration") || {} : {};
11
+ const env = input.env || store.env || process.env.NODE_ENV || Env.DEV;
12
+ const finalConfig = {
13
+ $$resolved: true,
14
+ rootDir: process.cwd(),
15
+ env,
16
+ httpPort: 8080,
17
+ httpsPort: false,
18
+ jsonMapper: JsonMapperSettings,
19
+ ...store,
20
+ ...input,
21
+ scopes: {
22
+ [ProviderType.CONTROLLER]: ProviderScope.SINGLETON,
23
+ ...store.scopes,
24
+ ...input.scopes
25
+ },
26
+ mount: mergeMount(store.mount, input.mount),
27
+ logger: {
28
+ debug: false,
29
+ level: env === Env.TEST ? "off" : "info",
30
+ logRequest: true,
31
+ ...store.logger,
32
+ ...input.logger,
33
+ jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2
34
+ }
35
+ };
36
+ configuration().set(finalConfig);
37
+ return finalConfig;
38
+ }
39
+ $on("$alterConfig:jsonMapper", (options) => {
40
+ JsonMapperSettings.strictGroups = Boolean(options.strictGroups);
41
+ JsonMapperSettings.disableUnsecureConstructor = Boolean(options.disableUnsecureConstructor);
42
+ JsonMapperSettings.additionalProperties = Boolean(isBoolean(options.additionalProperties) ? options.additionalProperties : options.additionalProperties === "accept");
43
+ return options;
44
+ });
@@ -2,11 +2,9 @@
2
2
  * @file Automatically generated by @tsed/barrels.
3
3
  */
4
4
  export * from "./builder/PlatformBuilder.js";
5
- export * from "./config/interfaces/PlatformJsonMapperSettings.js";
6
- export * from "./config/interfaces/PlatformMulterSettings.js";
7
- export * from "./config/interfaces/PlatformRouterSettings.js";
8
- export * from "./config/interfaces/PlatformStaticsSettings.js";
9
- export * from "./config/services/PlatformConfiguration.js";
5
+ export * from "./config/defineConfiguration.js";
6
+ export * from "./config/PlatformConfiguration.js";
7
+ export * from "./config/PlatformStaticsSettings.js";
10
8
  export * from "./constants/routerOptions.js";
11
9
  export * from "./decorators/multer/multerFileSize.js";
12
10
  export * from "./decorators/multer/multerOptions.js";
@@ -53,6 +51,7 @@ export * from "./utils/createHttpsServer.js";
53
51
  export * from "./utils/createInjector.js";
54
52
  export * from "./utils/createServer.js";
55
53
  export * from "./utils/ensureContext.js";
54
+ export * from "./utils/getBestHost.js";
56
55
  export * from "./utils/getStaticsOptions.js";
57
56
  export * from "./utils/listenServer.js";
58
57
  export * from "./utils/mapReturnedResponse.js";
@@ -1,16 +1,12 @@
1
- import { injector, setLoggerConfiguration } from "@tsed/di";
1
+ import { attachLogger, injector } from "@tsed/di";
2
2
  import { $log } from "@tsed/logger";
3
- import { PlatformConfiguration } from "../config/services/PlatformConfiguration.js";
4
3
  import { adapter as $adapter } from "../fn/adapter.js";
5
4
  import { PlatformAdapter } from "../services/PlatformAdapter.js";
6
5
  $log.name = "TSED";
7
6
  export function createInjector(settings) {
8
7
  const inj = injector();
9
- inj.addProvider(PlatformConfiguration);
10
- inj.settings = inj.invoke(PlatformConfiguration);
11
- inj.logger = $log;
12
8
  inj.settings.set(settings);
13
- setLoggerConfiguration();
9
+ attachLogger($log);
14
10
  $adapter(settings.adapter);
15
11
  inj.invoke(PlatformAdapter);
16
12
  return inj;
@@ -0,0 +1,35 @@
1
+ import { getHostInfoFromPort } from "@tsed/core";
2
+ import { configuration, constant } from "@tsed/di";
3
+ function httpPort() {
4
+ return constant("httpPort", constant("port"));
5
+ }
6
+ export function setHttpPort(settings) {
7
+ configuration().set("httpPort", `${settings.address}:${settings.port}`);
8
+ }
9
+ export function setHttpsPort(settings) {
10
+ configuration().set("httpsPort", `${settings.address}:${settings.port}`);
11
+ }
12
+ export function getHttpsPort() {
13
+ return getHostInfoFromPort("https", constant("httpsPort"));
14
+ }
15
+ export function getHttpPort() {
16
+ return getHostInfoFromPort("http", httpPort());
17
+ }
18
+ export function getBestHost() {
19
+ if (constant("httpsPort")) {
20
+ return getHttpsPort();
21
+ }
22
+ if (httpPort()) {
23
+ return getHttpPort();
24
+ }
25
+ return {
26
+ toString() {
27
+ return "/";
28
+ }
29
+ };
30
+ }
31
+ configuration().decorate("getBestHost", getBestHost);
32
+ configuration().decorate("getHttpPort", getHttpPort);
33
+ configuration().decorate("getHttpsPort", getHttpsPort);
34
+ configuration().decorate("setHttpsPort", setHttpsPort);
35
+ configuration().decorate("setHttpPort", setHttpPort);
@@ -1,12 +1,12 @@
1
+ import { isPlainObject } from "@tsed/core";
1
2
  import { DITest, injector } from "@tsed/di";
2
3
  import accepts from "accepts";
3
4
  import { PlatformBuilder } from "../common/builder/PlatformBuilder.js";
4
5
  import { PlatformContext } from "../common/domain/PlatformContext.js";
5
- import { adapter } from "../common/index.js";
6
+ import { adapter, defineConfiguration } from "../common/index.js";
6
7
  import { PlatformAdapter } from "../common/services/PlatformAdapter.js";
7
8
  import { PlatformApplication } from "../common/services/PlatformApplication.js";
8
9
  import { createInjector } from "../common/utils/createInjector.js";
9
- import { getConfiguration } from "../common/utils/getConfiguration.js";
10
10
  import { FakeAdapter } from "./FakeAdapter.js";
11
11
  import { FakeResponse } from "./FakeResponse.js";
12
12
  /**
@@ -21,31 +21,30 @@ export class PlatformTest extends DITest {
21
21
  },
22
22
  ...(settings.imports || [])
23
23
  ];
24
- PlatformTest.createInjector(getConfiguration(settings));
24
+ PlatformTest.createInjector(defineConfiguration(DITest.configure(settings)));
25
25
  await DITest.createContainer();
26
26
  }
27
27
  /**
28
28
  * Create a new injector with the right default services
29
29
  */
30
30
  static createInjector(settings = {}) {
31
- return createInjector(DITest.configure({ httpPort: false, httpsPort: false, ...settings }));
31
+ return createInjector(settings);
32
32
  }
33
- /**
34
- * Load the server silently without listening port and configure it on test profile.
35
- * @decorator
36
- * @param mod
37
- * @param listen
38
- * @param settings
39
- * @returns {Promise<void>}
40
- */
41
- static bootstrap(mod, { listen, ...settings } = {}) {
33
+ static bootstrap(mod, initialSettings = {}) {
34
+ if (!isPlainObject(mod)) {
35
+ initialSettings.rootModule = mod;
36
+ }
37
+ else {
38
+ initialSettings = mod;
39
+ }
40
+ const { listen, ...props } = initialSettings;
42
41
  return async function before() {
43
42
  let instance;
44
43
  // @ts-ignore
45
- settings = DITest.configure(settings);
44
+ const settings = DITest.configure(props);
46
45
  adapter(settings.adapter || adapter());
47
- const configuration = getConfiguration(settings, mod);
48
- instance = await PlatformBuilder.build(mod, configuration).bootstrap();
46
+ const configuration = defineConfiguration(settings);
47
+ instance = await PlatformBuilder.build(configuration.rootModule, configuration).bootstrap();
49
48
  await instance.listen(!!listen);
50
49
  };
51
50
  }
@@ -25,22 +25,20 @@ export declare class PlatformBuilder<App = TsED.Application> {
25
25
  *
26
26
  * ```typescript
27
27
  * @Configuration({
28
- * port: 8000,
29
- * httpsPort: 8080,
30
- * mount: {
31
- * "/rest": "${rootDir}/controllers/**\/*.js"
32
- * }
28
+ * port: 8000,
29
+ * httpsPort: 8080,
30
+ * mount: {
31
+ * "/rest": "${rootDir}/controllers/**\/*.js"
32
+ * }
33
33
  * })
34
34
  * export class Server {
35
- * $onInit(){
36
- * console.log(this.settings); // {rootDir, port, httpsPort,...}
37
- * }
35
+ * $onInit(){
36
+ * console.log(this.settings); // {rootDir, port, httpsPort,...}
37
+ * }
38
38
  * }
39
39
  * ```
40
- *
41
- * @returns {PlatformConfiguration}
42
40
  */
43
- get settings(): TsED.DIConfiguration & import("@tsed/di").DIConfiguration;
41
+ get settings(): TsED.Configuration & import("@tsed/di").DIConfiguration;
44
42
  get logger(): import("@tsed/di").DILogger;
45
43
  get disableBootstrapLog(): boolean | undefined;
46
44
  /**
@@ -0,0 +1,34 @@
1
+ import { Type } from "@tsed/core";
2
+ import { DIConfiguration } from "@tsed/di";
3
+ import { JsonMapperGlobalOptions } from "@tsed/json-mapper";
4
+ import type { PlatformStaticsSettings } from "./PlatformStaticsSettings.js";
5
+ export interface PlatformRouterSettings {
6
+ appendChildrenRoutesFirst?: boolean;
7
+ }
8
+ declare global {
9
+ namespace TsED {
10
+ interface Configuration {
11
+ rootModule?: Type;
12
+ rootDir?: string;
13
+ httpPort?: string | number | false;
14
+ httpsPort?: string | number | false;
15
+ jsonMapper?: JsonMapperGlobalOptions;
16
+ router?: PlatformRouterSettings;
17
+ statics?: PlatformStaticsSettings;
18
+ }
19
+ interface StaticsOptions {
20
+ root: string;
21
+ hook?: "$beforeRoutesInit" | "$afterRoutesInit";
22
+ [key: string]: any;
23
+ }
24
+ interface MultipartFileOptions {
25
+ }
26
+ interface MultipartFileInstance {
27
+ }
28
+ }
29
+ }
30
+ /**
31
+ * @deprecated
32
+ */
33
+ export declare const PlatformConfiguration: typeof DIConfiguration;
34
+ export type PlatformConfiguration = DIConfiguration & TsED.Configuration;
@@ -1,12 +1,3 @@
1
- declare global {
2
- namespace TsED {
3
- interface StaticsOptions {
4
- root: string;
5
- hook?: "$beforeRoutesInit" | "$afterRoutesInit";
6
- [key: string]: any;
7
- }
8
- }
9
- }
10
1
  export interface PlatformStaticsOptions extends TsED.StaticsOptions {
11
2
  root: string;
12
3
  [key: string]: any;
@@ -0,0 +1,2 @@
1
+ import "./PlatformConfiguration.js";
2
+ export declare function defineConfiguration(input?: Partial<TsED.Configuration>): any;
@@ -2,11 +2,9 @@
2
2
  * @file Automatically generated by @tsed/barrels.
3
3
  */
4
4
  export * from "./builder/PlatformBuilder.js";
5
- export * from "./config/interfaces/PlatformJsonMapperSettings.js";
6
- export * from "./config/interfaces/PlatformMulterSettings.js";
7
- export * from "./config/interfaces/PlatformRouterSettings.js";
8
- export * from "./config/interfaces/PlatformStaticsSettings.js";
9
- export * from "./config/services/PlatformConfiguration.js";
5
+ export * from "./config/defineConfiguration.js";
6
+ export * from "./config/PlatformConfiguration.js";
7
+ export * from "./config/PlatformStaticsSettings.js";
10
8
  export * from "./constants/routerOptions.js";
11
9
  export * from "./decorators/multer/multerFileSize.js";
12
10
  export * from "./decorators/multer/multerOptions.js";
@@ -53,6 +51,7 @@ export * from "./utils/createHttpsServer.js";
53
51
  export * from "./utils/createInjector.js";
54
52
  export * from "./utils/createServer.js";
55
53
  export * from "./utils/ensureContext.js";
54
+ export * from "./utils/getBestHost.js";
56
55
  export * from "./utils/getStaticsOptions.js";
57
56
  export * from "./utils/listenServer.js";
58
57
  export * from "./utils/mapReturnedResponse.js";
@@ -3,7 +3,7 @@ import { IncomingMessage, ServerResponse } from "node:http";
3
3
  import { Type } from "@tsed/core";
4
4
  import type { PlatformMulter, PlatformMulterSettings } from "@tsed/platform-multer";
5
5
  import { PlatformHandlerMetadata, PlatformLayer } from "@tsed/platform-router";
6
- import { PlatformStaticsOptions } from "../config/interfaces/PlatformStaticsSettings.js";
6
+ import type { PlatformStaticsOptions } from "../config/PlatformStaticsSettings.js";
7
7
  import { CreateServerReturn } from "../utils/createServer.js";
8
8
  import { PlatformApplication } from "./PlatformApplication.js";
9
9
  export declare abstract class PlatformAdapter<App = TsED.Application> {
@@ -0,0 +1,39 @@
1
+ export declare function setHttpPort(settings: {
2
+ address: string;
3
+ port: number;
4
+ }): void;
5
+ export declare function setHttpsPort(settings: {
6
+ address: string;
7
+ port: number;
8
+ }): void;
9
+ export declare function getHttpsPort(): {
10
+ protocol: string;
11
+ address: string;
12
+ port: number;
13
+ toString(): string;
14
+ };
15
+ export declare function getHttpPort(): {
16
+ protocol: string;
17
+ address: string;
18
+ port: number;
19
+ toString(): string;
20
+ };
21
+ export declare function getBestHost(): {
22
+ protocol: string;
23
+ address: string;
24
+ port: number;
25
+ toString(): string;
26
+ } | {
27
+ toString(): string;
28
+ };
29
+ declare global {
30
+ namespace TsED {
31
+ interface Configuration {
32
+ readonly getBestHost: typeof getBestHost;
33
+ readonly getHttpPort: typeof getHttpPort;
34
+ readonly getHttpsPort: typeof getHttpsPort;
35
+ readonly setHttpsPort: typeof setHttpsPort;
36
+ readonly setHttpPort: typeof setHttpPort;
37
+ }
38
+ }
39
+ }
@@ -1,4 +1,4 @@
1
- import { PlatformStaticsOptions, PlatformStaticsSettings } from "../config/interfaces/PlatformStaticsSettings.js";
1
+ import type { PlatformStaticsOptions, PlatformStaticsSettings } from "../config/PlatformStaticsSettings.js";
2
2
  export declare function getStaticsOptions(statics?: PlatformStaticsSettings): {
3
3
  path: string;
4
4
  options: PlatformStaticsOptions;
@@ -1,6 +1,6 @@
1
1
  import { type ProviderOpts } from "@tsed/di";
2
2
  import { type PlatformContextHandler, PlatformLayer } from "@tsed/platform-router";
3
- import { PlatformAdapter, PlatformContext, type PlatformMulter, type PlatformMulterSettings, type PlatformStaticsOptions } from "../common/index.js";
3
+ import { PlatformAdapter, PlatformContext, type PlatformStaticsOptions } from "../common/index.js";
4
4
  export declare class FakeAdapter extends PlatformAdapter<any> {
5
5
  readonly NAME: string;
6
6
  providers: ProviderOpts[];
@@ -20,7 +20,7 @@ export declare class FakeAdapter extends PlatformAdapter<any> {
20
20
  app: any;
21
21
  callback(): any;
22
22
  };
23
- multipart(options: PlatformMulterSettings): PlatformMulter;
23
+ multipart(options: TsED.MultipartFileOptions): TsED.MultipartFileInstance;
24
24
  statics(endpoint: string, options: PlatformStaticsOptions): any;
25
25
  bodyParser(type: string): any;
26
26
  mapLayers(layers: PlatformLayer[]): void;
@@ -11,16 +11,16 @@ export declare class PlatformTest extends DITest {
11
11
  /**
12
12
  * Create a new injector with the right default services
13
13
  */
14
- static createInjector(settings?: any): InjectorService;
14
+ static createInjector(settings?: Partial<TsED.Configuration>): InjectorService;
15
15
  /**
16
16
  * Load the server silently without listening port and configure it on test profile.
17
- * @decorator
18
- * @param mod
19
- * @param listen
20
- * @param settings
17
+ *
21
18
  * @returns {Promise<void>}
22
19
  */
23
- static bootstrap(mod: any, { listen, ...settings }?: Partial<PlatformBuilderSettings & {
20
+ static bootstrap(settings?: Partial<PlatformBuilderSettings & {
21
+ listen: boolean;
22
+ }>): () => Promise<void>;
23
+ static bootstrap(mod: any, settings?: Partial<PlatformBuilderSettings & {
24
24
  listen: boolean;
25
25
  }>): () => Promise<void>;
26
26
  /**
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsed/platform-http",
3
3
  "description": "A TypeScript Framework on top of Express",
4
4
  "type": "module",
5
- "version": "8.16.0-rc.2",
5
+ "version": "8.16.0-rc.3",
6
6
  "source": "./src/common/index.ts",
7
7
  "main": "./lib/esm/common/index.js",
8
8
  "module": "./lib/esm/common/index.js",
@@ -70,38 +70,38 @@
70
70
  }
71
71
  ],
72
72
  "dependencies": {
73
- "@tsed/core": "8.16.0-rc.2",
74
- "@tsed/di": "8.16.0-rc.2",
75
- "@tsed/exceptions": "8.16.0-rc.2",
76
- "@tsed/hooks": "8.16.0-rc.2",
77
- "@tsed/json-mapper": "8.16.0-rc.2",
78
- "@tsed/logger": "^8.0.0-rc.1",
79
- "@tsed/logger-std": "^8.0.0-rc.1",
80
- "@tsed/platform-accept-mimes": "8.16.0-rc.2",
81
- "@tsed/platform-exceptions": "8.16.0-rc.2",
82
- "@tsed/platform-middlewares": "8.16.0-rc.2",
83
- "@tsed/platform-multer": "8.16.0-rc.2",
84
- "@tsed/platform-params": "8.16.0-rc.2",
85
- "@tsed/platform-response-filter": "8.16.0-rc.2",
86
- "@tsed/platform-router": "8.16.0-rc.2",
87
- "@tsed/platform-views": "8.16.0-rc.2",
88
- "@tsed/schema": "8.16.0-rc.2",
73
+ "@tsed/core": "8.16.0-rc.3",
74
+ "@tsed/di": "8.16.0-rc.3",
75
+ "@tsed/exceptions": "8.16.0-rc.3",
76
+ "@tsed/hooks": "8.16.0-rc.3",
77
+ "@tsed/json-mapper": "8.16.0-rc.3",
78
+ "@tsed/logger": "^8.0.0",
79
+ "@tsed/logger-std": "^8.0.0",
80
+ "@tsed/platform-accept-mimes": "8.16.0-rc.3",
81
+ "@tsed/platform-exceptions": "8.16.0-rc.3",
82
+ "@tsed/platform-middlewares": "8.16.0-rc.3",
83
+ "@tsed/platform-multer": "8.16.0-rc.3",
84
+ "@tsed/platform-params": "8.16.0-rc.3",
85
+ "@tsed/platform-response-filter": "8.16.0-rc.3",
86
+ "@tsed/platform-router": "8.16.0-rc.3",
87
+ "@tsed/platform-views": "8.16.0-rc.3",
88
+ "@tsed/schema": "8.16.0-rc.3",
89
89
  "@types/json-schema": "7.0.15",
90
90
  "accepts": "^1.3.8",
91
91
  "tslib": "2.7.0",
92
92
  "uuid": "10.0.0"
93
93
  },
94
94
  "devDependencies": {
95
- "@tsed/barrels": "8.16.0-rc.2",
96
- "@tsed/engines": "8.16.0-rc.2",
97
- "@tsed/typescript": "8.16.0-rc.2",
95
+ "@tsed/barrels": "8.16.0-rc.3",
96
+ "@tsed/engines": "8.16.0-rc.3",
97
+ "@tsed/typescript": "8.16.0-rc.3",
98
98
  "cross-env": "7.0.3",
99
99
  "eslint": "9.12.0",
100
100
  "typescript": "5.4.5",
101
101
  "vitest": "3.2.4"
102
102
  },
103
103
  "peerDependencies": {
104
- "@tsed/logger": ">=8.0.0-rc.1"
104
+ "@tsed/logger": ">=8.0.0"
105
105
  },
106
106
  "peerDependenciesMeta": {
107
107
  "@tsed/logger": {
@@ -1,118 +0,0 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import { getHostInfoFromPort, isBoolean } from "@tsed/core";
3
- import { DIConfiguration, Injectable, ProviderScope } from "@tsed/di";
4
- import { JsonMapperSettings } from "@tsed/json-mapper";
5
- const rootDir = process.cwd();
6
- /**
7
- * `PlatformConfiguration` contains all information about your Server configuration.
8
- */
9
- let PlatformConfiguration = class PlatformConfiguration extends DIConfiguration {
10
- constructor() {
11
- super({ rootDir });
12
- }
13
- get port() {
14
- return this.httpPort;
15
- }
16
- set port(value) {
17
- this.httpPort = value;
18
- }
19
- get httpsOptions() {
20
- return this.getRaw("httpsOptions");
21
- }
22
- set httpsOptions(value) {
23
- this.setRaw("httpsOptions", value);
24
- }
25
- get httpPort() {
26
- return this.getRaw("httpPort");
27
- }
28
- set httpPort(value) {
29
- this.setRaw("httpPort", value);
30
- }
31
- get httpsPort() {
32
- return this.getRaw("httpsPort");
33
- }
34
- set httpsPort(value) {
35
- this.setRaw("httpsPort", value);
36
- }
37
- get mount() {
38
- return this.get("mount");
39
- }
40
- set mount(value) {
41
- this.setRaw("mount", value);
42
- }
43
- get statics() {
44
- return this.getRaw("statics") || this.getRaw("serveStatic") || {};
45
- }
46
- set statics(value) {
47
- this.setRaw("statics", value);
48
- }
49
- get acceptMimes() {
50
- return this.getRaw("acceptMimes");
51
- }
52
- set acceptMimes(value) {
53
- this.setRaw("acceptMimes", value || []);
54
- }
55
- get jsonMapper() {
56
- return {
57
- ...JsonMapperSettings
58
- };
59
- }
60
- set jsonMapper(options) {
61
- JsonMapperSettings.strictGroups = Boolean(options.strictGroups);
62
- JsonMapperSettings.disableUnsecureConstructor = Boolean(options.disableUnsecureConstructor);
63
- JsonMapperSettings.additionalProperties = Boolean(isBoolean(options.additionalProperties) ? options.additionalProperties : options.additionalProperties === "accept");
64
- }
65
- get additionalProperties() {
66
- return this.get("converter.additionalProperties") === "accept";
67
- }
68
- /**
69
- *
70
- * @returns {string|number}
71
- */
72
- getHttpPort() {
73
- return getHostInfoFromPort("http", this.getRaw("httpPort"));
74
- }
75
- /**
76
- *
77
- * @param settings
78
- */
79
- setHttpPort(settings) {
80
- this.setRaw("httpPort", `${settings.address}:${settings.port}`);
81
- }
82
- /**
83
- *
84
- * @returns {string|number}
85
- */
86
- getHttpsPort() {
87
- return getHostInfoFromPort("https", this.getRaw("httpsPort"));
88
- }
89
- /**
90
- *
91
- * @param settings
92
- */
93
- setHttpsPort(settings) {
94
- this.setRaw("httpsPort", `${settings.address}:${settings.port}`);
95
- }
96
- getBestHost() {
97
- const { httpsPort, httpPort } = this;
98
- if (httpsPort) {
99
- return this.getHttpsPort();
100
- }
101
- if (httpPort) {
102
- return this.getHttpPort();
103
- }
104
- return {
105
- toString() {
106
- return "/";
107
- }
108
- };
109
- }
110
- };
111
- PlatformConfiguration = __decorate([
112
- Injectable({
113
- scope: ProviderScope.SINGLETON,
114
- global: true
115
- }),
116
- __metadata("design:paramtypes", [])
117
- ], PlatformConfiguration);
118
- export { PlatformConfiguration };
@@ -1,31 +0,0 @@
1
- import { Env, Store } from "@tsed/core";
2
- import { mergeMount, ProviderScope, ProviderType } from "@tsed/di";
3
- export function getConfiguration(configuration = {}, module = null) {
4
- if (configuration.$$resolved) {
5
- return configuration;
6
- }
7
- const store = module ? Store.from(module).get("configuration") || {} : {};
8
- const env = configuration.env || store.env || process.env.NODE_ENV || Env.DEV;
9
- return {
10
- $$resolved: true,
11
- env,
12
- httpPort: 8080,
13
- httpsPort: false,
14
- ...store,
15
- ...configuration,
16
- scopes: {
17
- [ProviderType.CONTROLLER]: ProviderScope.SINGLETON,
18
- ...store.scopes,
19
- ...configuration.scopes
20
- },
21
- mount: mergeMount(store.mount, configuration.mount),
22
- logger: {
23
- debug: false,
24
- level: env === Env.TEST ? "off" : "info",
25
- logRequest: true,
26
- ...store.logger,
27
- ...configuration.logger,
28
- jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2
29
- }
30
- };
31
- }
@@ -1,10 +0,0 @@
1
- import { JsonMapperGlobalOptions } from "@tsed/json-mapper";
2
- export interface PlatformJsonMapperSettings extends JsonMapperGlobalOptions {
3
- }
4
- declare global {
5
- namespace TsED {
6
- interface Configuration extends Record<string, any> {
7
- jsonMapper?: PlatformJsonMapperSettings;
8
- }
9
- }
10
- }
@@ -1,17 +0,0 @@
1
- import { PlatformMulter as M1, PlatformMulterField as M4, PlatformMulterFile as M3, PlatformMulterSettings as M2 } from "@tsed/platform-multer";
2
- /**
3
- * @deprecated Since v8.5. Use PlatformMulter from @tsed/platform-multer instead.
4
- */
5
- export type PlatformMulter = M1;
6
- /**
7
- * @deprecated Since v8.5. Use PlatformMulterSettings from @tsed/platform-multer instead.
8
- */
9
- export type PlatformMulterSettings = M2;
10
- /**
11
- * @deprecated Since v8.5. Use PlatformMulterFile from @tsed/platform-multer instead.
12
- */
13
- export type PlatformMulterFile = M3;
14
- /**
15
- * @deprecated Since v8.5. Use PlatformMulterField from @tsed/platform-multer instead.
16
- */
17
- export type PlatformMulterField = M4;
@@ -1,10 +0,0 @@
1
- export interface PlatformRouterSettings {
2
- appendChildrenRoutesFirst?: boolean;
3
- }
4
- declare global {
5
- namespace TsED {
6
- interface Configuration extends Record<string, any> {
7
- router?: PlatformRouterSettings;
8
- }
9
- }
10
- }
@@ -1,78 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import Https from "node:https";
3
- import { getHostInfoFromPort } from "@tsed/core";
4
- import { DIConfiguration, TokenProvider } from "@tsed/di";
5
- import { PlatformJsonMapperSettings } from "../interfaces/PlatformJsonMapperSettings.js";
6
- /**
7
- * `PlatformConfiguration` contains all information about your Server configuration.
8
- */
9
- export declare class PlatformConfiguration extends DIConfiguration {
10
- constructor();
11
- get port(): string | number | false;
12
- set port(value: string | number | false);
13
- get httpsOptions(): Https.ServerOptions;
14
- set httpsOptions(value: Https.ServerOptions);
15
- get httpPort(): string | number | false;
16
- set httpPort(value: string | number | false);
17
- get httpsPort(): string | number | false;
18
- set httpsPort(value: string | number | false);
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)[]>);
23
- get acceptMimes(): string[];
24
- set acceptMimes(value: string[]);
25
- get jsonMapper(): Partial<PlatformJsonMapperSettings>;
26
- set jsonMapper(options: Partial<PlatformJsonMapperSettings>);
27
- get additionalProperties(): boolean;
28
- /**
29
- *
30
- * @returns {string|number}
31
- */
32
- getHttpPort(): ReturnType<typeof getHostInfoFromPort>;
33
- /**
34
- *
35
- * @param settings
36
- */
37
- setHttpPort(settings: {
38
- address: string;
39
- port: number;
40
- }): void;
41
- /**
42
- *
43
- * @returns {string|number}
44
- */
45
- getHttpsPort(): {
46
- protocol: string;
47
- address: string;
48
- port: number;
49
- toString(): string;
50
- };
51
- /**
52
- *
53
- * @param settings
54
- */
55
- setHttpsPort(settings: {
56
- address: string;
57
- port: number;
58
- }): void;
59
- getBestHost(): {
60
- protocol: string;
61
- address: string;
62
- port: number;
63
- toString(): string;
64
- } | {
65
- toString(): string;
66
- };
67
- }
68
- declare global {
69
- namespace TsED {
70
- interface Context {
71
- }
72
- /**
73
- * Here to allow extension on DIConfiguration base service
74
- */
75
- interface DIConfiguration extends PlatformConfiguration {
76
- }
77
- }
78
- }
@@ -1,2 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- export declare function getConfiguration(configuration?: any, module?: Type<any> | null): any;