refactor: split anki-connect and stats-server resolvers into modules (#169)

This commit is contained in:
2026-07-17 23:05:59 -07:00
committed by GitHub
parent 44959ed282
commit deae61b211
34 changed files with 3239 additions and 2398 deletions
@@ -0,0 +1,26 @@
import type { Hono } from 'hono';
import { createStatsStaticResponse } from './route-support.js';
export function registerStatsStaticRoutes(app: Hono, staticDir?: string): void {
if (!staticDir) return;
app.get('/assets/*', (c) => {
const response = createStatsStaticResponse(staticDir, c.req.path);
if (!response) return c.text('Not found', 404);
return response;
});
app.get('/index.html', (c) => {
const response = createStatsStaticResponse(staticDir, '/index.html');
if (!response) return c.text('Stats UI not built', 404);
return response;
});
app.get('*', (c) => {
const staticResponse = createStatsStaticResponse(staticDir, c.req.path);
if (staticResponse) return staticResponse;
const fallback = createStatsStaticResponse(staticDir, '/index.html');
if (!fallback) return c.text('Stats UI not built', 404);
return fallback;
});
}