pushes on tangled sites.wisp.place/zzstoatzz.io/punch
fun tangled
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 24 lines 885 B view raw
1// local dev server — serves public/ as-is. in production the `public/` directory 2// is what you ship to any static host; no runtime required. 3 4import { join } from "node:path"; 5 6const ROOT = new URL("..", import.meta.url).pathname; 7const PUBLIC_DIR = join(ROOT, "public"); 8const PORT = Number(process.env.PORT ?? 4747); 9 10const server = Bun.serve({ 11 port: PORT, 12 async fetch(req) { 13 const { pathname } = new URL(req.url); 14 const rel = pathname === "/" ? "/index.html" : pathname; 15 const asset = join(PUBLIC_DIR, rel); 16 if (!asset.startsWith(PUBLIC_DIR)) return new Response("bad path", { status: 400 }); 17 18 const f = Bun.file(asset); 19 if (!(await f.exists())) return new Response("not found", { status: 404 }); 20 return new Response(f, { headers: { "cache-control": "no-store" } }); 21 }, 22}); 23 24console.log(`punch dev server → http://localhost:${server.port}`);