@modern-js/plugin-bff 2.48.6 → 2.49.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 +22 -5
- package/dist/esm/server.js +20 -7
- package/dist/esm-node/server.js +22 -5
- package/dist/types/server.d.ts +1 -1
- package/package.json +14 -14
package/dist/cjs/server.js
CHANGED
|
@@ -54,9 +54,11 @@ var server_default = () => ({
|
|
|
54
54
|
const storage = new Storage();
|
|
55
55
|
const transformAPI = createTransformAPI(storage);
|
|
56
56
|
let apiAppPath = "";
|
|
57
|
+
let apiRouter;
|
|
57
58
|
return {
|
|
58
59
|
prepare() {
|
|
59
|
-
const
|
|
60
|
+
const appContext = api.useAppContext();
|
|
61
|
+
const { appDirectory, distDirectory } = appContext;
|
|
60
62
|
const root = (0, import_utils.isProd)() ? distDirectory : appDirectory;
|
|
61
63
|
const apiPath = import_path.default.resolve(root || process.cwd(), import_utils.API_DIR);
|
|
62
64
|
apiAppPath = import_path.default.resolve(apiPath, import_constants.API_APP_NAME);
|
|
@@ -64,25 +66,40 @@ var server_default = () => ({
|
|
|
64
66
|
if (apiMod && typeof apiMod === "function") {
|
|
65
67
|
apiMod(transformAPI);
|
|
66
68
|
}
|
|
69
|
+
const { middlewares } = storage;
|
|
70
|
+
api.setAppContext({
|
|
71
|
+
...appContext,
|
|
72
|
+
apiMiddlewares: middlewares
|
|
73
|
+
});
|
|
67
74
|
},
|
|
68
75
|
reset() {
|
|
69
76
|
storage.reset();
|
|
77
|
+
const appContext = api.useAppContext();
|
|
70
78
|
const newApiModule = (0, import_utils.requireExistModule)(apiAppPath);
|
|
71
79
|
if (newApiModule && typeof newApiModule === "function") {
|
|
72
80
|
newApiModule(transformAPI);
|
|
73
81
|
}
|
|
82
|
+
const { middlewares } = storage;
|
|
83
|
+
api.setAppContext({
|
|
84
|
+
...appContext,
|
|
85
|
+
apiMiddlewares: middlewares
|
|
86
|
+
});
|
|
74
87
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
88
|
+
onApiChange(changes) {
|
|
89
|
+
const apiHandlerInfos = apiRouter.getApiHandlers();
|
|
90
|
+
const appContext = api.useAppContext();
|
|
91
|
+
api.setAppContext({
|
|
92
|
+
...appContext,
|
|
93
|
+
apiHandlerInfos
|
|
78
94
|
});
|
|
95
|
+
return changes;
|
|
79
96
|
},
|
|
80
97
|
prepareApiServer(props, next) {
|
|
81
98
|
const { pwd, prefix, httpMethodDecider } = props;
|
|
82
99
|
const apiDir = import_path.default.resolve(pwd, import_utils.API_DIR);
|
|
83
100
|
const appContext = api.useAppContext();
|
|
84
101
|
const { apiDirectory, lambdaDirectory } = appContext;
|
|
85
|
-
|
|
102
|
+
apiRouter = new import_bff_core.ApiRouter({
|
|
86
103
|
appDir: pwd,
|
|
87
104
|
apiDir: apiDirectory || apiDir,
|
|
88
105
|
lambdaDir: lambdaDirectory,
|
package/dist/esm/server.js
CHANGED
|
@@ -31,9 +31,11 @@ function server_default() {
|
|
|
31
31
|
var storage = new Storage();
|
|
32
32
|
var transformAPI = createTransformAPI(storage);
|
|
33
33
|
var apiAppPath = "";
|
|
34
|
+
var apiRouter;
|
|
34
35
|
return {
|
|
35
36
|
prepare: function prepare() {
|
|
36
|
-
var
|
|
37
|
+
var appContext = api.useAppContext();
|
|
38
|
+
var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory;
|
|
37
39
|
var root = isProd() ? distDirectory : appDirectory;
|
|
38
40
|
var apiPath = path.resolve(root || process.cwd(), API_DIR);
|
|
39
41
|
apiAppPath = path.resolve(apiPath, API_APP_NAME);
|
|
@@ -41,26 +43,37 @@ function server_default() {
|
|
|
41
43
|
if (apiMod && typeof apiMod === "function") {
|
|
42
44
|
apiMod(transformAPI);
|
|
43
45
|
}
|
|
46
|
+
var middlewares = storage.middlewares;
|
|
47
|
+
api.setAppContext(_object_spread_props(_object_spread({}, appContext), {
|
|
48
|
+
apiMiddlewares: middlewares
|
|
49
|
+
}));
|
|
44
50
|
},
|
|
45
51
|
reset: function reset() {
|
|
46
52
|
storage.reset();
|
|
53
|
+
var appContext = api.useAppContext();
|
|
47
54
|
var newApiModule = requireExistModule(apiAppPath);
|
|
48
55
|
if (newApiModule && typeof newApiModule === "function") {
|
|
49
56
|
newApiModule(transformAPI);
|
|
50
57
|
}
|
|
58
|
+
var middlewares = storage.middlewares;
|
|
59
|
+
api.setAppContext(_object_spread_props(_object_spread({}, appContext), {
|
|
60
|
+
apiMiddlewares: middlewares
|
|
61
|
+
}));
|
|
51
62
|
},
|
|
52
|
-
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
onApiChange: function onApiChange(changes) {
|
|
64
|
+
var apiHandlerInfos = apiRouter.getApiHandlers();
|
|
65
|
+
var appContext = api.useAppContext();
|
|
66
|
+
api.setAppContext(_object_spread_props(_object_spread({}, appContext), {
|
|
67
|
+
apiHandlerInfos
|
|
68
|
+
}));
|
|
69
|
+
return changes;
|
|
57
70
|
},
|
|
58
71
|
prepareApiServer: function prepareApiServer(props, next) {
|
|
59
72
|
var pwd = props.pwd, prefix = props.prefix, httpMethodDecider = props.httpMethodDecider;
|
|
60
73
|
var apiDir = path.resolve(pwd, API_DIR);
|
|
61
74
|
var appContext = api.useAppContext();
|
|
62
75
|
var apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory;
|
|
63
|
-
|
|
76
|
+
apiRouter = new ApiRouter({
|
|
64
77
|
appDir: pwd,
|
|
65
78
|
apiDir: apiDirectory || apiDir,
|
|
66
79
|
lambdaDir: lambdaDirectory,
|
package/dist/esm-node/server.js
CHANGED
|
@@ -21,9 +21,11 @@ var server_default = () => ({
|
|
|
21
21
|
const storage = new Storage();
|
|
22
22
|
const transformAPI = createTransformAPI(storage);
|
|
23
23
|
let apiAppPath = "";
|
|
24
|
+
let apiRouter;
|
|
24
25
|
return {
|
|
25
26
|
prepare() {
|
|
26
|
-
const
|
|
27
|
+
const appContext = api.useAppContext();
|
|
28
|
+
const { appDirectory, distDirectory } = appContext;
|
|
27
29
|
const root = isProd() ? distDirectory : appDirectory;
|
|
28
30
|
const apiPath = path.resolve(root || process.cwd(), API_DIR);
|
|
29
31
|
apiAppPath = path.resolve(apiPath, API_APP_NAME);
|
|
@@ -31,25 +33,40 @@ var server_default = () => ({
|
|
|
31
33
|
if (apiMod && typeof apiMod === "function") {
|
|
32
34
|
apiMod(transformAPI);
|
|
33
35
|
}
|
|
36
|
+
const { middlewares } = storage;
|
|
37
|
+
api.setAppContext({
|
|
38
|
+
...appContext,
|
|
39
|
+
apiMiddlewares: middlewares
|
|
40
|
+
});
|
|
34
41
|
},
|
|
35
42
|
reset() {
|
|
36
43
|
storage.reset();
|
|
44
|
+
const appContext = api.useAppContext();
|
|
37
45
|
const newApiModule = requireExistModule(apiAppPath);
|
|
38
46
|
if (newApiModule && typeof newApiModule === "function") {
|
|
39
47
|
newApiModule(transformAPI);
|
|
40
48
|
}
|
|
49
|
+
const { middlewares } = storage;
|
|
50
|
+
api.setAppContext({
|
|
51
|
+
...appContext,
|
|
52
|
+
apiMiddlewares: middlewares
|
|
53
|
+
});
|
|
41
54
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
onApiChange(changes) {
|
|
56
|
+
const apiHandlerInfos = apiRouter.getApiHandlers();
|
|
57
|
+
const appContext = api.useAppContext();
|
|
58
|
+
api.setAppContext({
|
|
59
|
+
...appContext,
|
|
60
|
+
apiHandlerInfos
|
|
45
61
|
});
|
|
62
|
+
return changes;
|
|
46
63
|
},
|
|
47
64
|
prepareApiServer(props, next) {
|
|
48
65
|
const { pwd, prefix, httpMethodDecider } = props;
|
|
49
66
|
const apiDir = path.resolve(pwd, API_DIR);
|
|
50
67
|
const appContext = api.useAppContext();
|
|
51
68
|
const { apiDirectory, lambdaDirectory } = appContext;
|
|
52
|
-
|
|
69
|
+
apiRouter = new ApiRouter({
|
|
53
70
|
appDir: pwd,
|
|
54
71
|
apiDir: apiDirectory || apiDir,
|
|
55
72
|
lambdaDir: lambdaDirectory,
|
package/dist/types/server.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.49.1",
|
|
19
19
|
"jsnext:source": "./src/cli.ts",
|
|
20
20
|
"types": "./dist/types/cli.d.ts",
|
|
21
21
|
"main": "./dist/cjs/cli.js",
|
|
@@ -57,13 +57,13 @@
|
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@babel/core": "^7.23.2",
|
|
59
59
|
"@swc/helpers": "0.5.3",
|
|
60
|
-
"@modern-js/bff-core": "2.
|
|
61
|
-
"@modern-js/create-request": "2.
|
|
62
|
-
"@modern-js/server-utils": "2.
|
|
63
|
-
"@modern-js/utils": "2.
|
|
60
|
+
"@modern-js/bff-core": "2.49.1",
|
|
61
|
+
"@modern-js/create-request": "2.49.1",
|
|
62
|
+
"@modern-js/server-utils": "2.49.1",
|
|
63
|
+
"@modern-js/utils": "2.49.1"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@rsbuild/shared": "0.6.
|
|
66
|
+
"@rsbuild/shared": "0.6.6",
|
|
67
67
|
"@types/babel__core": "^7.20.1",
|
|
68
68
|
"@types/jest": "^29",
|
|
69
69
|
"@types/node": "^14",
|
|
@@ -72,14 +72,14 @@
|
|
|
72
72
|
"ts-jest": "^29.1.0",
|
|
73
73
|
"typescript": "^5",
|
|
74
74
|
"webpack": "^5.91.0",
|
|
75
|
-
"@modern-js/runtime": "2.
|
|
76
|
-
"@modern-js/core": "2.
|
|
77
|
-
"@modern-js/bff-runtime": "2.
|
|
78
|
-
"@modern-js/
|
|
79
|
-
"@modern-js/
|
|
80
|
-
"@modern-js/
|
|
81
|
-
"@scripts/build": "2.
|
|
82
|
-
"@scripts/jest-config": "2.
|
|
75
|
+
"@modern-js/runtime": "2.49.1",
|
|
76
|
+
"@modern-js/core": "2.49.1",
|
|
77
|
+
"@modern-js/bff-runtime": "2.49.1",
|
|
78
|
+
"@modern-js/types": "2.49.1",
|
|
79
|
+
"@modern-js/app-tools": "2.49.1",
|
|
80
|
+
"@modern-js/server-core": "2.49.1",
|
|
81
|
+
"@scripts/build": "2.49.1",
|
|
82
|
+
"@scripts/jest-config": "2.49.1"
|
|
83
83
|
},
|
|
84
84
|
"sideEffects": false,
|
|
85
85
|
"publishConfig": {
|