@tsed/platform-http 8.16.0-rc.3 → 8.16.0-rc.4
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "@tsed/platform-accept-mimes";
|
|
2
1
|
import { colors, configuration, constant, createContainer, destroyInjector, injector, logger, ProviderScope } from "@tsed/di";
|
|
3
2
|
import { $alter, $asyncAlter, $asyncEmit } from "@tsed/hooks";
|
|
4
3
|
import { defineConfiguration } from "../config/defineConfiguration.js";
|
|
@@ -19,15 +18,12 @@ export class PlatformBuilder {
|
|
|
19
18
|
#promise;
|
|
20
19
|
#servers;
|
|
21
20
|
#listeners;
|
|
22
|
-
constructor(
|
|
21
|
+
constructor(settings) {
|
|
23
22
|
this.startedAt = new Date();
|
|
24
23
|
this.current = new Date();
|
|
25
24
|
this.#listeners = [];
|
|
26
|
-
this.#rootModule =
|
|
27
|
-
createInjector(defineConfiguration(
|
|
28
|
-
rootModule: module,
|
|
29
|
-
...settings
|
|
30
|
-
}));
|
|
25
|
+
this.#rootModule = settings.rootModule;
|
|
26
|
+
createInjector(defineConfiguration(settings));
|
|
31
27
|
this.log(`Loading ${this.name.toUpperCase()} platform adapter...`);
|
|
32
28
|
this.createHttpServers();
|
|
33
29
|
this.log("Injector created...");
|
|
@@ -36,7 +32,7 @@ export class PlatformBuilder {
|
|
|
36
32
|
return this.adapter.NAME;
|
|
37
33
|
}
|
|
38
34
|
get rootModule() {
|
|
39
|
-
return injector().get(this.#rootModule);
|
|
35
|
+
return this.#rootModule && injector().get(this.#rootModule);
|
|
40
36
|
}
|
|
41
37
|
get app() {
|
|
42
38
|
return injector().get(PlatformApplication);
|
|
@@ -88,13 +84,11 @@ export class PlatformBuilder {
|
|
|
88
84
|
});
|
|
89
85
|
}
|
|
90
86
|
static build(module, settings) {
|
|
91
|
-
return new PlatformBuilder(
|
|
87
|
+
return new PlatformBuilder({
|
|
88
|
+
rootModule: settings ? module : undefined,
|
|
89
|
+
...(settings ? settings : module)
|
|
90
|
+
});
|
|
92
91
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Bootstrap a server application
|
|
95
|
-
* @param module
|
|
96
|
-
* @param settings
|
|
97
|
-
*/
|
|
98
92
|
static bootstrap(module, settings) {
|
|
99
93
|
return this.build(module, settings).bootstrap();
|
|
100
94
|
}
|
|
@@ -139,9 +133,9 @@ export class PlatformBuilder {
|
|
|
139
133
|
// init routes (controllers, middlewares, etc...)
|
|
140
134
|
this.log("Load routes");
|
|
141
135
|
await this.adapter.beforeLoadRoutes();
|
|
142
|
-
if (this.rootModule
|
|
136
|
+
if (this.rootModule?.$beforeRoutesInit) {
|
|
143
137
|
await this.rootModule.$beforeRoutesInit();
|
|
144
|
-
// remove method to avoid multiple call and preserve hook order
|
|
138
|
+
// remove this method to avoid multiple call and preserve hook order
|
|
145
139
|
this.rootModule.$beforeRoutesInit = () => { };
|
|
146
140
|
}
|
|
147
141
|
// Hooks execution (adding middlewares, controllers, services, etc...)
|
|
@@ -165,11 +159,13 @@ export class PlatformBuilder {
|
|
|
165
159
|
const routes = settings.get("routes").concat(resolveControllers(settings));
|
|
166
160
|
settings.set("routes", routes);
|
|
167
161
|
const container = createContainer();
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
162
|
+
if (this.#rootModule) {
|
|
163
|
+
container.delete(this.#rootModule);
|
|
164
|
+
container.addProvider(this.#rootModule, {
|
|
165
|
+
type: "server:module",
|
|
166
|
+
scope: ProviderScope.SINGLETON
|
|
167
|
+
});
|
|
168
|
+
}
|
|
173
169
|
await injector().load(container);
|
|
174
170
|
this.log("Settings and injector loaded...");
|
|
175
171
|
await this.callHook("$afterInit");
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import "@tsed/platform-accept-mimes";
|
|
3
2
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
4
|
-
import { Type } from "@tsed/core";
|
|
3
|
+
import type { Type } from "@tsed/core";
|
|
5
4
|
import { InjectorService, ProviderOpts, TokenProvider } from "@tsed/di";
|
|
6
5
|
import { PlatformLayer } from "@tsed/platform-router";
|
|
7
6
|
import { Platform } from "../services/Platform.js";
|
|
@@ -14,9 +13,9 @@ export declare class PlatformBuilder<App = TsED.Application> {
|
|
|
14
13
|
#private;
|
|
15
14
|
protected startedAt: Date;
|
|
16
15
|
protected current: Date;
|
|
17
|
-
protected constructor(
|
|
16
|
+
protected constructor(settings: Partial<TsED.Configuration>);
|
|
18
17
|
get name(): string;
|
|
19
|
-
get rootModule(): any;
|
|
18
|
+
get rootModule(): any | undefined;
|
|
20
19
|
get app(): PlatformApplication<App>;
|
|
21
20
|
get platform(): Platform;
|
|
22
21
|
get adapter(): PlatformAdapter<any>;
|
|
@@ -45,14 +44,15 @@ export declare class PlatformBuilder<App = TsED.Application> {
|
|
|
45
44
|
* @deprecated use injector() instead of this method.
|
|
46
45
|
*/
|
|
47
46
|
get injector(): InjectorService;
|
|
48
|
-
static create<App = TsED.Application>(
|
|
49
|
-
static
|
|
47
|
+
static create<App = TsED.Application>(settings: PlatformBuilderSettings<App>): PlatformBuilder<App>;
|
|
48
|
+
static create<App = TsED.Application>(module: Type<any>, settings?: PlatformBuilderSettings<App>): PlatformBuilder<App>;
|
|
49
|
+
static build<App = TsED.Application>(settings: PlatformBuilderSettings<App>): PlatformBuilder<App>;
|
|
50
|
+
static build<App = TsED.Application>(module: Type<any>, settings?: PlatformBuilderSettings<App>): PlatformBuilder<App>;
|
|
50
51
|
/**
|
|
51
52
|
* Bootstrap a server application
|
|
52
|
-
* @param module
|
|
53
|
-
* @param settings
|
|
54
53
|
*/
|
|
55
|
-
static bootstrap<App = TsED.Application>(
|
|
54
|
+
static bootstrap<App = TsED.Application>(settings: PlatformBuilderSettings<App>): Promise<PlatformBuilder<App>>;
|
|
55
|
+
static bootstrap<App = TsED.Application>(module: Type<any>, settings?: PlatformBuilderSettings<App>): Promise<PlatformBuilder<App>>;
|
|
56
56
|
callback(): (req: IncomingMessage, res: ServerResponse) => void;
|
|
57
57
|
callback(req: IncomingMessage, res: ServerResponse): void;
|
|
58
58
|
log(...data: any[]): any;
|
|
@@ -8,8 +8,8 @@ export declare class PlatformCustom extends FakeAdapter {
|
|
|
8
8
|
new (): {};
|
|
9
9
|
};
|
|
10
10
|
}[];
|
|
11
|
-
static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<
|
|
12
|
-
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<
|
|
11
|
+
static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<any>;
|
|
12
|
+
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<any>>;
|
|
13
13
|
afterLoadRoutes(): Promise<any>;
|
|
14
14
|
beforeLoadRoutes(): Promise<any>;
|
|
15
15
|
useContext(): any;
|
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.
|
|
5
|
+
"version": "8.16.0-rc.4",
|
|
6
6
|
"source": "./src/common/index.ts",
|
|
7
7
|
"main": "./lib/esm/common/index.js",
|
|
8
8
|
"module": "./lib/esm/common/index.js",
|
|
@@ -70,31 +70,31 @@
|
|
|
70
70
|
}
|
|
71
71
|
],
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@tsed/core": "8.16.0-rc.
|
|
74
|
-
"@tsed/di": "8.16.0-rc.
|
|
75
|
-
"@tsed/exceptions": "8.16.0-rc.
|
|
76
|
-
"@tsed/hooks": "8.16.0-rc.
|
|
77
|
-
"@tsed/json-mapper": "8.16.0-rc.
|
|
73
|
+
"@tsed/core": "8.16.0-rc.4",
|
|
74
|
+
"@tsed/di": "8.16.0-rc.4",
|
|
75
|
+
"@tsed/exceptions": "8.16.0-rc.4",
|
|
76
|
+
"@tsed/hooks": "8.16.0-rc.4",
|
|
77
|
+
"@tsed/json-mapper": "8.16.0-rc.4",
|
|
78
78
|
"@tsed/logger": "^8.0.0",
|
|
79
79
|
"@tsed/logger-std": "^8.0.0",
|
|
80
|
-
"@tsed/platform-accept-mimes": "8.16.0-rc.
|
|
81
|
-
"@tsed/platform-exceptions": "8.16.0-rc.
|
|
82
|
-
"@tsed/platform-middlewares": "8.16.0-rc.
|
|
83
|
-
"@tsed/platform-multer": "8.16.0-rc.
|
|
84
|
-
"@tsed/platform-params": "8.16.0-rc.
|
|
85
|
-
"@tsed/platform-response-filter": "8.16.0-rc.
|
|
86
|
-
"@tsed/platform-router": "8.16.0-rc.
|
|
87
|
-
"@tsed/platform-views": "8.16.0-rc.
|
|
88
|
-
"@tsed/schema": "8.16.0-rc.
|
|
80
|
+
"@tsed/platform-accept-mimes": "8.16.0-rc.4",
|
|
81
|
+
"@tsed/platform-exceptions": "8.16.0-rc.4",
|
|
82
|
+
"@tsed/platform-middlewares": "8.16.0-rc.4",
|
|
83
|
+
"@tsed/platform-multer": "8.16.0-rc.4",
|
|
84
|
+
"@tsed/platform-params": "8.16.0-rc.4",
|
|
85
|
+
"@tsed/platform-response-filter": "8.16.0-rc.4",
|
|
86
|
+
"@tsed/platform-router": "8.16.0-rc.4",
|
|
87
|
+
"@tsed/platform-views": "8.16.0-rc.4",
|
|
88
|
+
"@tsed/schema": "8.16.0-rc.4",
|
|
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.
|
|
96
|
-
"@tsed/engines": "8.16.0-rc.
|
|
97
|
-
"@tsed/typescript": "8.16.0-rc.
|
|
95
|
+
"@tsed/barrels": "8.16.0-rc.4",
|
|
96
|
+
"@tsed/engines": "8.16.0-rc.4",
|
|
97
|
+
"@tsed/typescript": "8.16.0-rc.4",
|
|
98
98
|
"cross-env": "7.0.3",
|
|
99
99
|
"eslint": "9.12.0",
|
|
100
100
|
"typescript": "5.4.5",
|