restructure backend

This commit is contained in:
2026-01-16 18:07:23 +01:00
parent ebcc33b1f7
commit cd9d2e9900
21 changed files with 4323 additions and 69 deletions

18
src/api.ts Normal file
View File

@@ -0,0 +1,18 @@
export async function getImage(req: Bun.BunRequest<"/api/cards/:id">) {
const { id } = req.params;
let file = Bun.file(`images/cards/${id}.png`);
let type = "png";
if (!(await file.exists())) {
file = Bun.file(`images/cards/${id}.jpg`);
type = "jpg";
if (!(await file.exists())) {
file = Bun.file("images/cards/placeholder.png");
type = "png";
console.error(`File for image ${id} does not exist, serving placeholder`);
}
}
return new Response(file, { headers: { "Content-Type": `image/${type}` }, status: 200 });
}