feat(index): add back hot stats (#14664)
This commit is contained in:
@@ -4,6 +4,11 @@ import { getDebugInfo, setDebugInfo } from '@/utils/debug-info';
|
||||
const middleware: MiddlewareHandler = async (ctx, next) => {
|
||||
{
|
||||
const debug = getDebugInfo();
|
||||
if (!debug.paths[ctx.req.path]) {
|
||||
debug.paths[ctx.req.path] = 0;
|
||||
}
|
||||
debug.paths[ctx.req.path]++;
|
||||
|
||||
debug.request++;
|
||||
setDebugInfo(debug);
|
||||
}
|
||||
@@ -12,6 +17,12 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
|
||||
|
||||
{
|
||||
const debug = getDebugInfo();
|
||||
const hasMatchedRoute = ctx.req.routePath !== '/*';
|
||||
if (!debug.routes[ctx.req.routePath] && hasMatchedRoute) {
|
||||
debug.routes[ctx.req.routePath] = 0;
|
||||
}
|
||||
hasMatchedRoute && debug.routes[ctx.req.routePath]++;
|
||||
|
||||
if (ctx.res.headers.get('RSSHub-Cache-Status')) {
|
||||
debug.hitCache++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user