添加 HTTP 请求日志
This commit is contained in:
@@ -13,9 +13,22 @@ import fs from 'node:fs/promises'
|
||||
// @ts-types="npm:@types/express-fileupload"
|
||||
import fileUpload from 'express-fileupload'
|
||||
import FileUploadMiddleware from "./fileupload-middleware.ts"
|
||||
import chalk from "chalk"
|
||||
|
||||
export default async function createLingChairServer() {
|
||||
const app = express()
|
||||
|
||||
app.use((req, res, next) => {
|
||||
const start = Date.now()
|
||||
|
||||
res.on('finish', () => {
|
||||
const duration = Date.now() - start
|
||||
console.log(`${chalk.grey('[求]')} ${req.socket.remoteAddress} <- ${req.originalUrl} [${res.statusCode}] (with ${req.method}, ${duration}ms)`)
|
||||
})
|
||||
|
||||
next()
|
||||
})
|
||||
|
||||
app.use('/', express.static(config.data_path + '/page_compiled'))
|
||||
app.use(cookieParser())
|
||||
app.get('/config.json', (req, res) => {
|
||||
@@ -49,7 +62,7 @@ export default async function createLingChairServer() {
|
||||
try {
|
||||
await fs.rmdir(config.data_path + '/upload_cache')
|
||||
// deno-lint-ignore no-empty
|
||||
} catch (_) {}
|
||||
} catch (_) { }
|
||||
app.use(fileUpload({
|
||||
limits: { fileSize: 2 * 1024 * 1024 * 1024 },
|
||||
useTempFiles: true,
|
||||
|
||||
Reference in New Issue
Block a user