@modern-js/plugin-bff 2.56.2 → 2.57.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/dist/cjs/server.js +3 -8
- package/dist/esm/server.js +8 -32
- package/dist/esm-node/server.js +3 -8
- package/package.json +13 -13
package/dist/cjs/server.js
CHANGED
|
@@ -34,7 +34,6 @@ module.exports = __toCommonJS(server_exports);
|
|
|
34
34
|
var import_path = __toESM(require("path"));
|
|
35
35
|
var import_bff_core = require("@modern-js/bff-core");
|
|
36
36
|
var import_utils = require("@modern-js/utils");
|
|
37
|
-
var import_server_core = require("@modern-js/server-core");
|
|
38
37
|
var import_constants = require("./constants");
|
|
39
38
|
class Storage {
|
|
40
39
|
reset() {
|
|
@@ -60,7 +59,7 @@ var server_default = () => ({
|
|
|
60
59
|
async prepare() {
|
|
61
60
|
var _config_bff, _config_bff1, _config_bff2;
|
|
62
61
|
const appContext = api.useAppContext();
|
|
63
|
-
const { appDirectory, distDirectory } = appContext;
|
|
62
|
+
const { appDirectory, distDirectory, render } = appContext;
|
|
64
63
|
const root = (0, import_utils.isProd)() ? distDirectory : appDirectory;
|
|
65
64
|
const apiPath = import_path.default.resolve(root || process.cwd(), import_utils.API_DIR);
|
|
66
65
|
apiAppPath = import_path.default.resolve(apiPath, import_constants.API_APP_NAME);
|
|
@@ -77,7 +76,7 @@ var server_default = () => ({
|
|
|
77
76
|
const prefix = (config === null || config === void 0 ? void 0 : (_config_bff = config.bff) === null || _config_bff === void 0 ? void 0 : _config_bff.prefix) || "/api";
|
|
78
77
|
const enableHandleWeb = config === null || config === void 0 ? void 0 : (_config_bff1 = config.bff) === null || _config_bff1 === void 0 ? void 0 : _config_bff1.enableHandleWeb;
|
|
79
78
|
const httpMethodDecider = config === null || config === void 0 ? void 0 : (_config_bff2 = config.bff) === null || _config_bff2 === void 0 ? void 0 : _config_bff2.httpMethodDecider;
|
|
80
|
-
const { distDirectory: pwd,
|
|
79
|
+
const { distDirectory: pwd, middlewares: globalMiddlewares } = api.useAppContext();
|
|
81
80
|
const webOnly = await (0, import_utils.isWebOnly)();
|
|
82
81
|
let handler;
|
|
83
82
|
if (webOnly) {
|
|
@@ -87,11 +86,7 @@ var server_default = () => ({
|
|
|
87
86
|
};
|
|
88
87
|
} else {
|
|
89
88
|
const runner = api.useHookRunners();
|
|
90
|
-
const renderHandler = enableHandleWeb ?
|
|
91
|
-
pwd,
|
|
92
|
-
routes: routes || [],
|
|
93
|
-
config
|
|
94
|
-
}) : null;
|
|
89
|
+
const renderHandler = enableHandleWeb ? render : null;
|
|
95
90
|
handler = await runner.prepareApiServer({
|
|
96
91
|
pwd,
|
|
97
92
|
prefix,
|
package/dist/esm/server.js
CHANGED
|
@@ -6,7 +6,6 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
|
6
6
|
import path from "path";
|
|
7
7
|
import { ApiRouter } from "@modern-js/bff-core";
|
|
8
8
|
import { API_DIR, isProd, isWebOnly, requireExistModule } from "@modern-js/utils";
|
|
9
|
-
import { getRenderHandler } from "@modern-js/server-core";
|
|
10
9
|
import { API_APP_NAME } from "./constants";
|
|
11
10
|
var Storage = /* @__PURE__ */ function() {
|
|
12
11
|
"use strict";
|
|
@@ -38,12 +37,12 @@ function server_default() {
|
|
|
38
37
|
return {
|
|
39
38
|
prepare: function prepare() {
|
|
40
39
|
return _async_to_generator(function() {
|
|
41
|
-
var _config_bff, _config_bff1, _config_bff2, appContext, appDirectory, distDirectory, root, apiPath, apiMod, middlewares, config, prefix, enableHandleWeb, httpMethodDecider, _api_useAppContext, pwd,
|
|
40
|
+
var _config_bff, _config_bff1, _config_bff2, appContext, appDirectory, distDirectory, render, root, apiPath, apiMod, middlewares, config, prefix, enableHandleWeb, httpMethodDecider, _api_useAppContext, pwd, globalMiddlewares, webOnly, handler, runner, renderHandler;
|
|
42
41
|
return _ts_generator(this, function(_state) {
|
|
43
42
|
switch (_state.label) {
|
|
44
43
|
case 0:
|
|
45
44
|
appContext = api.useAppContext();
|
|
46
|
-
appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory;
|
|
45
|
+
appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, render = appContext.render;
|
|
47
46
|
root = isProd() ? distDirectory : appDirectory;
|
|
48
47
|
apiPath = path.resolve(root || process.cwd(), API_DIR);
|
|
49
48
|
apiAppPath = path.resolve(apiPath, API_APP_NAME);
|
|
@@ -59,7 +58,7 @@ function server_default() {
|
|
|
59
58
|
prefix = (config === null || config === void 0 ? void 0 : (_config_bff = config.bff) === null || _config_bff === void 0 ? void 0 : _config_bff.prefix) || "/api";
|
|
60
59
|
enableHandleWeb = config === null || config === void 0 ? void 0 : (_config_bff1 = config.bff) === null || _config_bff1 === void 0 ? void 0 : _config_bff1.enableHandleWeb;
|
|
61
60
|
httpMethodDecider = config === null || config === void 0 ? void 0 : (_config_bff2 = config.bff) === null || _config_bff2 === void 0 ? void 0 : _config_bff2.httpMethodDecider;
|
|
62
|
-
_api_useAppContext = api.useAppContext(), pwd = _api_useAppContext.distDirectory,
|
|
61
|
+
_api_useAppContext = api.useAppContext(), pwd = _api_useAppContext.distDirectory, globalMiddlewares = _api_useAppContext.middlewares;
|
|
63
62
|
return [
|
|
64
63
|
4,
|
|
65
64
|
isWebOnly()
|
|
@@ -95,34 +94,11 @@ function server_default() {
|
|
|
95
94
|
}();
|
|
96
95
|
return [
|
|
97
96
|
3,
|
|
98
|
-
|
|
97
|
+
4
|
|
99
98
|
];
|
|
100
99
|
case 2:
|
|
101
100
|
runner = api.useHookRunners();
|
|
102
|
-
|
|
103
|
-
return [
|
|
104
|
-
3,
|
|
105
|
-
4
|
|
106
|
-
];
|
|
107
|
-
return [
|
|
108
|
-
4,
|
|
109
|
-
getRenderHandler({
|
|
110
|
-
pwd,
|
|
111
|
-
routes: routes || [],
|
|
112
|
-
config
|
|
113
|
-
})
|
|
114
|
-
];
|
|
115
|
-
case 3:
|
|
116
|
-
_tmp = _state.sent();
|
|
117
|
-
return [
|
|
118
|
-
3,
|
|
119
|
-
5
|
|
120
|
-
];
|
|
121
|
-
case 4:
|
|
122
|
-
_tmp = null;
|
|
123
|
-
_state.label = 5;
|
|
124
|
-
case 5:
|
|
125
|
-
renderHandler = _tmp;
|
|
101
|
+
renderHandler = enableHandleWeb ? render : null;
|
|
126
102
|
return [
|
|
127
103
|
4,
|
|
128
104
|
runner.prepareApiServer({
|
|
@@ -136,10 +112,10 @@ function server_default() {
|
|
|
136
112
|
}
|
|
137
113
|
})
|
|
138
114
|
];
|
|
139
|
-
case
|
|
115
|
+
case 3:
|
|
140
116
|
handler = _state.sent();
|
|
141
|
-
_state.label =
|
|
142
|
-
case
|
|
117
|
+
_state.label = 4;
|
|
118
|
+
case 4:
|
|
143
119
|
if (handler) {
|
|
144
120
|
globalMiddlewares.push({
|
|
145
121
|
name: "bind-bff",
|
package/dist/esm-node/server.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { ApiRouter } from "@modern-js/bff-core";
|
|
3
3
|
import { API_DIR, isProd, isWebOnly, requireExistModule } from "@modern-js/utils";
|
|
4
|
-
import { getRenderHandler } from "@modern-js/server-core";
|
|
5
4
|
import { API_APP_NAME } from "./constants";
|
|
6
5
|
class Storage {
|
|
7
6
|
reset() {
|
|
@@ -27,7 +26,7 @@ var server_default = () => ({
|
|
|
27
26
|
async prepare() {
|
|
28
27
|
var _config_bff, _config_bff1, _config_bff2;
|
|
29
28
|
const appContext = api.useAppContext();
|
|
30
|
-
const { appDirectory, distDirectory } = appContext;
|
|
29
|
+
const { appDirectory, distDirectory, render } = appContext;
|
|
31
30
|
const root = isProd() ? distDirectory : appDirectory;
|
|
32
31
|
const apiPath = path.resolve(root || process.cwd(), API_DIR);
|
|
33
32
|
apiAppPath = path.resolve(apiPath, API_APP_NAME);
|
|
@@ -44,7 +43,7 @@ var server_default = () => ({
|
|
|
44
43
|
const prefix = (config === null || config === void 0 ? void 0 : (_config_bff = config.bff) === null || _config_bff === void 0 ? void 0 : _config_bff.prefix) || "/api";
|
|
45
44
|
const enableHandleWeb = config === null || config === void 0 ? void 0 : (_config_bff1 = config.bff) === null || _config_bff1 === void 0 ? void 0 : _config_bff1.enableHandleWeb;
|
|
46
45
|
const httpMethodDecider = config === null || config === void 0 ? void 0 : (_config_bff2 = config.bff) === null || _config_bff2 === void 0 ? void 0 : _config_bff2.httpMethodDecider;
|
|
47
|
-
const { distDirectory: pwd,
|
|
46
|
+
const { distDirectory: pwd, middlewares: globalMiddlewares } = api.useAppContext();
|
|
48
47
|
const webOnly = await isWebOnly();
|
|
49
48
|
let handler;
|
|
50
49
|
if (webOnly) {
|
|
@@ -54,11 +53,7 @@ var server_default = () => ({
|
|
|
54
53
|
};
|
|
55
54
|
} else {
|
|
56
55
|
const runner = api.useHookRunners();
|
|
57
|
-
const renderHandler = enableHandleWeb ?
|
|
58
|
-
pwd,
|
|
59
|
-
routes: routes || [],
|
|
60
|
-
config
|
|
61
|
-
}) : null;
|
|
56
|
+
const renderHandler = enableHandleWeb ? render : null;
|
|
62
57
|
handler = await runner.prepareApiServer({
|
|
63
58
|
pwd,
|
|
64
59
|
prefix,
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.57.1",
|
|
19
19
|
"jsnext:source": "./src/cli.ts",
|
|
20
20
|
"types": "./dist/types/cli.d.ts",
|
|
21
21
|
"main": "./dist/cjs/cli.js",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@babel/core": "^7.24.7",
|
|
60
60
|
"@swc/helpers": "0.5.3",
|
|
61
|
-
"@modern-js/bff-core": "2.
|
|
62
|
-
"@modern-js/server-
|
|
63
|
-
"@modern-js/create-request": "2.
|
|
64
|
-
"@modern-js/server-
|
|
65
|
-
"@modern-js/utils": "2.
|
|
61
|
+
"@modern-js/bff-core": "2.57.1",
|
|
62
|
+
"@modern-js/server-utils": "2.57.1",
|
|
63
|
+
"@modern-js/create-request": "2.57.1",
|
|
64
|
+
"@modern-js/server-core": "2.57.1",
|
|
65
|
+
"@modern-js/utils": "2.57.1"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/babel__core": "^7.20.5",
|
|
@@ -73,13 +73,13 @@
|
|
|
73
73
|
"ts-jest": "^29.1.0",
|
|
74
74
|
"typescript": "^5",
|
|
75
75
|
"webpack": "^5.93.0",
|
|
76
|
-
"@modern-js/runtime": "2.
|
|
77
|
-
"@modern-js/core": "2.
|
|
78
|
-
"@modern-js/
|
|
79
|
-
"@modern-js/
|
|
80
|
-
"@
|
|
81
|
-
"@
|
|
82
|
-
"@scripts/jest-config": "2.
|
|
76
|
+
"@modern-js/runtime": "2.57.1",
|
|
77
|
+
"@modern-js/core": "2.57.1",
|
|
78
|
+
"@modern-js/app-tools": "2.57.1",
|
|
79
|
+
"@modern-js/bff-runtime": "2.57.1",
|
|
80
|
+
"@scripts/build": "2.57.1",
|
|
81
|
+
"@modern-js/types": "2.57.1",
|
|
82
|
+
"@scripts/jest-config": "2.57.1"
|
|
83
83
|
},
|
|
84
84
|
"sideEffects": false,
|
|
85
85
|
"publishConfig": {
|