From a86ea710cbf9dc640dcee0344d42822bef3d9428 Mon Sep 17 00:00:00 2001 From: qwerinope Date: Mon, 1 Dec 2025 20:44:02 +0100 Subject: [PATCH] improve static alert object handling --- src/web/index.ts | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/web/index.ts b/src/web/index.ts index 922bb17..63513ac 100644 --- a/src/web/index.ts +++ b/src/web/index.ts @@ -26,21 +26,14 @@ export default Bun.serve({ "/chat/getEmotes": getExternalEmotes, "/alerts": alerts, - "/alerts/public/:filename": async (req) => { - const target = req.params.filename; - const file = Bun.file(`${import.meta.dir}/alerts/www/public/${target}`); + "/alerts/public/*": async (req) => { + const url = new URL(req.url); + const path = url.pathname.slice("/alerts/public/".length); + const file = Bun.file(`${import.meta.dir}/alerts/www/public/${path}`); if (!(await file.exists())) - return new Response(`${target} not found`, { status: 404 }); - return new Response(file); - }, - // TODO: make this nicer, i don't want to redefine the same thing here every time - "/alerts/public/explosions/:filename": async (req) => { - const target = req.params.filename; - const file = Bun.file( - `${import.meta.dir}/alerts/www/public/explosions/${target}`, - ); - if (!(await file.exists())) - return new Response(`${target} not found`, { status: 404 }); + return new Response(`404: ${url.pathname} not found`, { + status: 404, + }); return new Response(file); }, "/": async (req, srv) => {