mirror of
https://github.com/lyz05/danmaku.git
synced 2026-02-02 17:59:53 +08:00
refactor: Node18支持
This commit is contained in:
11
app.js
11
app.js
@@ -7,12 +7,13 @@ const compression = require('compression');
|
||||
// 引入环境变量
|
||||
require("dotenv")
|
||||
.config();
|
||||
|
||||
// 引入一个个路由模块
|
||||
const danmakuRouter = require("./routes/danmaku.mjs").default;
|
||||
const app = express();
|
||||
// 加载路由
|
||||
// 引入一个个路由模块
|
||||
// const danmakuRouter = require("./routes/danmaku.mjs").default;
|
||||
async function loadRouter() {
|
||||
const { default: danmakuRouter } = await import('./routes/danmaku.mjs');
|
||||
app.use("/", danmakuRouter);
|
||||
|
||||
// 启用gzip压缩
|
||||
app.use(compression());
|
||||
|
||||
@@ -52,5 +53,7 @@ app.use(function (err, req, res) {
|
||||
res.status(err.status || 500);
|
||||
res.render("error");
|
||||
});
|
||||
}
|
||||
loadRouter();
|
||||
|
||||
module.exports = app;
|
||||
|
||||
Reference in New Issue
Block a user