feat(*): init

This commit is contained in:
hh committed 2026-10-16 03:41:12 +02:00
commit d7626fd483
184 files changed
+5558

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
const ROOT = `${import.meta.dir}/build`;
const PORT = Number(Bun.env.PORT ?? 3000);
const IMMUTABLE = "/_app/immutable/";
const fallback = Bun.file(`${ROOT}/index.html`);
function headersFor(pathname: string): HeadersInit {
if (pathname.startsWith(IMMUTABLE)) {
return { "Cache-Control": "public, max-age=31536000, immutable" };
}
return { "Cache-Control": "no-cache" };
}
Bun.serve({
async fetch(request) {
const { pathname } = new URL(request.url);
if (pathname.includes("..")) {
return new Response("Bad Request", { status: 400 });
}
const file = Bun.file(`${ROOT}${pathname}`);
if (await file.exists()) {
return new Response(file, { headers: headersFor(pathname) });
}
return new Response(fallback, {
headers: {
"Cache-Control": "no-cache",
"Content-Type": "text/html; charset=utf-8",
},
});
},
idleTimeout: 30,
port: PORT,
});