optimize directory structure

This commit is contained in:
DIYgod
2018-12-26 18:35:10 +08:00
parent c68251e461
commit 38a90e29b0
475 changed files with 52 additions and 52 deletions

24
lib/middleware/debug.js Normal file
View File

@@ -0,0 +1,24 @@
module.exports = async (ctx, next) => {
if (!ctx.debug.routes[ctx.request.path]) {
ctx.debug.routes[ctx.request.path] = 0;
}
ctx.debug.routes[ctx.request.path]++;
const ip = ctx.ips[0] || ctx.ip;
if (!ctx.debug.ips[ip]) {
ctx.debug.ips[ip] = 0;
}
ctx.debug.ips[ip]++;
if (ctx.request.path !== '/') {
ctx.debug.request++;
}
await next();
if (ctx.request.path !== '/') {
if (ctx.response.get('X-Koa-Redis-Cache') || ctx.response.get('X-Koa-Memory-Cache')) {
ctx.debug.hitCache++;
}
}
};