@tsed/platform-express 6.89.0 → 6.90.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.
- package/lib/cjs/components/PlatformExpress.d.ts +12 -9
- package/lib/cjs/components/PlatformExpress.js +64 -54
- package/lib/cjs/components/PlatformExpress.js.map +1 -1
- package/lib/cjs/index.js +2 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/components/PlatformExpress.js +64 -54
- package/lib/esm/components/PlatformExpress.js.map +1 -1
- package/lib/esm/index.js +2 -2
- package/lib/esm/index.js.map +1 -1
- package/lib/types/components/PlatformExpress.d.ts +12 -9
- package/package.json +11 -11
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { PlatformBuilder, PlatformHandler, PlatformRequest, PlatformResponse, PlatformRouter } from "@tsed/common";
|
|
2
|
-
import { Type } from "@tsed/core";
|
|
3
1
|
import Express from "express";
|
|
2
|
+
import { PlatformAdapter, PlatformBuilder, PlatformHandler, PlatformRequest, PlatformResponse, PlatformRouter } from "@tsed/common";
|
|
3
|
+
import { Type } from "@tsed/core";
|
|
4
4
|
import { PlatformExpressHandler, PlatformExpressRequest, PlatformExpressResponse, PlatformExpressRouter } from "../services";
|
|
5
5
|
/**
|
|
6
6
|
* @platform
|
|
7
7
|
* @express
|
|
8
8
|
*/
|
|
9
|
-
export declare class PlatformExpress
|
|
10
|
-
|
|
9
|
+
export declare class PlatformExpress implements PlatformAdapter<Express.Application, Express.Router> {
|
|
10
|
+
private platform;
|
|
11
|
+
readonly providers: ({
|
|
11
12
|
provide: typeof PlatformRouter;
|
|
12
13
|
useClass: typeof PlatformExpressRouter;
|
|
13
14
|
} | {
|
|
@@ -20,20 +21,22 @@ export declare class PlatformExpress extends PlatformBuilder<Express.Application
|
|
|
20
21
|
provide: typeof PlatformRequest;
|
|
21
22
|
useClass: typeof PlatformExpressRequest;
|
|
22
23
|
})[];
|
|
24
|
+
constructor(platform: PlatformBuilder<Express.Application, Express.Router>);
|
|
23
25
|
/**
|
|
24
26
|
* Create new serverless application. In this mode, the component scan are disabled.
|
|
25
27
|
* @param module
|
|
26
28
|
* @param settings
|
|
27
29
|
*/
|
|
28
|
-
static create(module: Type<any>, settings?: Partial<TsED.Configuration>):
|
|
30
|
+
static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Express.Application, Express.Router>;
|
|
29
31
|
/**
|
|
30
32
|
* Bootstrap a server application
|
|
31
33
|
* @param module
|
|
32
34
|
* @param settings
|
|
33
35
|
*/
|
|
34
|
-
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Express.Application, Express.Router>>;
|
|
37
|
+
useRouter(): this;
|
|
38
|
+
beforeLoadRoutes(): Promise<void>;
|
|
39
|
+
afterLoadRoutes(): Promise<void>;
|
|
40
|
+
useContext(): this;
|
|
38
41
|
private configureViewsEngine;
|
|
39
42
|
}
|
|
@@ -28,18 +28,41 @@ const services_1 = require("../services");
|
|
|
28
28
|
* @platform
|
|
29
29
|
* @express
|
|
30
30
|
*/
|
|
31
|
-
class PlatformExpress
|
|
31
|
+
class PlatformExpress {
|
|
32
|
+
constructor(platform) {
|
|
33
|
+
this.platform = platform;
|
|
34
|
+
this.providers = [
|
|
35
|
+
{
|
|
36
|
+
provide: common_1.PlatformApplication,
|
|
37
|
+
useClass: services_1.PlatformExpressApplication
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
provide: common_1.PlatformRouter,
|
|
41
|
+
useClass: services_1.PlatformExpressRouter
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
provide: common_1.PlatformHandler,
|
|
45
|
+
useClass: services_1.PlatformExpressHandler
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
provide: common_1.PlatformResponse,
|
|
49
|
+
useClass: services_1.PlatformExpressResponse
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
provide: common_1.PlatformRequest,
|
|
53
|
+
useClass: services_1.PlatformExpressRequest
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
}
|
|
32
57
|
/**
|
|
33
58
|
* Create new serverless application. In this mode, the component scan are disabled.
|
|
34
59
|
* @param module
|
|
35
60
|
* @param settings
|
|
36
61
|
*/
|
|
37
62
|
static create(module, settings = {}) {
|
|
38
|
-
return
|
|
39
|
-
httpsPort: false,
|
|
40
|
-
httpPort: false,
|
|
63
|
+
return common_1.PlatformBuilder.create(module, {
|
|
41
64
|
...settings,
|
|
42
|
-
|
|
65
|
+
adapter: PlatformExpress
|
|
43
66
|
});
|
|
44
67
|
}
|
|
45
68
|
/**
|
|
@@ -48,56 +71,65 @@ class PlatformExpress extends common_1.PlatformBuilder {
|
|
|
48
71
|
* @param settings
|
|
49
72
|
*/
|
|
50
73
|
static async bootstrap(module, settings = {}) {
|
|
51
|
-
return
|
|
74
|
+
return common_1.PlatformBuilder.bootstrap(module, {
|
|
75
|
+
...settings,
|
|
76
|
+
adapter: PlatformExpress
|
|
77
|
+
});
|
|
52
78
|
}
|
|
53
79
|
useRouter() {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
useContext() {
|
|
60
|
-
this.logger.debug("Mount app context");
|
|
61
|
-
const invoke = (0, common_1.createContext)(this.injector);
|
|
62
|
-
this.app.getApp().use(async (request, response, next) => {
|
|
63
|
-
await invoke({ request, response });
|
|
64
|
-
return next();
|
|
65
|
-
});
|
|
80
|
+
const { logger, app } = this.platform;
|
|
81
|
+
logger.debug("Mount app router");
|
|
82
|
+
app.getApp().use(rawBodyMiddleware_1.rawBodyMiddleware);
|
|
83
|
+
app.getApp().use(app.getRouter());
|
|
66
84
|
return this;
|
|
67
85
|
}
|
|
68
|
-
async
|
|
86
|
+
async beforeLoadRoutes() {
|
|
87
|
+
const { injector, app } = this.platform;
|
|
69
88
|
// disable x-powered-by header
|
|
70
|
-
|
|
89
|
+
injector.settings.get("env") === core_1.Env.PROD && app.getApp().disable("x-powered-by");
|
|
71
90
|
await this.configureViewsEngine();
|
|
72
|
-
|
|
91
|
+
}
|
|
92
|
+
async afterLoadRoutes() {
|
|
93
|
+
const { injector, app } = this.platform;
|
|
73
94
|
// NOT FOUND
|
|
74
|
-
|
|
95
|
+
app.use((req, res, next) => {
|
|
75
96
|
var _a;
|
|
76
|
-
!res.headersSent && ((_a =
|
|
97
|
+
!res.headersSent && ((_a = injector.get(common_1.PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.resourceNotFound(req.$ctx));
|
|
77
98
|
});
|
|
78
99
|
// EXCEPTION FILTERS
|
|
79
|
-
|
|
100
|
+
app.use((err, req, res, next) => {
|
|
80
101
|
var _a;
|
|
81
|
-
!res.headersSent && ((_a =
|
|
102
|
+
!res.headersSent && ((_a = injector.get(common_1.PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.catch(err, req.$ctx));
|
|
82
103
|
});
|
|
83
104
|
}
|
|
105
|
+
useContext() {
|
|
106
|
+
const { logger, app, injector } = this.platform;
|
|
107
|
+
logger.debug("Mount app context");
|
|
108
|
+
const invoke = (0, common_1.createContext)(injector);
|
|
109
|
+
app.getApp().use(async (request, response, next) => {
|
|
110
|
+
await invoke({ request, response });
|
|
111
|
+
return next();
|
|
112
|
+
});
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
84
115
|
async configureViewsEngine() {
|
|
116
|
+
const { settings, injector, app } = this.platform;
|
|
85
117
|
try {
|
|
86
|
-
const { exists, disabled } =
|
|
118
|
+
const { exists, disabled } = settings.get("views") || {};
|
|
87
119
|
if (exists && !disabled) {
|
|
88
120
|
const { PlatformViews } = await Promise.resolve().then(() => __importStar(require("@tsed/platform-views")));
|
|
89
|
-
const platformViews =
|
|
90
|
-
const
|
|
121
|
+
const platformViews = injector.get(PlatformViews);
|
|
122
|
+
const express = app.getApp();
|
|
91
123
|
platformViews.getEngines().forEach(({ extension, engine }) => {
|
|
92
|
-
|
|
124
|
+
express.engine(extension, engine.render);
|
|
93
125
|
});
|
|
94
|
-
platformViews.viewEngine &&
|
|
95
|
-
platformViews.root &&
|
|
126
|
+
platformViews.viewEngine && express.set("view engine", platformViews.viewEngine);
|
|
127
|
+
platformViews.root && express.set("views", platformViews.root);
|
|
96
128
|
}
|
|
97
129
|
}
|
|
98
130
|
catch (error) {
|
|
99
131
|
// istanbul ignore next
|
|
100
|
-
|
|
132
|
+
injector.logger.warn({
|
|
101
133
|
event: "PLATFORM_VIEWS_ERROR",
|
|
102
134
|
message: "Unable to configure the PlatformViews service on your environment.",
|
|
103
135
|
error
|
|
@@ -106,26 +138,4 @@ class PlatformExpress extends common_1.PlatformBuilder {
|
|
|
106
138
|
}
|
|
107
139
|
}
|
|
108
140
|
exports.PlatformExpress = PlatformExpress;
|
|
109
|
-
PlatformExpress.providers = [
|
|
110
|
-
{
|
|
111
|
-
provide: common_1.PlatformApplication,
|
|
112
|
-
useClass: services_1.PlatformExpressApplication
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
provide: common_1.PlatformRouter,
|
|
116
|
-
useClass: services_1.PlatformExpressRouter
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
provide: common_1.PlatformHandler,
|
|
120
|
-
useClass: services_1.PlatformExpressHandler
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
provide: common_1.PlatformResponse,
|
|
124
|
-
useClass: services_1.PlatformExpressResponse
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
provide: common_1.PlatformRequest,
|
|
128
|
-
useClass: services_1.PlatformExpressRequest
|
|
129
|
-
}
|
|
130
|
-
];
|
|
131
141
|
//# sourceMappingURL=PlatformExpress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformExpress.js","sourceRoot":"","sources":["../../../src/components/PlatformExpress.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"PlatformExpress.js","sourceRoot":"","sources":["../../../src/components/PlatformExpress.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,yCAUsB;AACtB,qCAAqC;AACrC,wEAAmE;AACnE,0CAMqB;AAErB;;;GAGG;AACH,MAAa,eAAe;IAwB1B,YAAoB,QAA8D;QAA9D,aAAQ,GAAR,QAAQ,CAAsD;QAvBzE,cAAS,GAAG;YACnB;gBACE,OAAO,EAAE,4BAAmB;gBAC5B,QAAQ,EAAE,qCAA0B;aACrC;YACD;gBACE,OAAO,EAAE,uBAAc;gBACvB,QAAQ,EAAE,gCAAqB;aAChC;YACD;gBACE,OAAO,EAAE,wBAAe;gBACxB,QAAQ,EAAE,iCAAsB;aACjC;YACD;gBACE,OAAO,EAAE,yBAAgB;gBACzB,QAAQ,EAAE,kCAAuB;aAClC;YACD;gBACE,OAAO,EAAE,wBAAe;gBACxB,QAAQ,EAAE,iCAAsB;aACjC;SACF,CAAC;IAEmF,CAAC;IAEtF;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,MAAiB,EAAE,WAAwC,EAAE;QACzE,OAAO,wBAAe,CAAC,MAAM,CAAsC,MAAM,EAAE;YACzE,GAAG,QAAQ;YACX,OAAO,EAAE,eAAe;SACzB,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAiB,EAAE,WAAwC,EAAE;QAClF,OAAO,wBAAe,CAAC,SAAS,CAAsC,MAAM,EAAE;YAC5E,GAAG,QAAQ;YACX,OAAO,EAAE,eAAe;SACzB,CAAC,CAAC;IACL,CAAC;IAED,SAAS;QACP,MAAM,EAAC,MAAM,EAAE,GAAG,EAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;QAEpC,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACjC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,q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K,EAAE;YACd,uBAAuB;YACvB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE,sBAAsB;gBAC7B,OAAO,EAAE,oEAAoE;gBAC7E,KAAK;aACN,CAAC,CAAC;SACJ;IACH,CAAC;CACF;AA3HD,0CA2HC","sourcesContent":["import Express from \"express\";\nimport type {PlatformViews} from \"@tsed/platform-views\";\nimport {\n createContext,\n PlatformAdapter,\n PlatformApplication,\n PlatformBuilder,\n PlatformExceptions,\n PlatformHandler,\n PlatformRequest,\n PlatformResponse,\n PlatformRouter\n} from \"@tsed/common\";\nimport {Env, Type} from \"@tsed/core\";\nimport {rawBodyMiddleware} from \"../middlewares/rawBodyMiddleware\";\nimport {\n PlatformExpressApplication,\n PlatformExpressHandler,\n PlatformExpressRequest,\n PlatformExpressResponse,\n PlatformExpressRouter\n} from \"../services\";\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpress implements PlatformAdapter<Express.Application, Express.Router> {\n readonly providers = [\n {\n provide: PlatformApplication,\n useClass: PlatformExpressApplication\n },\n {\n provide: PlatformRouter,\n useClass: PlatformExpressRouter\n },\n {\n provide: PlatformHandler,\n useClass: PlatformExpressHandler\n },\n {\n provide: PlatformResponse,\n useClass: PlatformExpressResponse\n },\n {\n provide: PlatformRequest,\n useClass: PlatformExpressRequest\n }\n ];\n\n constructor(private platform: PlatformBuilder<Express.Application, Express.Router>) {}\n\n /**\n * Create new serverless application. In this mode, the component scan are disabled.\n * @param module\n * @param settings\n */\n static create(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return PlatformBuilder.create<Express.Application, Express.Router>(module, {\n ...settings,\n adapter: PlatformExpress\n });\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return PlatformBuilder.bootstrap<Express.Application, Express.Router>(module, {\n ...settings,\n adapter: PlatformExpress\n });\n }\n\n useRouter(): this {\n const {logger, app} = this.platform;\n\n logger.debug(\"Mount app router\");\n app.getApp().use(rawBodyMiddleware);\n app.getApp().use(app.getRouter());\n\n return this;\n }\n\n async beforeLoadRoutes() {\n const {injector, app} = this.platform;\n // disable x-powered-by header\n injector.settings.get(\"env\") === Env.PROD && app.getApp().disable(\"x-powered-by\");\n\n await this.configureViewsEngine();\n }\n\n async afterLoadRoutes() {\n const {injector, app} = this.platform;\n // NOT FOUND\n app.use((req: any, res: any, next: any) => {\n !res.headersSent && injector.get<PlatformExceptions>(PlatformExceptions)?.resourceNotFound(req.$ctx);\n });\n\n // EXCEPTION FILTERS\n app.use((err: any, req: any, res: any, next: any) => {\n !res.headersSent && injector.get<PlatformExceptions>(PlatformExceptions)?.catch(err, req.$ctx);\n });\n }\n\n useContext(): this {\n const {logger, app, injector} = this.platform;\n\n logger.debug(\"Mount app context\");\n\n const invoke = createContext(injector);\n\n app.getApp().use(async (request: any, response: any, next: any) => {\n await invoke({request, response});\n\n return next();\n });\n\n return this;\n }\n\n private async configureViewsEngine() {\n const {settings, injector, app} = this.platform;\n try {\n const {exists, disabled} = settings.get(\"views\") || {};\n\n if (exists && !disabled) {\n const {PlatformViews} = await import(\"@tsed/platform-views\");\n const platformViews = injector.get<PlatformViews>(PlatformViews)!;\n const express = app.getApp();\n\n platformViews.getEngines().forEach(({extension, engine}) => {\n express.engine(extension, engine.render);\n });\n\n platformViews.viewEngine && express.set(\"view engine\", platformViews.viewEngine);\n platformViews.root && express.set(\"views\", platformViews.root);\n }\n } catch (error) {\n // istanbul ignore next\n injector.logger.warn({\n event: \"PLATFORM_VIEWS_ERROR\",\n message: \"Unable to configure the PlatformViews service on your environment.\",\n error\n });\n }\n }\n}\n"]}
|
package/lib/cjs/index.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const common_1 = require("@tsed/common");
|
|
5
5
|
const PlatformExpress_1 = require("./components/PlatformExpress");
|
|
6
|
-
common_1.PlatformTest.
|
|
7
|
-
common_1.PlatformBuilder.
|
|
6
|
+
common_1.PlatformTest.adapter = PlatformExpress_1.PlatformExpress;
|
|
7
|
+
common_1.PlatformBuilder.adapter = PlatformExpress_1.PlatformExpress;
|
|
8
8
|
// interfaces
|
|
9
9
|
(0, tslib_1.__exportStar)(require("./interfaces"), exports);
|
|
10
10
|
// decorators
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAA2D;AAE3D,kEAA6D;AAE7D,qBAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAA2D;AAE3D,kEAA6D;AAE7D,qBAAY,CAAC,OAAO,GAAG,iCAAsB,CAAC;AAC9C,wBAAe,CAAC,OAAO,GAAG,iCAAsB,CAAC;AAEjD,aAAa;AACb,4DAA6B;AAE7B,aAAa;AACb,4DAA6B;AAE7B,WAAW;AACX,0DAA2B;AAE3B,aAAa;AACb,4EAA6C","sourcesContent":["import {PlatformBuilder, PlatformTest} from \"@tsed/common\";\n\nimport {PlatformExpress} from \"./components/PlatformExpress\";\n\nPlatformTest.adapter = PlatformExpress as any;\nPlatformBuilder.adapter = PlatformExpress as any;\n\n// interfaces\nexport * from \"./interfaces\";\n\n// decorators\nexport * from \"./decorators\";\n\n// services\nexport * from \"./services\";\n\n// components\nexport * from \"./components/PlatformExpress\";\n"]}
|
|
@@ -6,18 +6,41 @@ import { PlatformExpressApplication, PlatformExpressHandler, PlatformExpressRequ
|
|
|
6
6
|
* @platform
|
|
7
7
|
* @express
|
|
8
8
|
*/
|
|
9
|
-
export class PlatformExpress
|
|
9
|
+
export class PlatformExpress {
|
|
10
|
+
constructor(platform) {
|
|
11
|
+
this.platform = platform;
|
|
12
|
+
this.providers = [
|
|
13
|
+
{
|
|
14
|
+
provide: PlatformApplication,
|
|
15
|
+
useClass: PlatformExpressApplication
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
provide: PlatformRouter,
|
|
19
|
+
useClass: PlatformExpressRouter
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
provide: PlatformHandler,
|
|
23
|
+
useClass: PlatformExpressHandler
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
provide: PlatformResponse,
|
|
27
|
+
useClass: PlatformExpressResponse
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
provide: PlatformRequest,
|
|
31
|
+
useClass: PlatformExpressRequest
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
}
|
|
10
35
|
/**
|
|
11
36
|
* Create new serverless application. In this mode, the component scan are disabled.
|
|
12
37
|
* @param module
|
|
13
38
|
* @param settings
|
|
14
39
|
*/
|
|
15
40
|
static create(module, settings = {}) {
|
|
16
|
-
return
|
|
17
|
-
httpsPort: false,
|
|
18
|
-
httpPort: false,
|
|
41
|
+
return PlatformBuilder.create(module, {
|
|
19
42
|
...settings,
|
|
20
|
-
|
|
43
|
+
adapter: PlatformExpress
|
|
21
44
|
});
|
|
22
45
|
}
|
|
23
46
|
/**
|
|
@@ -26,56 +49,65 @@ export class PlatformExpress extends PlatformBuilder {
|
|
|
26
49
|
* @param settings
|
|
27
50
|
*/
|
|
28
51
|
static async bootstrap(module, settings = {}) {
|
|
29
|
-
return
|
|
52
|
+
return PlatformBuilder.bootstrap(module, {
|
|
53
|
+
...settings,
|
|
54
|
+
adapter: PlatformExpress
|
|
55
|
+
});
|
|
30
56
|
}
|
|
31
57
|
useRouter() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
useContext() {
|
|
38
|
-
this.logger.debug("Mount app context");
|
|
39
|
-
const invoke = createContext(this.injector);
|
|
40
|
-
this.app.getApp().use(async (request, response, next) => {
|
|
41
|
-
await invoke({ request, response });
|
|
42
|
-
return next();
|
|
43
|
-
});
|
|
58
|
+
const { logger, app } = this.platform;
|
|
59
|
+
logger.debug("Mount app router");
|
|
60
|
+
app.getApp().use(rawBodyMiddleware);
|
|
61
|
+
app.getApp().use(app.getRouter());
|
|
44
62
|
return this;
|
|
45
63
|
}
|
|
46
|
-
async
|
|
64
|
+
async beforeLoadRoutes() {
|
|
65
|
+
const { injector, app } = this.platform;
|
|
47
66
|
// disable x-powered-by header
|
|
48
|
-
|
|
67
|
+
injector.settings.get("env") === Env.PROD && app.getApp().disable("x-powered-by");
|
|
49
68
|
await this.configureViewsEngine();
|
|
50
|
-
|
|
69
|
+
}
|
|
70
|
+
async afterLoadRoutes() {
|
|
71
|
+
const { injector, app } = this.platform;
|
|
51
72
|
// NOT FOUND
|
|
52
|
-
|
|
73
|
+
app.use((req, res, next) => {
|
|
53
74
|
var _a;
|
|
54
|
-
!res.headersSent && ((_a =
|
|
75
|
+
!res.headersSent && ((_a = injector.get(PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.resourceNotFound(req.$ctx));
|
|
55
76
|
});
|
|
56
77
|
// EXCEPTION FILTERS
|
|
57
|
-
|
|
78
|
+
app.use((err, req, res, next) => {
|
|
58
79
|
var _a;
|
|
59
|
-
!res.headersSent && ((_a =
|
|
80
|
+
!res.headersSent && ((_a = injector.get(PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.catch(err, req.$ctx));
|
|
60
81
|
});
|
|
61
82
|
}
|
|
83
|
+
useContext() {
|
|
84
|
+
const { logger, app, injector } = this.platform;
|
|
85
|
+
logger.debug("Mount app context");
|
|
86
|
+
const invoke = createContext(injector);
|
|
87
|
+
app.getApp().use(async (request, response, next) => {
|
|
88
|
+
await invoke({ request, response });
|
|
89
|
+
return next();
|
|
90
|
+
});
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
62
93
|
async configureViewsEngine() {
|
|
94
|
+
const { settings, injector, app } = this.platform;
|
|
63
95
|
try {
|
|
64
|
-
const { exists, disabled } =
|
|
96
|
+
const { exists, disabled } = settings.get("views") || {};
|
|
65
97
|
if (exists && !disabled) {
|
|
66
98
|
const { PlatformViews } = await import("@tsed/platform-views");
|
|
67
|
-
const platformViews =
|
|
68
|
-
const
|
|
99
|
+
const platformViews = injector.get(PlatformViews);
|
|
100
|
+
const express = app.getApp();
|
|
69
101
|
platformViews.getEngines().forEach(({ extension, engine }) => {
|
|
70
|
-
|
|
102
|
+
express.engine(extension, engine.render);
|
|
71
103
|
});
|
|
72
|
-
platformViews.viewEngine &&
|
|
73
|
-
platformViews.root &&
|
|
104
|
+
platformViews.viewEngine && express.set("view engine", platformViews.viewEngine);
|
|
105
|
+
platformViews.root && express.set("views", platformViews.root);
|
|
74
106
|
}
|
|
75
107
|
}
|
|
76
108
|
catch (error) {
|
|
77
109
|
// istanbul ignore next
|
|
78
|
-
|
|
110
|
+
injector.logger.warn({
|
|
79
111
|
event: "PLATFORM_VIEWS_ERROR",
|
|
80
112
|
message: "Unable to configure the PlatformViews service on your environment.",
|
|
81
113
|
error
|
|
@@ -83,26 +115,4 @@ export class PlatformExpress extends PlatformBuilder {
|
|
|
83
115
|
}
|
|
84
116
|
}
|
|
85
117
|
}
|
|
86
|
-
PlatformExpress.providers = [
|
|
87
|
-
{
|
|
88
|
-
provide: PlatformApplication,
|
|
89
|
-
useClass: PlatformExpressApplication
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
provide: PlatformRouter,
|
|
93
|
-
useClass: PlatformExpressRouter
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
provide: PlatformHandler,
|
|
97
|
-
useClass: PlatformExpressHandler
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
provide: PlatformResponse,
|
|
101
|
-
useClass: PlatformExpressResponse
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
provide: PlatformRequest,
|
|
105
|
-
useClass: PlatformExpressRequest
|
|
106
|
-
}
|
|
107
|
-
];
|
|
108
118
|
//# sourceMappingURL=PlatformExpress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformExpress.js","sourceRoot":"","sources":["../../../src/components/PlatformExpress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlatformExpress.js","sourceRoot":"","sources":["../../../src/components/PlatformExpress.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EAEb,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,GAAG,EAAO,MAAM,YAAY,CAAC;AACrC,OAAO,EAAC,iBAAiB,EAAC,MAAM,kCAAkC,CAAC;AACnE,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,MAAM,OAAO,eAAe;IAwB1B,YAAoB,QAA8D;QAA9D,aAAQ,GAAR,QAAQ,CAAsD;QAvBzE,cAAS,GAAG;YACnB;gBACE,OAAO,EAAE,mBAAmB;gBAC5B,QAAQ,EAAE,0BAA0B;aACrC;YACD;gBACE,OAAO,EAAE,cAAc;gBACvB,QAAQ,EAAE,qBAAqB;aAChC;YACD;gBACE,OAAO,EAAE,eAAe;gBACxB,QAAQ,EAAE,sBAAsB;aACjC;YACD;gBACE,OAAO,EAAE,gBAAgB;gBACzB,QAAQ,EAAE,uBAAuB;aAClC;YACD;gBACE,OAAO,EAAE,eAAe;gBACxB,QAAQ,EAAE,sBAAsB;aACjC;SACF,CAAC;IAEmF,CAAC;IAEtF;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,MAAiB,EAAE,WAAwC,EAAE;QACzE,OAAO,eAAe,CAAC,MAAM,CAAsC,MAAM,EAAE;YACzE,GAAG,QAAQ;YACX,OAAO,EAAE,eAAe;SACzB,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM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AC,EAAC,SAAS,EAAE,MAAM,EAAC,EAAE,EAAE;oBACzD,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC3C,CAAC,CAAC,CAAC;gBAEH,aAAa,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;gBACjF,aAAa,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;aAChE;SACF;QAAC,OAAO,KAAK,EAAE;YACd,uBAAuB;YACvB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE,sBAAsB;gBAC7B,OAAO,EAAE,oEAAoE;gBAC7E,KAAK;aACN,CAAC,CAAC;SACJ;IACH,CAAC;CACF","sourcesContent":["import Express from \"express\";\nimport type {PlatformViews} from \"@tsed/platform-views\";\nimport {\n createContext,\n PlatformAdapter,\n PlatformApplication,\n PlatformBuilder,\n PlatformExceptions,\n PlatformHandler,\n PlatformRequest,\n PlatformResponse,\n PlatformRouter\n} from \"@tsed/common\";\nimport {Env, Type} from \"@tsed/core\";\nimport {rawBodyMiddleware} from \"../middlewares/rawBodyMiddleware\";\nimport {\n PlatformExpressApplication,\n PlatformExpressHandler,\n PlatformExpressRequest,\n PlatformExpressResponse,\n PlatformExpressRouter\n} from \"../services\";\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpress implements PlatformAdapter<Express.Application, Express.Router> {\n readonly providers = [\n {\n provide: PlatformApplication,\n useClass: PlatformExpressApplication\n },\n {\n provide: PlatformRouter,\n useClass: PlatformExpressRouter\n },\n {\n provide: PlatformHandler,\n useClass: PlatformExpressHandler\n },\n {\n provide: PlatformResponse,\n useClass: PlatformExpressResponse\n },\n {\n provide: PlatformRequest,\n useClass: PlatformExpressRequest\n }\n ];\n\n constructor(private platform: PlatformBuilder<Express.Application, Express.Router>) {}\n\n /**\n * Create new serverless application. In this mode, the component scan are disabled.\n * @param module\n * @param settings\n */\n static create(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return PlatformBuilder.create<Express.Application, Express.Router>(module, {\n ...settings,\n adapter: PlatformExpress\n });\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return PlatformBuilder.bootstrap<Express.Application, Express.Router>(module, {\n ...settings,\n adapter: PlatformExpress\n });\n }\n\n useRouter(): this {\n const {logger, app} = this.platform;\n\n logger.debug(\"Mount app router\");\n app.getApp().use(rawBodyMiddleware);\n app.getApp().use(app.getRouter());\n\n return this;\n }\n\n async beforeLoadRoutes() {\n const {injector, app} = this.platform;\n // disable x-powered-by header\n injector.settings.get(\"env\") === Env.PROD && app.getApp().disable(\"x-powered-by\");\n\n await this.configureViewsEngine();\n }\n\n async afterLoadRoutes() {\n const {injector, app} = this.platform;\n // NOT FOUND\n app.use((req: any, res: any, next: any) => {\n !res.headersSent && injector.get<PlatformExceptions>(PlatformExceptions)?.resourceNotFound(req.$ctx);\n });\n\n // EXCEPTION FILTERS\n app.use((err: any, req: any, res: any, next: any) => {\n !res.headersSent && injector.get<PlatformExceptions>(PlatformExceptions)?.catch(err, req.$ctx);\n });\n }\n\n useContext(): this {\n const {logger, app, injector} = this.platform;\n\n logger.debug(\"Mount app context\");\n\n const invoke = createContext(injector);\n\n app.getApp().use(async (request: any, response: any, next: any) => {\n await invoke({request, response});\n\n return next();\n });\n\n return this;\n }\n\n private async configureViewsEngine() {\n const {settings, injector, app} = this.platform;\n try {\n const {exists, disabled} = settings.get(\"views\") || {};\n\n if (exists && !disabled) {\n const {PlatformViews} = await import(\"@tsed/platform-views\");\n const platformViews = injector.get<PlatformViews>(PlatformViews)!;\n const express = app.getApp();\n\n platformViews.getEngines().forEach(({extension, engine}) => {\n express.engine(extension, engine.render);\n });\n\n platformViews.viewEngine && express.set(\"view engine\", platformViews.viewEngine);\n platformViews.root && express.set(\"views\", platformViews.root);\n }\n } catch (error) {\n // istanbul ignore next\n injector.logger.warn({\n event: \"PLATFORM_VIEWS_ERROR\",\n message: \"Unable to configure the PlatformViews service on your environment.\",\n error\n });\n }\n }\n}\n"]}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlatformBuilder, PlatformTest } from "@tsed/common";
|
|
2
2
|
import { PlatformExpress } from "./components/PlatformExpress";
|
|
3
|
-
PlatformTest.
|
|
4
|
-
PlatformBuilder.
|
|
3
|
+
PlatformTest.adapter = PlatformExpress;
|
|
4
|
+
PlatformBuilder.adapter = PlatformExpress;
|
|
5
5
|
// interfaces
|
|
6
6
|
export * from "./interfaces";
|
|
7
7
|
// decorators
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAE7D,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAE7D,YAAY,CAAC,OAAO,GAAG,eAAsB,CAAC;AAC9C,eAAe,CAAC,OAAO,GAAG,eAAsB,CAAC;AAEjD,aAAa;AACb,cAAc,cAAc,CAAC;AAE7B,aAAa;AACb,cAAc,cAAc,CAAC;AAE7B,WAAW;AACX,cAAc,YAAY,CAAC;AAE3B,aAAa;AACb,cAAc,8BAA8B,CAAC","sourcesContent":["import {PlatformBuilder, PlatformTest} from \"@tsed/common\";\n\nimport {PlatformExpress} from \"./components/PlatformExpress\";\n\nPlatformTest.adapter = PlatformExpress as any;\nPlatformBuilder.adapter = PlatformExpress as any;\n\n// interfaces\nexport * from \"./interfaces\";\n\n// decorators\nexport * from \"./decorators\";\n\n// services\nexport * from \"./services\";\n\n// components\nexport * from \"./components/PlatformExpress\";\n"]}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { PlatformBuilder, PlatformHandler, PlatformRequest, PlatformResponse, PlatformRouter } from "@tsed/common";
|
|
2
|
-
import { Type } from "@tsed/core";
|
|
3
1
|
import Express from "express";
|
|
2
|
+
import { PlatformAdapter, PlatformBuilder, PlatformHandler, PlatformRequest, PlatformResponse, PlatformRouter } from "@tsed/common";
|
|
3
|
+
import { Type } from "@tsed/core";
|
|
4
4
|
import { PlatformExpressHandler, PlatformExpressRequest, PlatformExpressResponse, PlatformExpressRouter } from "../services";
|
|
5
5
|
/**
|
|
6
6
|
* @platform
|
|
7
7
|
* @express
|
|
8
8
|
*/
|
|
9
|
-
export declare class PlatformExpress
|
|
10
|
-
|
|
9
|
+
export declare class PlatformExpress implements PlatformAdapter<Express.Application, Express.Router> {
|
|
10
|
+
private platform;
|
|
11
|
+
readonly providers: ({
|
|
11
12
|
provide: typeof PlatformRouter;
|
|
12
13
|
useClass: typeof PlatformExpressRouter;
|
|
13
14
|
} | {
|
|
@@ -20,20 +21,22 @@ export declare class PlatformExpress extends PlatformBuilder<Express.Application
|
|
|
20
21
|
provide: typeof PlatformRequest;
|
|
21
22
|
useClass: typeof PlatformExpressRequest;
|
|
22
23
|
})[];
|
|
24
|
+
constructor(platform: PlatformBuilder<Express.Application, Express.Router>);
|
|
23
25
|
/**
|
|
24
26
|
* Create new serverless application. In this mode, the component scan are disabled.
|
|
25
27
|
* @param module
|
|
26
28
|
* @param settings
|
|
27
29
|
*/
|
|
28
|
-
static create(module: Type<any>, settings?: Partial<TsED.Configuration>):
|
|
30
|
+
static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Express.Application, Express.Router>;
|
|
29
31
|
/**
|
|
30
32
|
* Bootstrap a server application
|
|
31
33
|
* @param module
|
|
32
34
|
* @param settings
|
|
33
35
|
*/
|
|
34
|
-
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Express.Application, Express.Router>>;
|
|
37
|
+
useRouter(): this;
|
|
38
|
+
beforeLoadRoutes(): Promise<void>;
|
|
39
|
+
afterLoadRoutes(): Promise<void>;
|
|
40
|
+
useContext(): this;
|
|
38
41
|
private configureViewsEngine;
|
|
39
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-express",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.90.0",
|
|
4
4
|
"description": "A TypeScript Framework on top of Express",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"tslib": "2.2.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@tsed/common": "6.
|
|
58
|
-
"@tsed/core": "6.
|
|
59
|
-
"@tsed/di": "6.
|
|
60
|
-
"@tsed/platform-test-utils": "6.
|
|
57
|
+
"@tsed/common": "6.90.0",
|
|
58
|
+
"@tsed/core": "6.90.0",
|
|
59
|
+
"@tsed/di": "6.90.0",
|
|
60
|
+
"@tsed/platform-test-utils": "6.90.0",
|
|
61
61
|
"@types/body-parser": "1.19.0",
|
|
62
62
|
"@types/compression": "1.7.0",
|
|
63
63
|
"@types/cookie-parser": "1.4.2",
|
|
@@ -73,13 +73,13 @@
|
|
|
73
73
|
"method-override": "3.0.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@tsed/common": "^6.
|
|
77
|
-
"@tsed/core": "^6.
|
|
78
|
-
"@tsed/di": "^6.
|
|
79
|
-
"@tsed/json-mapper": "^6.
|
|
76
|
+
"@tsed/common": "^6.90.0",
|
|
77
|
+
"@tsed/core": "^6.90.0",
|
|
78
|
+
"@tsed/di": "^6.90.0",
|
|
79
|
+
"@tsed/json-mapper": "^6.90.0",
|
|
80
80
|
"@tsed/logger": ">=6.0.0",
|
|
81
|
-
"@tsed/openspec": "^6.
|
|
82
|
-
"@tsed/schema": "^6.
|
|
81
|
+
"@tsed/openspec": "^6.90.0",
|
|
82
|
+
"@tsed/schema": "^6.90.0",
|
|
83
83
|
"@types/multer": "^1.4.5",
|
|
84
84
|
"body-parser": "1.19.0"
|
|
85
85
|
}
|