@modern-js/plugin-express 2.9.0 → 2.11.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/CHANGELOG.md +38 -0
- package/dist/cjs/plugin.js +12 -1
- package/dist/esm/plugin.js +31 -2
- package/dist/esm-node/plugin.js +12 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @modern-js/plugin-express
|
|
2
2
|
|
|
3
|
+
## 2.11.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [cfb058f]
|
|
8
|
+
- Updated dependencies [0bd018b]
|
|
9
|
+
- Updated dependencies [5d624fd]
|
|
10
|
+
- Updated dependencies [e2466a1]
|
|
11
|
+
- Updated dependencies [02bb383]
|
|
12
|
+
- Updated dependencies [381a3b9]
|
|
13
|
+
- Updated dependencies [7a60f10]
|
|
14
|
+
- Updated dependencies [274b2e5]
|
|
15
|
+
- Updated dependencies [b9e1c54]
|
|
16
|
+
- @modern-js/utils@2.11.0
|
|
17
|
+
- @modern-js/bff-core@2.11.0
|
|
18
|
+
- @modern-js/bff-runtime@2.11.0
|
|
19
|
+
- @modern-js/types@2.11.0
|
|
20
|
+
|
|
21
|
+
## 2.10.0
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 3e0bd50: feat: when enable bff handle render, support use `useContext` to get framework plugin context in data loader.
|
|
26
|
+
feat: 当开启 BFF 托管渲染时,支持在 data loader 中使用 `useContext` 获取框架插件提供的上下文。
|
|
27
|
+
- 0da32d0: chore: upgrade jest and puppeteer
|
|
28
|
+
chore: 升级 jest 和 puppeteer 到 latest
|
|
29
|
+
- Updated dependencies [3e0bd50]
|
|
30
|
+
- Updated dependencies [92d247f]
|
|
31
|
+
- Updated dependencies [0da32d0]
|
|
32
|
+
- Updated dependencies [0d9962b]
|
|
33
|
+
- Updated dependencies [fbefa7e]
|
|
34
|
+
- Updated dependencies [4d54233]
|
|
35
|
+
- Updated dependencies [6db4864]
|
|
36
|
+
- @modern-js/types@2.10.0
|
|
37
|
+
- @modern-js/bff-runtime@2.10.0
|
|
38
|
+
- @modern-js/bff-core@2.10.0
|
|
39
|
+
- @modern-js/utils@2.10.0
|
|
40
|
+
|
|
3
41
|
## 2.9.0
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -87,13 +87,15 @@ var plugin_default = () => ({
|
|
|
87
87
|
"@modern-js/plugin-server"
|
|
88
88
|
],
|
|
89
89
|
setup: (api) => ({
|
|
90
|
-
async prepareApiServer({ pwd, config }) {
|
|
90
|
+
async prepareApiServer({ pwd, config, render }) {
|
|
91
|
+
var _a;
|
|
91
92
|
let app;
|
|
92
93
|
const appContext = api.useAppContext();
|
|
93
94
|
const apiHandlerInfos = appContext.apiHandlerInfos;
|
|
94
95
|
const apiDirectory = appContext.apiDirectory;
|
|
95
96
|
const apiDir = apiDirectory || path.join(pwd, "./api");
|
|
96
97
|
const mode = appContext.apiMode;
|
|
98
|
+
const userConfig = api.useConfigContext();
|
|
97
99
|
if (mode === "framework") {
|
|
98
100
|
const appModule = await findAppModule(apiDir);
|
|
99
101
|
app = appModule[0];
|
|
@@ -126,6 +128,15 @@ var plugin_default = () => ({
|
|
|
126
128
|
} else {
|
|
127
129
|
throw new Error(`mode must be function or framework`);
|
|
128
130
|
}
|
|
131
|
+
if (((_a = userConfig.bff) == null ? void 0 : _a.enableHandleWeb) && render) {
|
|
132
|
+
app.use(async (req, res, next) => {
|
|
133
|
+
const html = await render(req, res);
|
|
134
|
+
if (html) {
|
|
135
|
+
res.end(html);
|
|
136
|
+
}
|
|
137
|
+
next();
|
|
138
|
+
});
|
|
139
|
+
}
|
|
129
140
|
return (req, res) => new Promise((resolve, reject) => {
|
|
130
141
|
const handler = (err) => {
|
|
131
142
|
if (err) {
|
package/dist/esm/plugin.js
CHANGED
|
@@ -255,9 +255,9 @@ var plugin_default = function() {
|
|
|
255
255
|
setup: function(api) {
|
|
256
256
|
return {
|
|
257
257
|
prepareApiServer: function prepareApiServer(param) {
|
|
258
|
-
var pwd = param.pwd, config = param.config;
|
|
258
|
+
var pwd = param.pwd, config = param.config, render = param.render;
|
|
259
259
|
return _asyncToGenerator(function() {
|
|
260
|
-
var app, appContext, apiHandlerInfos, apiDirectory, apiDir, mode, appModule, hooks, middleware, afterLambdaRegisted, middleware1;
|
|
260
|
+
var _userConfig_bff, app, appContext, apiHandlerInfos, apiDirectory, apiDir, mode, userConfig, appModule, hooks, middleware, afterLambdaRegisted, middleware1;
|
|
261
261
|
return __generator(this, function(_state) {
|
|
262
262
|
switch(_state.label){
|
|
263
263
|
case 0:
|
|
@@ -266,6 +266,7 @@ var plugin_default = function() {
|
|
|
266
266
|
apiDirectory = appContext.apiDirectory;
|
|
267
267
|
apiDir = apiDirectory || path.join(pwd, "./api");
|
|
268
268
|
mode = appContext.apiMode;
|
|
269
|
+
userConfig = api.useConfigContext();
|
|
269
270
|
if (!(mode === "framework")) return [
|
|
270
271
|
3,
|
|
271
272
|
2
|
|
@@ -313,6 +314,34 @@ var plugin_default = function() {
|
|
|
313
314
|
}
|
|
314
315
|
_state.label = 3;
|
|
315
316
|
case 3:
|
|
317
|
+
if (((_userConfig_bff = userConfig.bff) === null || _userConfig_bff === void 0 ? void 0 : _userConfig_bff.enableHandleWeb) && render) {
|
|
318
|
+
app.use(function() {
|
|
319
|
+
var _ref = _asyncToGenerator(function(req, res, next) {
|
|
320
|
+
var html;
|
|
321
|
+
return __generator(this, function(_state) {
|
|
322
|
+
switch(_state.label){
|
|
323
|
+
case 0:
|
|
324
|
+
return [
|
|
325
|
+
4,
|
|
326
|
+
render(req, res)
|
|
327
|
+
];
|
|
328
|
+
case 1:
|
|
329
|
+
html = _state.sent();
|
|
330
|
+
if (html) {
|
|
331
|
+
res.end(html);
|
|
332
|
+
}
|
|
333
|
+
next();
|
|
334
|
+
return [
|
|
335
|
+
2
|
|
336
|
+
];
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
return function(req, res, next) {
|
|
341
|
+
return _ref.apply(this, arguments);
|
|
342
|
+
};
|
|
343
|
+
}());
|
|
344
|
+
}
|
|
316
345
|
return [
|
|
317
346
|
2,
|
|
318
347
|
function(req, res) {
|
package/dist/esm-node/plugin.js
CHANGED
|
@@ -55,13 +55,15 @@ var plugin_default = () => ({
|
|
|
55
55
|
"@modern-js/plugin-server"
|
|
56
56
|
],
|
|
57
57
|
setup: (api) => ({
|
|
58
|
-
async prepareApiServer({ pwd, config }) {
|
|
58
|
+
async prepareApiServer({ pwd, config, render }) {
|
|
59
|
+
var _a;
|
|
59
60
|
let app;
|
|
60
61
|
const appContext = api.useAppContext();
|
|
61
62
|
const apiHandlerInfos = appContext.apiHandlerInfos;
|
|
62
63
|
const apiDirectory = appContext.apiDirectory;
|
|
63
64
|
const apiDir = apiDirectory || path.join(pwd, "./api");
|
|
64
65
|
const mode = appContext.apiMode;
|
|
66
|
+
const userConfig = api.useConfigContext();
|
|
65
67
|
if (mode === "framework") {
|
|
66
68
|
const appModule = await findAppModule(apiDir);
|
|
67
69
|
app = appModule[0];
|
|
@@ -94,6 +96,15 @@ var plugin_default = () => ({
|
|
|
94
96
|
} else {
|
|
95
97
|
throw new Error(`mode must be function or framework`);
|
|
96
98
|
}
|
|
99
|
+
if (((_a = userConfig.bff) == null ? void 0 : _a.enableHandleWeb) && render) {
|
|
100
|
+
app.use(async (req, res, next) => {
|
|
101
|
+
const html = await render(req, res);
|
|
102
|
+
if (html) {
|
|
103
|
+
res.end(html);
|
|
104
|
+
}
|
|
105
|
+
next();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
97
108
|
return (req, res) => new Promise((resolve, reject) => {
|
|
98
109
|
const handler = (err) => {
|
|
99
110
|
if (err) {
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.11.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/cli/index.d.ts",
|
|
17
17
|
"main": "./dist/cjs/cli/index.js",
|
|
@@ -42,30 +42,30 @@
|
|
|
42
42
|
"formidable": "^1.2.2",
|
|
43
43
|
"reflect-metadata": "^0.1.13",
|
|
44
44
|
"type-is": "^1.6.18",
|
|
45
|
-
"@modern-js/bff-core": "2.
|
|
46
|
-
"@modern-js/bff-runtime": "2.
|
|
47
|
-
"@modern-js/types": "2.
|
|
48
|
-
"@modern-js/utils": "2.
|
|
45
|
+
"@modern-js/bff-core": "2.11.0",
|
|
46
|
+
"@modern-js/bff-runtime": "2.11.0",
|
|
47
|
+
"@modern-js/types": "2.11.0",
|
|
48
|
+
"@modern-js/utils": "2.11.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/cookie-parser": "^1.4.2",
|
|
52
52
|
"@types/express": "^4.17.13",
|
|
53
53
|
"@types/finalhandler": "^1.1.1",
|
|
54
54
|
"@types/formidable": "^1.2.3",
|
|
55
|
-
"@types/jest": "^
|
|
55
|
+
"@types/jest": "^29",
|
|
56
56
|
"@types/node": "^14",
|
|
57
57
|
"@types/supertest": "^2.0.11",
|
|
58
58
|
"@types/type-is": "^1.6.3",
|
|
59
59
|
"express": "^4.17.1",
|
|
60
|
-
"jest": "^
|
|
60
|
+
"jest": "^29",
|
|
61
61
|
"supertest": "^6.1.6",
|
|
62
62
|
"typescript": "^4",
|
|
63
63
|
"zod": "^3.17.3",
|
|
64
|
-
"@modern-js/core": "2.
|
|
65
|
-
"@modern-js/app-tools": "2.
|
|
66
|
-
"@modern-js/server-core": "2.
|
|
67
|
-
"@scripts/build": "2.
|
|
68
|
-
"@scripts/jest-config": "2.
|
|
64
|
+
"@modern-js/core": "2.11.0",
|
|
65
|
+
"@modern-js/app-tools": "2.11.0",
|
|
66
|
+
"@modern-js/server-core": "2.11.0",
|
|
67
|
+
"@scripts/build": "2.11.0",
|
|
68
|
+
"@scripts/jest-config": "2.11.0"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"express": "^4.17.1"
|