mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
移除koa-morgan
This commit is contained in:
1 parent
d458c231a4
commit
9e225f5daa
2 files changed
+17
-8
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.13.8",
|
"version": "2.13.9",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
"js-yaml": "^3.13.1",
|
"js-yaml": "^3.13.1",
|
||||||
"koa": "^2.13.0",
|
"koa": "^2.13.0",
|
||||||
"koa-body": "^4.2.0",
|
"koa-body": "^4.2.0",
|
||||||
"koa-morgan": "^1.0.1",
|
|
||||||
"koa-router": "^9.4.0",
|
"koa-router": "^9.4.0",
|
||||||
"koa-static-cache": "^5.1.3",
|
"koa-static-cache": "^5.1.3",
|
||||||
"lodash": "^4.17.20",
|
"lodash": "^4.17.20",
|
||||||
@@ -40,7 +39,6 @@
|
|||||||
"@types/fs-extra": "^9.0.1",
|
"@types/fs-extra": "^9.0.1",
|
||||||
"@types/js-yaml": "^3.12.5",
|
"@types/js-yaml": "^3.12.5",
|
||||||
"@types/koa": "^2.11.4",
|
"@types/koa": "^2.11.4",
|
||||||
"@types/koa-morgan": "^1.0.4",
|
|
||||||
"@types/koa-router": "^7.4.1",
|
"@types/koa-router": "^7.4.1",
|
||||||
"@types/koa-static-cache": "^5.1.0",
|
"@types/koa-static-cache": "^5.1.0",
|
||||||
"@types/lodash": "^4.14.161",
|
"@types/lodash": "^4.14.161",
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import http from 'http';
|
|||||||
import moment from 'moment-timezone';
|
import moment from 'moment-timezone';
|
||||||
import { isSafeInteger, Dictionary, filter } from 'lodash';
|
import { isSafeInteger, Dictionary, filter } from 'lodash';
|
||||||
import { ObjectID } from 'mongodb';
|
import { ObjectID } from 'mongodb';
|
||||||
import Koa from 'koa';
|
import Koa, { Context } from 'koa';
|
||||||
import morgan from 'koa-morgan';
|
|
||||||
import Body from 'koa-body';
|
import Body from 'koa-body';
|
||||||
import Router from 'koa-router';
|
import Router from 'koa-router';
|
||||||
import cache from 'koa-static-cache';
|
import cache from 'koa-static-cache';
|
||||||
@@ -806,9 +805,21 @@ export function Connection(
|
|||||||
export async function start() {
|
export async function start() {
|
||||||
const port = await system.get('server.port');
|
const port = await system.get('server.port');
|
||||||
if (argv.debug) {
|
if (argv.debug) {
|
||||||
app.use(morgan(':method :url :status :res[content-length] - :response-time ms', {
|
app.use(async (ctx: Context, next: Function) => {
|
||||||
skip: (req, res) => res.hasHeader('nolog'),
|
const startTime = new Date().getTime();
|
||||||
}));
|
await next();
|
||||||
|
const endTime = new Date().getTime();
|
||||||
|
if (ctx.response.headers.nolog) return;
|
||||||
|
ctx._remoteAddress = ctx.request.ip;
|
||||||
|
const status = ctx.response.status;
|
||||||
|
const color = status >= 500 ? 31 // red
|
||||||
|
: status >= 400 ? 33 // yellow
|
||||||
|
: status >= 300 ? 36 // cyan
|
||||||
|
: status >= 200 ? 32 // green
|
||||||
|
: 0; // no color
|
||||||
|
logger.debug(`\
|
||||||
|
\x1b[0m${ctx.request.method} ${ctx.request.path} \x1b[${color}m${ctx.response.status}\x1b[0m ${endTime - startTime}ms ${ctx.response.length}\x1b[0m`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
app.use(async (ctx, next) => {
|
app.use(async (ctx, next) => {
|
||||||
const xff = await system.get('server.xff');
|
const xff = await system.get('server.xff');
|
||||||
|
|||||||
Reference in new issue
Block a user