生产环境要如何启动bff呢?
#3538
-
@modern-js/app-tools 是有暴露命令 |
Beta Was this translation helpful? Give feedback.
Answered by
yimingjfe
Apr 26, 2023
Replies: 3 comments
-
@yimingjfe 看看~ |
Beta Was this translation helpful? Give feedback.
0 replies
-
ping @yimingjfe |
Beta Was this translation helpful? Give feedback.
0 replies
-
@baranwang 目前可以通过增加一个 bootstrap 文件去启动 server,一个可参考的示例如下: const path = require("path");
const server = require("@modern-js/prod-server").default;
const pluginBFF = require("@modern-js/plugin-bff/server").default;
const pluginKoa = require("@modern-js/plugin-koa/server").default;
async function bootstrap() {
const config = {
output: {
path: ".",
},
bff: {
prefix: "/api",
},
};
try {
const app = await server({
config,
pwd: __dirname,
serverConfigFile: "modern.server-runtime.config",
plugins: [pluginBFF(), pluginKoa()],
appContext: {
sharedDirectory: path.join(__dirname, "shared"),
apiDirectory: path.join(__dirname, "api"),
lambdaDirectory: path.join(__dirname, "api/lambda"),
},
});
const port = 8080;
app.listen(port);
} catch (error) {
console.error(error);
process.exit(1);
}
}
bootstrap(); 这样只需要安装 server 相关的依赖。 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
chenjiahan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@baranwang 目前可以通过增加一个 bootstrap 文件去启动 server,一个可参考的示例如下: