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,
|
"/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) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user