mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-27 16:49:51 -07:00
27 lines
899 B
TypeScript
27 lines
899 B
TypeScript
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;
|
|
});
|
|
}
|