mirror of
https://github.com/ZeroCatDev/ClassworksKV.git
synced 2025-07-02 04:39:23 +00:00
Update app.js
to use fileURLToPath
for directory resolution and comment out unused imports. Modify Docker image reference in workflow configuration for deployment consistency.
This commit is contained in:
parent
4c8e38e805
commit
28f6a6bc80
2
.github/workflows/docker-image.yml
vendored
2
.github/workflows/docker-image.yml
vendored
@ -36,7 +36,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
sunwuyuan/classworks
|
sunwuyuan/classworks
|
||||||
ghcr.io/ClassworksDev/ClassworksServer
|
ghcr.io/ZeroCatDev/ClassworksServer
|
||||||
tags: |
|
tags: |
|
||||||
type=sha
|
type=sha
|
||||||
flavor: |
|
flavor: |
|
||||||
|
18
app.js
18
app.js
@ -1,7 +1,8 @@
|
|||||||
import createError from "http-errors";
|
// import createError from "http-errors";
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import { join } from "path";
|
import { join, dirname } from "path";
|
||||||
import cookieParser from "cookie-parser";
|
import { fileURLToPath } from "url";
|
||||||
|
// import cookieParser from "cookie-parser";
|
||||||
import logger from "morgan";
|
import logger from "morgan";
|
||||||
import bodyParser from "body-parser";
|
import bodyParser from "body-parser";
|
||||||
import errorHandler from "./middleware/errorHandler.js";
|
import errorHandler from "./middleware/errorHandler.js";
|
||||||
@ -16,22 +17,23 @@ import cors from "cors";
|
|||||||
app.options("*", cors());
|
app.options("*", cors());
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
|
|
||||||
//全局变量
|
// 获取当前文件的目录路径
|
||||||
global.dirname = import.meta.dirname;
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = dirname(__filename);
|
||||||
|
|
||||||
// 初始化 readme
|
// 初始化 readme
|
||||||
initReadme();
|
initReadme();
|
||||||
|
|
||||||
// view engine setup
|
// view engine setup
|
||||||
app.set("views", join(dirname, "views"));
|
app.set("views", join(__dirname, "views"));
|
||||||
app.set("view engine", "ejs");
|
app.set("view engine", "ejs");
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
app.use(logger("dev"));
|
app.use(logger("dev"));
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use(express.urlencoded({ extended: false }));
|
app.use(express.urlencoded({ extended: false }));
|
||||||
app.use(cookieParser());
|
// app.use(cookieParser());
|
||||||
app.use(express.static(join(dirname, "public")));
|
// app.use(express.static(join(__dirname, "public")));
|
||||||
|
|
||||||
// 添加请求超时处理中间件
|
// 添加请求超时处理中间件
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user