@tsed/platform-express 8.11.0 → 8.11.2-rc.1
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/esm/components/PlatformExpress.js +0 -1
- package/lib/esm/index.js +0 -1
- package/lib/esm/interfaces/PlatformExpressSettings.js +0 -1
- package/lib/esm/interfaces/PlatformExpressStaticsOptions.js +0 -1
- package/lib/esm/interfaces/interfaces.js +0 -1
- package/lib/esm/middlewares/staticsMiddleware.js +0 -1
- package/lib/esm/services/PlatformExpressHandler.js +0 -1
- package/lib/esm/services/PlatformExpressResponse.js +0 -1
- package/package.json +16 -9
- package/lib/esm/components/PlatformExpress.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/interfaces/PlatformExpressSettings.js.map +0 -1
- package/lib/esm/interfaces/PlatformExpressStaticsOptions.js.map +0 -1
- package/lib/esm/interfaces/interfaces.js.map +0 -1
- package/lib/esm/middlewares/staticsMiddleware.js.map +0 -1
- package/lib/esm/services/PlatformExpressHandler.js.map +0 -1
- package/lib/esm/services/PlatformExpressResponse.js.map +0 -1
- package/src/components/PlatformExpress.spec.ts +0 -58
- package/src/components/PlatformExpress.ts +0 -252
- package/src/index.ts +0 -10
- package/src/interfaces/PlatformExpressSettings.ts +0 -26
- package/src/interfaces/PlatformExpressStaticsOptions.ts +0 -74
- package/src/interfaces/interfaces.ts +0 -19
- package/src/middlewares/staticsMiddleware.spec.ts +0 -35
- package/src/middlewares/staticsMiddleware.ts +0 -16
- package/src/services/PlatformExpressHandler.spec.ts +0 -46
- package/src/services/PlatformExpressHandler.ts +0 -15
- package/src/services/PlatformExpressResponse.ts +0 -14
- package/vitest.config.mts +0 -21
package/lib/esm/index.js
CHANGED
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.11.
|
|
5
|
+
"version": "8.11.2-rc.1",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -54,18 +54,17 @@
|
|
|
54
54
|
"homepage": "https://github.com/tsedio/tsed/tree/production/packages/platform/platform-express",
|
|
55
55
|
"repository": "https://github.com/tsedio/tsed",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"express": "^4.21.0",
|
|
58
57
|
"multer": "^2.0.0",
|
|
59
58
|
"tslib": "2.7.0"
|
|
60
59
|
},
|
|
61
60
|
"devDependencies": {
|
|
62
|
-
"@tsed/barrels": "8.11.
|
|
63
|
-
"@tsed/core": "8.11.
|
|
64
|
-
"@tsed/di": "8.11.
|
|
65
|
-
"@tsed/platform-http": "8.11.
|
|
66
|
-
"@tsed/platform-test-sdk": "8.11.
|
|
67
|
-
"@tsed/platform-views": "8.11.
|
|
68
|
-
"@tsed/typescript": "8.11.
|
|
61
|
+
"@tsed/barrels": "8.11.2-rc.1",
|
|
62
|
+
"@tsed/core": "8.11.2-rc.1",
|
|
63
|
+
"@tsed/di": "8.11.2-rc.1",
|
|
64
|
+
"@tsed/platform-http": "8.11.2-rc.1",
|
|
65
|
+
"@tsed/platform-test-sdk": "8.11.2-rc.1",
|
|
66
|
+
"@tsed/platform-views": "8.11.2-rc.1",
|
|
67
|
+
"@tsed/typescript": "8.11.2-rc.1",
|
|
69
68
|
"@types/body-parser": "1.19.5",
|
|
70
69
|
"@types/compression": "1.7.5",
|
|
71
70
|
"@types/cookie-parser": "1.4.7",
|
|
@@ -79,6 +78,7 @@
|
|
|
79
78
|
"cors": "2.8.5",
|
|
80
79
|
"cross-env": "7.0.3",
|
|
81
80
|
"eslint": "9.12.0",
|
|
81
|
+
"express": "^4.21.0",
|
|
82
82
|
"express-session": "1.18.1",
|
|
83
83
|
"method-override": "3.0.0",
|
|
84
84
|
"typescript": "5.4.5",
|
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
"@types/multer": "^1.4.5",
|
|
97
97
|
"body-parser": "^1.19.0",
|
|
98
98
|
"cross-env": "7.0.3",
|
|
99
|
+
"express": ">=4.17.1",
|
|
99
100
|
"multer": "^2.0.0"
|
|
100
101
|
},
|
|
101
102
|
"peerDependenciesMeta": {
|
|
@@ -120,8 +121,14 @@
|
|
|
120
121
|
"@tsed/schema": {
|
|
121
122
|
"optional": false
|
|
122
123
|
},
|
|
124
|
+
"express": {
|
|
125
|
+
"optional": false
|
|
126
|
+
},
|
|
123
127
|
"multer": {
|
|
124
128
|
"optional": false
|
|
125
129
|
}
|
|
130
|
+
},
|
|
131
|
+
"publishConfig": {
|
|
132
|
+
"tag": "rc"
|
|
126
133
|
}
|
|
127
134
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformExpress.js","sourceRoot":"","sources":["../../../src/components/PlatformExpress.ts"],"names":[],"mappings":"AAAA,OAAO,+BAA+B,CAAC;AAIvC,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,eAAe,EACf,eAAe,EAEf,eAAe,EACf,gBAAgB,EAEjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAA0B,mBAAmB,EAAgB,MAAM,uBAAuB,CAAC;AAElG,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,OAAO,EAAC,iBAAiB,EAAC,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAC,sBAAsB,EAAC,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAC,uBAAuB,EAAC,MAAM,wCAAwC,CAAC;AAS/E,SAAS,QAAQ,CAAC,IAAS,EAAE,QAA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AClC;CACF,CAAC,CAAC"}
|
package/lib/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yCAAyC,CAAC;AACxD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,oCAAoC,CAAC;AACnD,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformExpressSettings.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformExpressSettings.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformExpressStaticsOptions.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformExpressStaticsOptions.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"staticsMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/staticsMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,UAAe,EAAE;IACpE,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAEtD,OAAO,CAAC,OAAY,EAAE,QAAa,EAAE,IAAS,EAAE,EAAE;QAChD,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;YAC1B,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,IAAI,EAAE,CAAC;QACT,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformExpressHandler.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAmB,UAAU,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAClE,OAAO,EAAkB,eAAe,EAAC,MAAM,qBAAqB,CAAC;AAErE,MAAM,OAAO,sBAAuB,SAAQ,eAAe;IACzD,UAAU,CAAC,QAA0B,EAAE,IAAqB;QAC1D,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAEjC,2BAA2B;QAC3B,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAClD,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformExpressResponse.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,uBAAwB,SAAQ,gBAA+B;IAChE,GAAG,CAAC,IAAsB;QAClC,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACnB,uEAAuE;YACvE,aAAa;YACb,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {PlatformExpress} from "./PlatformExpress.js";
|
|
2
|
-
|
|
3
|
-
class Server {}
|
|
4
|
-
|
|
5
|
-
describe("PlatformExpress", () => {
|
|
6
|
-
describe("create()", () => {
|
|
7
|
-
it("should create platform", () => {
|
|
8
|
-
const platform = PlatformExpress.create(Server, {});
|
|
9
|
-
|
|
10
|
-
expect(platform.adapter).toBeInstanceOf(PlatformExpress);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
describe("bootstrap()", () => {
|
|
14
|
-
it("should create platform", async () => {
|
|
15
|
-
const platform = await PlatformExpress.bootstrap(Server, {});
|
|
16
|
-
|
|
17
|
-
expect(platform.adapter).toBeInstanceOf(PlatformExpress);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
describe("bodyParser()", () => {
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
vi.resetAllMocks();
|
|
24
|
-
});
|
|
25
|
-
it("should return the body parser (json)", () => {
|
|
26
|
-
const stub = vi.fn().mockReturnValue("body");
|
|
27
|
-
|
|
28
|
-
const platform = PlatformExpress.create(Server, {
|
|
29
|
-
express: {
|
|
30
|
-
bodyParser: {
|
|
31
|
-
json: stub
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const result = platform.adapter.bodyParser("json", {strict: true});
|
|
37
|
-
|
|
38
|
-
expect(result).toEqual("body");
|
|
39
|
-
expect(stub).toHaveBeenCalledWith({strict: true, verify: expect.any(Function)});
|
|
40
|
-
});
|
|
41
|
-
it("should return the body parser (urlencoded)", () => {
|
|
42
|
-
const stub = vi.fn().mockReturnValue("body");
|
|
43
|
-
|
|
44
|
-
const platform = PlatformExpress.create(Server, {
|
|
45
|
-
express: {
|
|
46
|
-
bodyParser: {
|
|
47
|
-
urlencoded: stub
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const result = platform.adapter.bodyParser("urlencoded", {strict: true});
|
|
53
|
-
|
|
54
|
-
expect(result).toEqual("body");
|
|
55
|
-
expect(stub).toHaveBeenCalledWith({extended: true, strict: true, verify: expect.any(Function)});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import "@tsed/platform-multer/express";
|
|
2
|
-
|
|
3
|
-
import {IncomingMessage, ServerResponse} from "node:http";
|
|
4
|
-
|
|
5
|
-
import {catchAsyncError, Env, isFunction, Type} from "@tsed/core";
|
|
6
|
-
import {constant, inject, logger, runInContext} from "@tsed/di";
|
|
7
|
-
import {PlatformExceptions} from "@tsed/platform-exceptions";
|
|
8
|
-
import {
|
|
9
|
-
adapter,
|
|
10
|
-
application,
|
|
11
|
-
createContext,
|
|
12
|
-
PlatformAdapter,
|
|
13
|
-
PlatformBuilder,
|
|
14
|
-
PlatformContext,
|
|
15
|
-
PlatformHandler,
|
|
16
|
-
PlatformResponse,
|
|
17
|
-
PlatformStaticsOptions
|
|
18
|
-
} from "@tsed/platform-http";
|
|
19
|
-
import {PlatformHandlerMetadata, PlatformHandlerType, PlatformLayer} from "@tsed/platform-router";
|
|
20
|
-
import {OptionsJson, OptionsText, OptionsUrlencoded} from "body-parser";
|
|
21
|
-
import Express from "express";
|
|
22
|
-
|
|
23
|
-
import {PlatformExpressStaticsOptions} from "../interfaces/PlatformExpressStaticsOptions.js";
|
|
24
|
-
import {staticsMiddleware} from "../middlewares/staticsMiddleware.js";
|
|
25
|
-
import {PlatformExpressHandler} from "../services/PlatformExpressHandler.js";
|
|
26
|
-
import {PlatformExpressResponse} from "../services/PlatformExpressResponse.js";
|
|
27
|
-
|
|
28
|
-
declare module "express" {
|
|
29
|
-
export interface Request {
|
|
30
|
-
id: string;
|
|
31
|
-
$ctx: PlatformContext;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function callNext(next: any, metadata: PlatformHandlerMetadata, $ctx: PlatformContext) {
|
|
36
|
-
if (metadata.type !== PlatformHandlerType.RESPONSE_FN) {
|
|
37
|
-
return next && $ctx.error && !$ctx.isDone() ? next($ctx.error) : next();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
declare global {
|
|
42
|
-
namespace TsED {
|
|
43
|
-
// export interface Router extends Express.Router {}
|
|
44
|
-
|
|
45
|
-
export interface Application extends Express.Application {}
|
|
46
|
-
|
|
47
|
-
export interface StaticsOptions extends PlatformExpressStaticsOptions {}
|
|
48
|
-
|
|
49
|
-
export interface Request extends Express.Request {
|
|
50
|
-
id: string;
|
|
51
|
-
$ctx: PlatformContext;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @platform
|
|
58
|
-
* @express
|
|
59
|
-
*/
|
|
60
|
-
export class PlatformExpress extends PlatformAdapter<Express.Application> {
|
|
61
|
-
readonly NAME = "express";
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Create new serverless application. In this mode, the component scan are disabled.
|
|
65
|
-
* @param module
|
|
66
|
-
* @param settings
|
|
67
|
-
*/
|
|
68
|
-
static create(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {
|
|
69
|
-
return PlatformBuilder.create<Express.Application>(module, {
|
|
70
|
-
...settings,
|
|
71
|
-
adapter: PlatformExpress as any
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Bootstrap a server application
|
|
77
|
-
* @param module
|
|
78
|
-
* @param settings
|
|
79
|
-
*/
|
|
80
|
-
static bootstrap(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {
|
|
81
|
-
return PlatformBuilder.bootstrap<Express.Application>(module, {
|
|
82
|
-
...settings,
|
|
83
|
-
adapter: PlatformExpress as any
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async beforeLoadRoutes() {
|
|
88
|
-
const {app} = this;
|
|
89
|
-
|
|
90
|
-
// disable x-powered-by header
|
|
91
|
-
constant<Env>("env") === Env.PROD && app.getApp().disable("x-powered-by");
|
|
92
|
-
|
|
93
|
-
await this.configureViewsEngine();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
afterLoadRoutes() {
|
|
97
|
-
const {app} = this;
|
|
98
|
-
const platformExceptions = inject(PlatformExceptions)!;
|
|
99
|
-
|
|
100
|
-
// NOT FOUND
|
|
101
|
-
app.use((req: any, res: any, next: any) => {
|
|
102
|
-
const {$ctx} = req;
|
|
103
|
-
!$ctx.isDone() && platformExceptions?.resourceNotFound(req.$ctx);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// EXCEPTION FILTERS
|
|
107
|
-
app.use((err: any, req: any, res: any, next: any) => {
|
|
108
|
-
const {$ctx} = req;
|
|
109
|
-
!$ctx.isDone() && platformExceptions?.catch(err, $ctx);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
return Promise.resolve();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
mapLayers(layers: PlatformLayer[]) {
|
|
116
|
-
const rawApp: any = this.app.getApp();
|
|
117
|
-
|
|
118
|
-
layers.forEach((layer) => {
|
|
119
|
-
switch (layer.method) {
|
|
120
|
-
case "statics":
|
|
121
|
-
rawApp.use(layer.path, this.statics(layer.path as string, layer.opts as any));
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
rawApp[layer.method](...layer.getArgs());
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
mapHandler(handler: Function, metadata: PlatformHandlerMetadata) {
|
|
130
|
-
if (metadata.type == PlatformHandlerType.ERR_MIDDLEWARE) {
|
|
131
|
-
return (error: unknown, req: any, res: any, next: any) => {
|
|
132
|
-
return runInContext(req.$ctx, async () => {
|
|
133
|
-
const {$ctx} = req;
|
|
134
|
-
|
|
135
|
-
$ctx.next = next;
|
|
136
|
-
$ctx.error = error;
|
|
137
|
-
|
|
138
|
-
$ctx.error = await catchAsyncError(() => handler($ctx));
|
|
139
|
-
|
|
140
|
-
return callNext(next, metadata, $ctx);
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return (req: any, res: any, next: any) => {
|
|
146
|
-
return runInContext(req.$ctx, async () => {
|
|
147
|
-
const {$ctx} = req;
|
|
148
|
-
$ctx.next = next;
|
|
149
|
-
|
|
150
|
-
$ctx.error = await catchAsyncError(() => handler($ctx));
|
|
151
|
-
|
|
152
|
-
return callNext(next, metadata, $ctx);
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
useContext(): void {
|
|
158
|
-
const invoke = createContext();
|
|
159
|
-
const app = application();
|
|
160
|
-
|
|
161
|
-
app.use(async (request: any, response: any, next: any) => {
|
|
162
|
-
const $ctx = invoke({request, response});
|
|
163
|
-
await $ctx.start();
|
|
164
|
-
|
|
165
|
-
$ctx.response.getRes().on("finish", () => $ctx.finish());
|
|
166
|
-
|
|
167
|
-
return runInContext($ctx, next);
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
createApp() {
|
|
172
|
-
const app = constant<Express.Express>("express.app") || Express();
|
|
173
|
-
|
|
174
|
-
return {
|
|
175
|
-
app,
|
|
176
|
-
callback: () => app
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
statics(endpoint: string, options: PlatformStaticsOptions) {
|
|
181
|
-
const {root, ...props} = options;
|
|
182
|
-
|
|
183
|
-
return staticsMiddleware(root, props);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
bodyParser(type: "json" | "text" | "urlencoded", additionalOptions: any = {}): any {
|
|
187
|
-
const opts = constant(`express.bodyParser.${type}`);
|
|
188
|
-
|
|
189
|
-
let parser: any = Express[type];
|
|
190
|
-
let options: OptionsJson & OptionsText & OptionsUrlencoded = {};
|
|
191
|
-
|
|
192
|
-
if (isFunction(opts)) {
|
|
193
|
-
parser = opts;
|
|
194
|
-
options = {};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (type === "urlencoded") {
|
|
198
|
-
options.extended = true;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
options.verify = (req: IncomingMessage & {rawBody: Buffer}, _res: ServerResponse, buffer: Buffer) => {
|
|
202
|
-
const rawBody = constant(`rawBody`);
|
|
203
|
-
|
|
204
|
-
if (rawBody) {
|
|
205
|
-
req.rawBody = buffer;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return true;
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
return parser({...options, ...additionalOptions});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
private async configureViewsEngine() {
|
|
215
|
-
const {app} = this;
|
|
216
|
-
|
|
217
|
-
try {
|
|
218
|
-
const {exists, disabled} = constant<{exists?: boolean; disabled?: boolean}>("views") || {};
|
|
219
|
-
|
|
220
|
-
if (exists && !disabled) {
|
|
221
|
-
const {PlatformViews} = await import("@tsed/platform-views");
|
|
222
|
-
const platformViews = inject(PlatformViews)!;
|
|
223
|
-
const express = app.getApp();
|
|
224
|
-
|
|
225
|
-
platformViews.getEngines().forEach(({extension, engine}) => {
|
|
226
|
-
express.engine(extension, engine.render);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
platformViews.viewEngine && express.set("view engine", platformViews.viewEngine);
|
|
230
|
-
platformViews.root && express.set("views", platformViews.root);
|
|
231
|
-
}
|
|
232
|
-
} catch (error) {
|
|
233
|
-
// istanbul ignore next
|
|
234
|
-
logger().warn({
|
|
235
|
-
event: "PLATFORM_VIEWS_ERROR",
|
|
236
|
-
message: "Unable to configure the PlatformViews service on your environment.",
|
|
237
|
-
error
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
adapter(PlatformExpress, [
|
|
244
|
-
{
|
|
245
|
-
token: PlatformHandler,
|
|
246
|
-
useClass: PlatformExpressHandler
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
token: PlatformResponse,
|
|
250
|
-
useClass: PlatformExpressResponse
|
|
251
|
-
}
|
|
252
|
-
]);
|
package/src/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Automatically generated by @tsed/barrels.
|
|
3
|
-
*/
|
|
4
|
-
export * from "./components/PlatformExpress.js";
|
|
5
|
-
export * from "./interfaces/interfaces.js";
|
|
6
|
-
export * from "./interfaces/PlatformExpressSettings.js";
|
|
7
|
-
export * from "./interfaces/PlatformExpressStaticsOptions.js";
|
|
8
|
-
export * from "./middlewares/staticsMiddleware.js";
|
|
9
|
-
export * from "./services/PlatformExpressHandler.js";
|
|
10
|
-
export * from "./services/PlatformExpressResponse.js";
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type {Options, OptionsJson, OptionsText, OptionsUrlencoded} from "body-parser";
|
|
2
|
-
import type {NextHandleFunction} from "connect";
|
|
3
|
-
import type {RouterOptions} from "express";
|
|
4
|
-
|
|
5
|
-
export interface PlatformExpressSettings {
|
|
6
|
-
/**
|
|
7
|
-
* Global configuration for the Express.Router. See express [documentation](http://expressjs.com/en/api.html#express.router).
|
|
8
|
-
*/
|
|
9
|
-
router?: RouterOptions;
|
|
10
|
-
/**
|
|
11
|
-
* Express application
|
|
12
|
-
*/
|
|
13
|
-
app?: Express.Application;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* body parser configuration
|
|
17
|
-
*/
|
|
18
|
-
bodyParser?: {
|
|
19
|
-
json?: ((opts?: OptionsJson) => NextHandleFunction) | OptionsJson;
|
|
20
|
-
text?: ((opts?: OptionsText) => NextHandleFunction) | OptionsText;
|
|
21
|
-
raw?: ((opts?: Options) => NextHandleFunction) | Options;
|
|
22
|
-
urlencoded?: ((opts?: OptionsUrlencoded) => NextHandleFunction) | OptionsUrlencoded;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
useRawBody?: boolean;
|
|
26
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import Express from "express";
|
|
2
|
-
|
|
3
|
-
export interface PlatformExpressStaticsOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Enable or disable setting Cache-Control response header, defaults to true.
|
|
6
|
-
* Disabling this will ignore the immutable and maxAge options.
|
|
7
|
-
*/
|
|
8
|
-
cacheControl?: boolean;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Set how "dotfiles" are treated when encountered. A dotfile is a file or directory that begins with a dot (".").
|
|
12
|
-
* Note this check is done on the path itself without checking if the path actually exists on the disk.
|
|
13
|
-
* If root is specified, only the dotfiles above the root are checked (i.e. the root itself can be within a dotfile when when set to "deny").
|
|
14
|
-
* The default value is 'ignore'.
|
|
15
|
-
* 'allow' No special treatment for dotfiles
|
|
16
|
-
* 'deny' Send a 403 for any request for a dotfile
|
|
17
|
-
* 'ignore' Pretend like the dotfile does not exist and call next()
|
|
18
|
-
*/
|
|
19
|
-
dotfiles?: string;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Enable or disable etag generation, defaults to true.
|
|
23
|
-
*/
|
|
24
|
-
etag?: boolean;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Set file extension fallbacks. When set, if a file is not found, the given extensions will be added to the file name and search for.
|
|
28
|
-
* The first that exists will be served. Example: ['html', 'htm'].
|
|
29
|
-
* The default value is false.
|
|
30
|
-
*/
|
|
31
|
-
extensions?: string[] | false;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Let client errors fall-through as unhandled requests, otherwise forward a client error.
|
|
35
|
-
* The default value is true.
|
|
36
|
-
*/
|
|
37
|
-
fallthrough?: boolean;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Enable or disable the immutable directive in the Cache-Control response header.
|
|
41
|
-
* If enabled, the maxAge option should also be specified to enable caching. The immutable directive will prevent supported clients from making conditional requests during the life of the maxAge option to check if the file has changed.
|
|
42
|
-
*/
|
|
43
|
-
immutable?: boolean;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* By default this module will send "index.html" files in response to a request on a directory.
|
|
47
|
-
* To disable this set false or to supply a new index pass a string or an array in preferred order.
|
|
48
|
-
*/
|
|
49
|
-
index?: boolean | string | string[];
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.
|
|
53
|
-
*/
|
|
54
|
-
lastModified?: boolean;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Provide a max-age in milliseconds for http caching, defaults to 0. This can also be a string accepted by the ms module.
|
|
58
|
-
*/
|
|
59
|
-
maxAge?: number | string;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Redirect to trailing "/" when the pathname is a dir. Defaults to true.
|
|
63
|
-
*/
|
|
64
|
-
redirect?: boolean;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Function to set custom headers on response. Alterations to the headers need to occur synchronously.
|
|
68
|
-
* The function is called as fn(res, path, stat), where the arguments are:
|
|
69
|
-
* res the response object
|
|
70
|
-
* path the file path that is being sent
|
|
71
|
-
* stat the stat object of the file that is being sent
|
|
72
|
-
*/
|
|
73
|
-
setHeaders?: (res: Express.Response, path: string, stat: any) => any;
|
|
74
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {NextFunction as ENext, Request as EReq, Response as ERes} from "express";
|
|
2
|
-
|
|
3
|
-
import {PlatformExpressSettings} from "./PlatformExpressSettings.js";
|
|
4
|
-
|
|
5
|
-
declare global {
|
|
6
|
-
namespace TsED {
|
|
7
|
-
export interface Configuration {
|
|
8
|
-
/**
|
|
9
|
-
* Configuration related to Express platform application.
|
|
10
|
-
*/
|
|
11
|
-
express: PlatformExpressSettings;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface NextFunction extends ENext {}
|
|
15
|
-
|
|
16
|
-
export interface Response extends ERes {}
|
|
17
|
-
export interface Request extends EReq {}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import Express from "express";
|
|
2
|
-
|
|
3
|
-
import {staticsMiddleware} from "./staticsMiddleware.js";
|
|
4
|
-
|
|
5
|
-
describe("staticsMiddleware", () => {
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
vi.restoreAllMocks();
|
|
8
|
-
});
|
|
9
|
-
it("should call middleware", () => {
|
|
10
|
-
const middlewareServeStatic = vi.fn();
|
|
11
|
-
vi.spyOn(Express, "static").mockReturnValue(middlewareServeStatic);
|
|
12
|
-
const req = {};
|
|
13
|
-
const res = {};
|
|
14
|
-
const next = vi.fn();
|
|
15
|
-
|
|
16
|
-
const middleware = staticsMiddleware("/path", {root: "/publics", test: "test"});
|
|
17
|
-
middleware(req, res, next);
|
|
18
|
-
|
|
19
|
-
expect(middlewareServeStatic).toHaveBeenCalledWith(req, res, next);
|
|
20
|
-
});
|
|
21
|
-
it("should call next when headers is sent", () => {
|
|
22
|
-
const middlewareServeStatic = vi.fn();
|
|
23
|
-
vi.spyOn(Express, "static").mockReturnValue(middlewareServeStatic);
|
|
24
|
-
const req = {};
|
|
25
|
-
const res = {
|
|
26
|
-
headersSent: true
|
|
27
|
-
};
|
|
28
|
-
const next = vi.fn();
|
|
29
|
-
|
|
30
|
-
const middleware = staticsMiddleware("/path", {root: "/publics", test: "test"});
|
|
31
|
-
middleware(req, res, next);
|
|
32
|
-
|
|
33
|
-
expect(next).toHaveBeenCalled();
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Express from "express";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @ignore
|
|
5
|
-
*/
|
|
6
|
-
export function staticsMiddleware(directory: string, options: any = {}) {
|
|
7
|
-
const middleware = Express.static(directory, options);
|
|
8
|
-
|
|
9
|
-
return (request: any, response: any, next: any) => {
|
|
10
|
-
if (!response.headersSent) {
|
|
11
|
-
middleware(request, response, next);
|
|
12
|
-
} else {
|
|
13
|
-
next();
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {DITest, inject} from "@tsed/di";
|
|
2
|
-
import {PlatformTest} from "@tsed/platform-http/testing";
|
|
3
|
-
import {PlatformRouters} from "@tsed/platform-router";
|
|
4
|
-
|
|
5
|
-
import {PlatformExpressHandler} from "./PlatformExpressHandler.js";
|
|
6
|
-
|
|
7
|
-
vi.mock("@tsed/platform-http", async (importOriginal) => {
|
|
8
|
-
return {
|
|
9
|
-
...(await importOriginal()),
|
|
10
|
-
PlatformHandler: class PlatformHandler {
|
|
11
|
-
onResponse() {}
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
describe("PlatformExpressHandler", () => {
|
|
17
|
-
beforeEach(() =>
|
|
18
|
-
PlatformTest.create({
|
|
19
|
-
imports: [
|
|
20
|
-
{
|
|
21
|
-
token: PlatformRouters,
|
|
22
|
-
use: {
|
|
23
|
-
prebuild: vi.fn(),
|
|
24
|
-
hooks: {
|
|
25
|
-
on: vi.fn().mockReturnThis()
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
]
|
|
30
|
-
})
|
|
31
|
-
);
|
|
32
|
-
afterEach(() => DITest.reset());
|
|
33
|
-
it("should call middleware", async () => {
|
|
34
|
-
const instance = inject(PlatformExpressHandler);
|
|
35
|
-
const response: any = {};
|
|
36
|
-
const $ctx: any = {
|
|
37
|
-
getRequest: vi.fn().mockReturnThis(),
|
|
38
|
-
getResponse: vi.fn().mockReturnThis()
|
|
39
|
-
};
|
|
40
|
-
$ctx.data = (req: any, res: any, cb: any) => {
|
|
41
|
-
cb();
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
await instance.onResponse(response, $ctx);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {promisify} from "node:util";
|
|
2
|
-
|
|
3
|
-
import {AnyPromiseResult, isFunction, isStream} from "@tsed/core";
|
|
4
|
-
import {PlatformContext, PlatformHandler} from "@tsed/platform-http";
|
|
5
|
-
|
|
6
|
-
export class PlatformExpressHandler extends PlatformHandler {
|
|
7
|
-
onResponse(response: AnyPromiseResult, $ctx: PlatformContext): any {
|
|
8
|
-
super.onResponse(response, $ctx);
|
|
9
|
-
|
|
10
|
-
// call returned middleware
|
|
11
|
-
if (isFunction($ctx.data) && !isStream($ctx.data)) {
|
|
12
|
-
return promisify($ctx.data)($ctx.getRequest(), $ctx.getResponse());
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {isNumber} from "@tsed/core";
|
|
2
|
-
import {PlatformResponse} from "@tsed/platform-http";
|
|
3
|
-
|
|
4
|
-
export class PlatformExpressResponse extends PlatformResponse<TsED.Response> {
|
|
5
|
-
protected end(data?: string | Buffer) {
|
|
6
|
-
if (isNumber(data)) {
|
|
7
|
-
// TODO remove this when Express 5 will be the default version of Ts.ED
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
this.raw.send(this.statusCode, data);
|
|
10
|
-
} else {
|
|
11
|
-
this.raw.send(data);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
package/vitest.config.mts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import {presets} from "@tsed/vitest/presets";
|
|
3
|
-
import {defineConfig} from "vitest/config";
|
|
4
|
-
|
|
5
|
-
export default defineConfig(
|
|
6
|
-
{
|
|
7
|
-
...presets,
|
|
8
|
-
test: {
|
|
9
|
-
...presets.test,
|
|
10
|
-
coverage: {
|
|
11
|
-
...presets.test.coverage,
|
|
12
|
-
thresholds: {
|
|
13
|
-
statements: 0,
|
|
14
|
-
branches: 0,
|
|
15
|
-
functions: 0,
|
|
16
|
-
lines: 0
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
);
|