@modern-js/plugin-bff 2.5.1-alpha.2 → 2.6.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,88 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import path from "path";
21
- import { ApiRouter } from "@modern-js/bff-core";
22
- import { API_DIR, isProd, requireExistModule } from "@modern-js/utils";
23
- import { API_APP_NAME } from "./constants";
24
- class Storage {
25
- constructor() {
26
- this.middlewares = [];
27
- }
28
- reset() {
29
- this.middlewares = [];
30
- }
31
- }
32
- const createTransformAPI = (storage) => ({
33
- addMiddleware(fn) {
34
- storage.middlewares.push(fn);
35
- }
36
- });
37
- var server_default = () => ({
38
- name: "@modern-js/plugin-bff",
39
- setup: (api) => {
40
- const storage = new Storage();
41
- const transformAPI = createTransformAPI(storage);
42
- let apiAppPath = "";
43
- return {
44
- prepare() {
45
- const { appDirectory, distDirectory } = api.useAppContext();
46
- const root = isProd() ? distDirectory : appDirectory;
47
- const apiPath = path.resolve(root || process.cwd(), API_DIR);
48
- apiAppPath = path.resolve(apiPath, API_APP_NAME);
49
- const apiMod = requireExistModule(apiAppPath);
50
- if (apiMod && typeof apiMod === "function") {
51
- apiMod(transformAPI);
52
- }
53
- },
54
- reset() {
55
- storage.reset();
56
- const newApiModule = requireExistModule(apiAppPath);
57
- if (newApiModule && typeof newApiModule === "function") {
58
- newApiModule(transformAPI);
59
- }
60
- },
61
- gather({ addAPIMiddleware }) {
62
- storage.middlewares.forEach((mid) => {
63
- addAPIMiddleware(mid);
64
- });
65
- },
66
- prepareApiServer(props, next) {
67
- const { pwd, prefix } = props;
68
- const apiDir = path.resolve(pwd, API_DIR);
69
- const appContext = api.useAppContext();
70
- const apiRouter = new ApiRouter({
71
- apiDir,
72
- prefix
73
- });
74
- const apiMode = apiRouter.getApiMode();
75
- const apiHandlerInfos = apiRouter.getApiHandlers();
76
- api.setAppContext(__spreadProps(__spreadValues({}, appContext), {
77
- apiRouter,
78
- apiHandlerInfos,
79
- apiMode
80
- }));
81
- return next(props);
82
- }
83
- };
84
- }
85
- });
86
- export {
87
- server_default as default
88
- };
@@ -1,202 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __export = (target, all) => {
25
- for (var name in all)
26
- __defProp(target, name, { get: all[name], enumerable: true });
27
- };
28
- var __copyProps = (to, from, except, desc) => {
29
- if (from && typeof from === "object" || typeof from === "function") {
30
- for (let key of __getOwnPropNames(from))
31
- if (!__hasOwnProp.call(to, key) && key !== except)
32
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
- }
34
- return to;
35
- };
36
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
37
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
- mod
39
- ));
40
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
- var __async = (__this, __arguments, generator) => {
42
- return new Promise((resolve, reject) => {
43
- var fulfilled = (value) => {
44
- try {
45
- step(generator.next(value));
46
- } catch (e) {
47
- reject(e);
48
- }
49
- };
50
- var rejected = (value) => {
51
- try {
52
- step(generator.throw(value));
53
- } catch (e) {
54
- reject(e);
55
- }
56
- };
57
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
58
- step((generator = generator.apply(__this, __arguments)).next());
59
- });
60
- };
61
- var cli_exports = {};
62
- __export(cli_exports, {
63
- default: () => cli_default
64
- });
65
- module.exports = __toCommonJS(cli_exports);
66
- var import_path = __toESM(require("path"));
67
- var import_utils = require("@modern-js/utils");
68
- var import_server_utils = require("@modern-js/server-utils");
69
- var import_bff_core = require("@modern-js/bff-core");
70
- var import_helper = require("./helper");
71
- const DEFAULT_API_PREFIX = "/api";
72
- const TS_CONFIG_FILENAME = "tsconfig.json";
73
- var cli_default = () => ({
74
- name: "@modern-js/plugin-bff",
75
- setup: (api) => {
76
- let unRegisterResolveRuntimePath = null;
77
- return {
78
- validateSchema() {
79
- return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-bff"];
80
- },
81
- config() {
82
- return {
83
- tools: {
84
- webpackChain: (chain, { name, CHAIN_ID }) => {
85
- const { appDirectory, port } = api.useAppContext();
86
- const modernConfig = api.useResolvedConfigContext();
87
- const { bff } = modernConfig || {};
88
- const prefix = (bff == null ? void 0 : bff.prefix) || DEFAULT_API_PREFIX;
89
- const rootDir = import_path.default.resolve(appDirectory, import_utils.API_DIR);
90
- chain.resolve.alias.set("@api", rootDir);
91
- const apiRouter = new import_bff_core.ApiRouter({
92
- apiDir: rootDir,
93
- prefix
94
- });
95
- const lambdaDir = apiRouter.getLambdaDir();
96
- const existLambda = apiRouter.isExistLambda();
97
- const apiRegexp = new RegExp(
98
- (0, import_utils.normalizeOutputPath)(`${rootDir}${import_path.default.sep}.*(.[tj]s)$`)
99
- );
100
- chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(apiRegexp);
101
- chain.module.rule(CHAIN_ID.RULE.JS_BFF_API).test(apiRegexp).use("custom-loader").loader(require.resolve("./loader").replace(/\\/g, "/")).options({
102
- prefix,
103
- apiDir: rootDir,
104
- lambdaDir,
105
- existLambda,
106
- port,
107
- target: name
108
- });
109
- }
110
- },
111
- source: {
112
- moduleScopes: [`./${import_utils.API_DIR}`, /create-request/]
113
- }
114
- };
115
- },
116
- modifyServerRoutes({ routes }) {
117
- const modernConfig = api.useResolvedConfigContext();
118
- const { bff } = modernConfig || {};
119
- const prefix = (bff == null ? void 0 : bff.prefix) || "/api";
120
- const prefixList = [];
121
- if (Array.isArray(prefix)) {
122
- prefixList.push(...prefix);
123
- } else {
124
- prefixList.push(prefix);
125
- }
126
- const apiServerRoutes = prefixList.map((pre) => ({
127
- urlPath: pre,
128
- isApi: true,
129
- entryPath: "",
130
- isSPA: false,
131
- isSSR: false
132
- }));
133
- if (bff == null ? void 0 : bff.enableHandleWeb) {
134
- return {
135
- routes: routes.map((route) => {
136
- return __spreadProps(__spreadValues({}, route), {
137
- isApi: true
138
- });
139
- }).concat(apiServerRoutes)
140
- };
141
- }
142
- return { routes: routes.concat(apiServerRoutes) };
143
- },
144
- collectServerPlugins({ plugins }) {
145
- plugins.push({
146
- "@modern-js/plugin-bff": "@modern-js/plugin-bff/server"
147
- });
148
- return { plugins };
149
- },
150
- beforeBuild() {
151
- return __async(this, null, function* () {
152
- if ((0, import_utils.isProd)()) {
153
- const { internalDirectory } = api.useAppContext();
154
- unRegisterResolveRuntimePath = (0, import_helper.registerModernRuntimePath)(internalDirectory);
155
- }
156
- });
157
- },
158
- afterBuild() {
159
- return __async(this, null, function* () {
160
- if (unRegisterResolveRuntimePath) {
161
- unRegisterResolveRuntimePath();
162
- }
163
- const { appDirectory, distDirectory } = api.useAppContext();
164
- const modernConfig = api.useResolvedConfigContext();
165
- const distDir = import_path.default.resolve(distDirectory);
166
- const apiDir = import_path.default.resolve(appDirectory, import_utils.API_DIR);
167
- const sharedDir = import_path.default.resolve(appDirectory, import_utils.SHARED_DIR);
168
- const tsconfigPath = import_path.default.resolve(appDirectory, TS_CONFIG_FILENAME);
169
- const sourceDirs = [];
170
- if (import_utils.fs.existsSync(apiDir)) {
171
- sourceDirs.push(apiDir);
172
- }
173
- if (import_utils.fs.existsSync(sharedDir)) {
174
- sourceDirs.push(sharedDir);
175
- }
176
- const { server } = modernConfig;
177
- const { alias, define, globalVars } = modernConfig.source;
178
- const { babel } = modernConfig.tools;
179
- if (sourceDirs.length > 0) {
180
- yield (0, import_server_utils.compile)(
181
- appDirectory,
182
- {
183
- server,
184
- alias,
185
- define,
186
- globalVars,
187
- babelConfig: babel
188
- },
189
- {
190
- sourceDirs,
191
- distDir,
192
- tsconfigPath
193
- }
194
- );
195
- }
196
- });
197
- }
198
- };
199
- }
200
- });
201
- // Annotate the CommonJS export names for ESM import in node:
202
- 0 && (module.exports = {});
@@ -1,38 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var constants_exports = {};
19
- __export(constants_exports, {
20
- API_APP_NAME: () => API_APP_NAME,
21
- BUILD_FILES: () => BUILD_FILES
22
- });
23
- module.exports = __toCommonJS(constants_exports);
24
- const API_APP_NAME = "_app";
25
- const BUILD_FILES = [
26
- "**/*.[tj]sx?",
27
- "!**/*.test.jsx?",
28
- "!**/*.test.tsx?",
29
- "!**/*.spec.jsx?",
30
- "!**/*.spec.tsx?",
31
- "!__tests__/*.tsx?",
32
- "!__tests__/*.jsx?"
33
- ];
34
- // Annotate the CommonJS export names for ESM import in node:
35
- 0 && (module.exports = {
36
- API_APP_NAME,
37
- BUILD_FILES
38
- });
@@ -1,43 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
23
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
- var helper_exports = {};
25
- __export(helper_exports, {
26
- registerModernRuntimePath: () => registerModernRuntimePath
27
- });
28
- module.exports = __toCommonJS(helper_exports);
29
- var path = __toESM(require("path"));
30
- var import_bff_core = require("@modern-js/bff-core");
31
- const serverRuntimeAlias = "@modern-js/runtime/server";
32
- const serverRuntimePath = ".runtime-exports/server";
33
- const registerModernRuntimePath = (internalDirectory) => {
34
- const paths = {
35
- [serverRuntimeAlias]: path.join(internalDirectory, serverRuntimePath)
36
- };
37
- const unRegister = (0, import_bff_core.registerPaths)(paths);
38
- return unRegister;
39
- };
40
- // Annotate the CommonJS export names for ESM import in node:
41
- 0 && (module.exports = {
42
- registerModernRuntimePath
43
- });
@@ -1,17 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var src_exports = {};
16
- module.exports = __toCommonJS(src_exports);
17
- __reExport(src_exports, require("./constants"), module.exports);
@@ -1,88 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var __async = (__this, __arguments, generator) => {
19
- return new Promise((resolve, reject) => {
20
- var fulfilled = (value) => {
21
- try {
22
- step(generator.next(value));
23
- } catch (e) {
24
- reject(e);
25
- }
26
- };
27
- var rejected = (value) => {
28
- try {
29
- step(generator.throw(value));
30
- } catch (e) {
31
- reject(e);
32
- }
33
- };
34
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
35
- step((generator = generator.apply(__this, __arguments)).next());
36
- });
37
- };
38
- var loader_exports = {};
39
- __export(loader_exports, {
40
- default: () => loader_default
41
- });
42
- module.exports = __toCommonJS(loader_exports);
43
- var import_bff_core = require("@modern-js/bff-core");
44
- var import_utils = require("@modern-js/utils");
45
- function loader(source) {
46
- return __async(this, null, function* () {
47
- this.cacheable();
48
- const callback = this.async();
49
- const draftOptions = this.getOptions();
50
- const { resourcePath } = this;
51
- const warning = `The file ${resourcePath} is not allowd to be imported in src directory, only API definition files are allowed.`;
52
- if (!draftOptions.existLambda) {
53
- import_utils.logger.warn(warning);
54
- callback(null, `throw new Error('${warning}')`);
55
- return;
56
- }
57
- const options = {
58
- prefix: Array.isArray(draftOptions.prefix) ? draftOptions.prefix[0] : draftOptions.prefix,
59
- apiDir: draftOptions.apiDir,
60
- target: draftOptions.target,
61
- port: Number(draftOptions.port),
62
- source,
63
- resourcePath
64
- };
65
- const { lambdaDir } = draftOptions;
66
- if (!resourcePath.startsWith(lambdaDir)) {
67
- import_utils.logger.warn(warning);
68
- callback(null, `throw new Error('${warning}')`);
69
- return;
70
- }
71
- if (draftOptions.fetcher) {
72
- options.fetcher = draftOptions.fetcher;
73
- }
74
- if (draftOptions.requestCreator) {
75
- options.requestCreator = draftOptions.requestCreator;
76
- }
77
- options.requireResolve = require.resolve;
78
- const result = yield (0, import_bff_core.generateClient)(options);
79
- if (result.isOk) {
80
- callback(void 0, result.value);
81
- } else {
82
- callback(void 0, `throw new Error('${result.value}')`);
83
- }
84
- });
85
- }
86
- var loader_default = loader;
87
- // Annotate the CommonJS export names for ESM import in node:
88
- 0 && (module.exports = {});
@@ -1,113 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __export = (target, all) => {
25
- for (var name in all)
26
- __defProp(target, name, { get: all[name], enumerable: true });
27
- };
28
- var __copyProps = (to, from, except, desc) => {
29
- if (from && typeof from === "object" || typeof from === "function") {
30
- for (let key of __getOwnPropNames(from))
31
- if (!__hasOwnProp.call(to, key) && key !== except)
32
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
- }
34
- return to;
35
- };
36
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
37
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
- mod
39
- ));
40
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
- var server_exports = {};
42
- __export(server_exports, {
43
- default: () => server_default
44
- });
45
- module.exports = __toCommonJS(server_exports);
46
- var import_path = __toESM(require("path"));
47
- var import_bff_core = require("@modern-js/bff-core");
48
- var import_utils = require("@modern-js/utils");
49
- var import_constants = require("./constants");
50
- class Storage {
51
- constructor() {
52
- this.middlewares = [];
53
- }
54
- reset() {
55
- this.middlewares = [];
56
- }
57
- }
58
- const createTransformAPI = (storage) => ({
59
- addMiddleware(fn) {
60
- storage.middlewares.push(fn);
61
- }
62
- });
63
- var server_default = () => ({
64
- name: "@modern-js/plugin-bff",
65
- setup: (api) => {
66
- const storage = new Storage();
67
- const transformAPI = createTransformAPI(storage);
68
- let apiAppPath = "";
69
- return {
70
- prepare() {
71
- const { appDirectory, distDirectory } = api.useAppContext();
72
- const root = (0, import_utils.isProd)() ? distDirectory : appDirectory;
73
- const apiPath = import_path.default.resolve(root || process.cwd(), import_utils.API_DIR);
74
- apiAppPath = import_path.default.resolve(apiPath, import_constants.API_APP_NAME);
75
- const apiMod = (0, import_utils.requireExistModule)(apiAppPath);
76
- if (apiMod && typeof apiMod === "function") {
77
- apiMod(transformAPI);
78
- }
79
- },
80
- reset() {
81
- storage.reset();
82
- const newApiModule = (0, import_utils.requireExistModule)(apiAppPath);
83
- if (newApiModule && typeof newApiModule === "function") {
84
- newApiModule(transformAPI);
85
- }
86
- },
87
- gather({ addAPIMiddleware }) {
88
- storage.middlewares.forEach((mid) => {
89
- addAPIMiddleware(mid);
90
- });
91
- },
92
- prepareApiServer(props, next) {
93
- const { pwd, prefix } = props;
94
- const apiDir = import_path.default.resolve(pwd, import_utils.API_DIR);
95
- const appContext = api.useAppContext();
96
- const apiRouter = new import_bff_core.ApiRouter({
97
- apiDir,
98
- prefix
99
- });
100
- const apiMode = apiRouter.getApiMode();
101
- const apiHandlerInfos = apiRouter.getApiHandlers();
102
- api.setAppContext(__spreadProps(__spreadValues({}, appContext), {
103
- apiRouter,
104
- apiHandlerInfos,
105
- apiMode
106
- }));
107
- return next(props);
108
- }
109
- };
110
- }
111
- });
112
- // Annotate the CommonJS export names for ESM import in node:
113
- 0 && (module.exports = {});