mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-30 07:21:32 -07:00
refactor: split anki-connect and stats-server resolvers into modules (#169)
This commit is contained in:
@@ -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;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user