mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 08:41:39 +01:00
improve static alert object handling
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user