feat(index): add back hot stats (#14664)

This commit is contained in:
Tony
2024-03-05 13:55:39 +08:00
committed by GitHub
parent 0f51d2f93a
commit d17ebe81d0
7 changed files with 128 additions and 26 deletions
+11
View File
@@ -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++;
}