import { file } from "bun"; import { join } from "path"; import { PUBLIC_DIR } from "../config"; // Serve static files export async function handleStatic(path: string): Promise { if (path === "/" || path === "/index.html" || path.startsWith("/listen/")) { return new Response(file(join(PUBLIC_DIR, "index.html")), { headers: { "Content-Type": "text/html" }, }); } if (path === "/styles.css") { return new Response(file(join(PUBLIC_DIR, "styles.css")), { headers: { "Content-Type": "text/css" }, }); } if (path.endsWith(".js")) { const jsFile = file(join(PUBLIC_DIR, path.slice(1))); if (await jsFile.exists()) { return new Response(jsFile, { headers: { "Content-Type": "application/javascript" }, }); } } return null; }