@tsed/platform-express 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.
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
var PlatformExpress_1;
|
|
2
|
-
import { __decorate, __metadata } from "tslib";
|
|
3
1
|
import { catchAsyncError, Env, isFunction } from "@tsed/core";
|
|
4
|
-
import {
|
|
2
|
+
import { constant, inject, logger, runInContext } from "@tsed/di";
|
|
5
3
|
import { PlatformExceptions } from "@tsed/platform-exceptions";
|
|
6
|
-
import { createContext, PlatformAdapter, PlatformBuilder, PlatformHandler,
|
|
4
|
+
import { adapter, application, createContext, Platform, PlatformAdapter, PlatformApplication, PlatformBuilder, PlatformHandler, PlatformRequest, PlatformResponse } from "@tsed/platform-http";
|
|
7
5
|
import { PlatformHandlerType } from "@tsed/platform-router";
|
|
8
6
|
import Express from "express";
|
|
9
7
|
import { promisify } from "util";
|
|
@@ -18,17 +16,20 @@ function callNext(next, metadata, $ctx) {
|
|
|
18
16
|
* @platform
|
|
19
17
|
* @express
|
|
20
18
|
*/
|
|
21
|
-
|
|
22
|
-
static { PlatformExpress_1 = this; }
|
|
23
|
-
static { this.NAME = "express"; }
|
|
19
|
+
export class PlatformExpress extends PlatformAdapter {
|
|
24
20
|
#multer;
|
|
25
|
-
constructor(
|
|
26
|
-
super(
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
this.NAME = "express";
|
|
27
24
|
this.providers = [
|
|
28
25
|
{
|
|
29
|
-
|
|
26
|
+
token: PlatformHandler,
|
|
30
27
|
useClass: PlatformExpressHandler
|
|
31
|
-
}
|
|
28
|
+
},
|
|
29
|
+
{ token: PlatformResponse },
|
|
30
|
+
{ token: PlatformRequest },
|
|
31
|
+
{ token: PlatformApplication },
|
|
32
|
+
{ token: Platform }
|
|
32
33
|
];
|
|
33
34
|
import("multer").then(({ default: multer }) => (this.#multer = multer));
|
|
34
35
|
}
|
|
@@ -40,7 +41,7 @@ let PlatformExpress = class PlatformExpress extends PlatformAdapter {
|
|
|
40
41
|
static create(module, settings = {}) {
|
|
41
42
|
return PlatformBuilder.create(module, {
|
|
42
43
|
...settings,
|
|
43
|
-
adapter:
|
|
44
|
+
adapter: PlatformExpress
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
@@ -51,19 +52,18 @@ let PlatformExpress = class PlatformExpress extends PlatformAdapter {
|
|
|
51
52
|
static bootstrap(module, settings = {}) {
|
|
52
53
|
return PlatformBuilder.bootstrap(module, {
|
|
53
54
|
...settings,
|
|
54
|
-
adapter:
|
|
55
|
+
adapter: PlatformExpress
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
async beforeLoadRoutes() {
|
|
58
|
-
const injector = this.injector;
|
|
59
59
|
const { app } = this;
|
|
60
60
|
// disable x-powered-by header
|
|
61
|
-
|
|
61
|
+
constant("env") === Env.PROD && app.getApp().disable("x-powered-by");
|
|
62
62
|
await this.configureViewsEngine();
|
|
63
63
|
}
|
|
64
64
|
afterLoadRoutes() {
|
|
65
65
|
const { app } = this;
|
|
66
|
-
const platformExceptions =
|
|
66
|
+
const platformExceptions = inject(PlatformExceptions);
|
|
67
67
|
// NOT FOUND
|
|
68
68
|
app.use((req, res, next) => {
|
|
69
69
|
const { $ctx } = req;
|
|
@@ -109,8 +109,8 @@ let PlatformExpress = class PlatformExpress extends PlatformAdapter {
|
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
useContext() {
|
|
112
|
-
const
|
|
113
|
-
const
|
|
112
|
+
const invoke = createContext();
|
|
113
|
+
const app = application();
|
|
114
114
|
app.use(async (request, response, next) => {
|
|
115
115
|
const $ctx = invoke({ request, response });
|
|
116
116
|
await $ctx.start();
|
|
@@ -120,7 +120,7 @@ let PlatformExpress = class PlatformExpress extends PlatformAdapter {
|
|
|
120
120
|
return this;
|
|
121
121
|
}
|
|
122
122
|
createApp() {
|
|
123
|
-
const app =
|
|
123
|
+
const app = constant("express.app") || Express();
|
|
124
124
|
return {
|
|
125
125
|
app,
|
|
126
126
|
callback: () => app
|
|
@@ -150,7 +150,7 @@ let PlatformExpress = class PlatformExpress extends PlatformAdapter {
|
|
|
150
150
|
return staticsMiddleware(root, props);
|
|
151
151
|
}
|
|
152
152
|
bodyParser(type, additionalOptions = {}) {
|
|
153
|
-
const opts =
|
|
153
|
+
const opts = constant(`express.bodyParser.${type}`);
|
|
154
154
|
let parser = Express[type];
|
|
155
155
|
let options = {};
|
|
156
156
|
if (isFunction(opts)) {
|
|
@@ -161,7 +161,7 @@ let PlatformExpress = class PlatformExpress extends PlatformAdapter {
|
|
|
161
161
|
options.extended = true;
|
|
162
162
|
}
|
|
163
163
|
options.verify = (req, _res, buffer) => {
|
|
164
|
-
const rawBody =
|
|
164
|
+
const rawBody = constant(`rawBody`);
|
|
165
165
|
if (rawBody) {
|
|
166
166
|
req.rawBody = buffer;
|
|
167
167
|
}
|
|
@@ -170,13 +170,12 @@ let PlatformExpress = class PlatformExpress extends PlatformAdapter {
|
|
|
170
170
|
return parser({ ...options, ...additionalOptions });
|
|
171
171
|
}
|
|
172
172
|
async configureViewsEngine() {
|
|
173
|
-
const injector = this.injector;
|
|
174
173
|
const { app } = this;
|
|
175
174
|
try {
|
|
176
|
-
const { exists, disabled } =
|
|
175
|
+
const { exists, disabled } = constant("views") || {};
|
|
177
176
|
if (exists && !disabled) {
|
|
178
177
|
const { PlatformViews } = await import("@tsed/platform-views");
|
|
179
|
-
const platformViews =
|
|
178
|
+
const platformViews = inject(PlatformViews);
|
|
180
179
|
const express = app.getApp();
|
|
181
180
|
platformViews.getEngines().forEach(({ extension, engine }) => {
|
|
182
181
|
express.engine(extension, engine.render);
|
|
@@ -187,17 +186,13 @@ let PlatformExpress = class PlatformExpress extends PlatformAdapter {
|
|
|
187
186
|
}
|
|
188
187
|
catch (error) {
|
|
189
188
|
// istanbul ignore next
|
|
190
|
-
|
|
189
|
+
logger().warn({
|
|
191
190
|
event: "PLATFORM_VIEWS_ERROR",
|
|
192
191
|
message: "Unable to configure the PlatformViews service on your environment.",
|
|
193
192
|
error
|
|
194
193
|
});
|
|
195
194
|
}
|
|
196
195
|
}
|
|
197
|
-
}
|
|
198
|
-
PlatformExpress
|
|
199
|
-
PlatformProvider(),
|
|
200
|
-
__metadata("design:paramtypes", [InjectorService])
|
|
201
|
-
], PlatformExpress);
|
|
202
|
-
export { PlatformExpress };
|
|
196
|
+
}
|
|
197
|
+
adapter(PlatformExpress);
|
|
203
198
|
//# 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":"AAAA,OAAO,EAAC,eAAe,EAAE,GAAG,EAAE,UAAU,EAAO,MAAM,YAAY,CAAC;AAClE,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AAChE,OAAO,EAAC,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,OAAO,EACP,WAAW,EACX,aAAa,EACb,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,eAAe,EAEf,eAAe,EAGf,eAAe,EACf,gBAAgB,EAEjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAA0B,mBAAmB,EAAgB,MAAM,uBAAuB,CAAC;AAElG,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAG/B,OAAO,EAAC,iBAAiB,EAAC,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAC,sBAAsB,EAAC,MAAM,uCAAuC,CAAC;AAS7E,SAAS,QAAQ,CAAC,IAAS,EAAE,QAAiC,EAAE,IAAqB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
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
|
-
import {
|
|
3
|
-
import { PlatformAdapter, PlatformBuilder, PlatformContext, PlatformHandler, PlatformMulter, PlatformMulterSettings, PlatformStaticsOptions } from "@tsed/platform-http";
|
|
2
|
+
import { Platform, PlatformAdapter, PlatformApplication, PlatformBuilder, PlatformContext, PlatformHandler, PlatformMulter, PlatformMulterSettings, PlatformRequest, PlatformResponse, PlatformStaticsOptions } from "@tsed/platform-http";
|
|
4
3
|
import { PlatformHandlerMetadata, PlatformLayer } from "@tsed/platform-router";
|
|
5
4
|
import Express from "express";
|
|
6
5
|
import { PlatformExpressStaticsOptions } from "../interfaces/PlatformExpressStaticsOptions.js";
|
|
@@ -29,32 +28,44 @@ declare global {
|
|
|
29
28
|
*/
|
|
30
29
|
export declare class PlatformExpress extends PlatformAdapter<Express.Application> {
|
|
31
30
|
#private;
|
|
32
|
-
|
|
33
|
-
readonly providers: {
|
|
34
|
-
|
|
31
|
+
readonly NAME = "express";
|
|
32
|
+
readonly providers: ({
|
|
33
|
+
token: typeof PlatformHandler;
|
|
35
34
|
useClass: typeof PlatformExpressHandler;
|
|
36
|
-
}
|
|
37
|
-
|
|
35
|
+
} | {
|
|
36
|
+
token: typeof PlatformResponse;
|
|
37
|
+
useClass?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
token: typeof PlatformRequest;
|
|
40
|
+
useClass?: undefined;
|
|
41
|
+
} | {
|
|
42
|
+
token: typeof PlatformApplication;
|
|
43
|
+
useClass?: undefined;
|
|
44
|
+
} | {
|
|
45
|
+
token: typeof Platform;
|
|
46
|
+
useClass?: undefined;
|
|
47
|
+
})[];
|
|
48
|
+
constructor();
|
|
38
49
|
/**
|
|
39
50
|
* Create new serverless application. In this mode, the component scan are disabled.
|
|
40
51
|
* @param module
|
|
41
52
|
* @param settings
|
|
42
53
|
*/
|
|
43
|
-
static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<
|
|
54
|
+
static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<TsED.Application>;
|
|
44
55
|
/**
|
|
45
56
|
* Bootstrap a server application
|
|
46
57
|
* @param module
|
|
47
58
|
* @param settings
|
|
48
59
|
*/
|
|
49
|
-
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<
|
|
60
|
+
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<TsED.Application>>;
|
|
50
61
|
beforeLoadRoutes(): Promise<void>;
|
|
51
62
|
afterLoadRoutes(): Promise<void>;
|
|
52
63
|
mapLayers(layers: PlatformLayer[]): void;
|
|
53
64
|
mapHandler(handler: Function, metadata: PlatformHandlerMetadata): (error: unknown, req: any, res: any, next: any) => Promise<Promise<any>>;
|
|
54
65
|
useContext(): this;
|
|
55
66
|
createApp(): {
|
|
56
|
-
app:
|
|
57
|
-
callback: () =>
|
|
67
|
+
app: Express.Express;
|
|
68
|
+
callback: () => Express.Express;
|
|
58
69
|
};
|
|
59
70
|
multipart(options: PlatformMulterSettings): PlatformMulter;
|
|
60
71
|
statics(endpoint: string, options: PlatformStaticsOptions): (request: any, response: any, next: any) => void;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/platform-express",
|
|
3
3
|
"description": "A TypeScript Framework on top of Express",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.0.0
|
|
5
|
+
"version": "8.0.0",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -58,13 +58,13 @@
|
|
|
58
58
|
"tslib": "2.7.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@tsed/barrels": "8.0.0
|
|
62
|
-
"@tsed/core": "8.0.0
|
|
63
|
-
"@tsed/di": "8.0.0
|
|
64
|
-
"@tsed/platform-http": "8.0.0
|
|
65
|
-
"@tsed/platform-test-sdk": "8.0.0
|
|
66
|
-
"@tsed/platform-views": "8.0.0
|
|
67
|
-
"@tsed/typescript": "8.0.0
|
|
61
|
+
"@tsed/barrels": "8.0.0",
|
|
62
|
+
"@tsed/core": "8.0.0",
|
|
63
|
+
"@tsed/di": "8.0.0",
|
|
64
|
+
"@tsed/platform-http": "8.0.0",
|
|
65
|
+
"@tsed/platform-test-sdk": "8.0.0",
|
|
66
|
+
"@tsed/platform-views": "8.0.0",
|
|
67
|
+
"@tsed/typescript": "8.0.0",
|
|
68
68
|
"@types/body-parser": "1.19.5",
|
|
69
69
|
"@types/compression": "1.7.5",
|
|
70
70
|
"@types/cookie-parser": "1.4.7",
|
|
@@ -84,14 +84,14 @@
|
|
|
84
84
|
"vitest": "2.1.2"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"@tsed/core": "8.0.0
|
|
88
|
-
"@tsed/di": "8.0.0
|
|
89
|
-
"@tsed/json-mapper": "8.0.0
|
|
87
|
+
"@tsed/core": "8.0.0",
|
|
88
|
+
"@tsed/di": "8.0.0",
|
|
89
|
+
"@tsed/json-mapper": "8.0.0",
|
|
90
90
|
"@tsed/logger": ">=6.7.5",
|
|
91
|
-
"@tsed/openspec": "8.0.0
|
|
92
|
-
"@tsed/platform-http": "8.0.0
|
|
93
|
-
"@tsed/platform-views": "8.0.0
|
|
94
|
-
"@tsed/schema": "8.0.0
|
|
91
|
+
"@tsed/openspec": "8.0.0",
|
|
92
|
+
"@tsed/platform-http": "8.0.0",
|
|
93
|
+
"@tsed/platform-views": "8.0.0",
|
|
94
|
+
"@tsed/schema": "8.0.0",
|
|
95
95
|
"@types/multer": "^1.4.5",
|
|
96
96
|
"body-parser": "^1.19.0",
|
|
97
97
|
"cross-env": "7.0.3",
|
|
@@ -122,8 +122,5 @@
|
|
|
122
122
|
"multer": {
|
|
123
123
|
"optional": false
|
|
124
124
|
}
|
|
125
|
-
},
|
|
126
|
-
"publishConfig": {
|
|
127
|
-
"tag": "rc"
|
|
128
125
|
}
|
|
129
126
|
}
|
package/vitest.config.mts
CHANGED