1
0
mirror of https://github.com/ZeroCatDev/ClassworksKV.git synced 2025-07-01 20:09: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:
SunWuyuan 2025-05-10 15:04:17 +08:00
parent 4c8e38e805
commit 28f6a6bc80
No known key found for this signature in database
GPG Key ID: A6A54CF66F56BB64
2 changed files with 11 additions and 9 deletions

View File

@ -36,7 +36,7 @@ jobs:
with:
images: |
sunwuyuan/classworks
ghcr.io/ClassworksDev/ClassworksServer
ghcr.io/ZeroCatDev/ClassworksServer
tags: |
type=sha
flavor: |

18
app.js
View File

@ -1,7 +1,8 @@
import createError from "http-errors";
// import createError from "http-errors";
import express from "express";
import { join } from "path";
import cookieParser from "cookie-parser";
import { join, dirname } from "path";
import { fileURLToPath } from "url";
// import cookieParser from "cookie-parser";
import logger from "morgan";
import bodyParser from "body-parser";
import errorHandler from "./middleware/errorHandler.js";
@ -16,22 +17,23 @@ import cors from "cors";
app.options("*", cors());
app.use(cors());
//全局变量
global.dirname = import.meta.dirname;
// 获取当前文件的目录路径
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// 初始化 readme
initReadme();
// view engine setup
app.set("views", join(dirname, "views"));
app.set("views", join(__dirname, "views"));
app.set("view engine", "ejs");
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(logger("dev"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(join(dirname, "public")));
// app.use(cookieParser());
// app.use(express.static(join(__dirname, "public")));
// 添加请求超时处理中间件
app.use((req, res, next) => {