improve static alert object handling

This commit is contained in:
2025-12-01 20:44:02 +01:00
parent d501277511
commit a86ea710cb

View File

@@ -26,21 +26,14 @@ export default Bun.serve({
"/chat/getEmotes": getExternalEmotes, "/chat/getEmotes": getExternalEmotes,
"/alerts": alerts, "/alerts": alerts,
"/alerts/public/:filename": async (req) => { "/alerts/public/*": async (req) => {
const target = req.params.filename; const url = new URL(req.url);
const file = Bun.file(`${import.meta.dir}/alerts/www/public/${target}`); const path = url.pathname.slice("/alerts/public/".length);
const file = Bun.file(`${import.meta.dir}/alerts/www/public/${path}`);
if (!(await file.exists())) if (!(await file.exists()))
return new Response(`${target} not found`, { status: 404 }); return new Response(`404: ${url.pathname} not found`, {
return new Response(file); status: 404,
}, });
// 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(file); return new Response(file);
}, },
"/": async (req, srv) => { "/": async (req, srv) => {