#!/usr/bin/env bun
import index from "./index.html"

Bun.serve({
  port: 3000,
  routes: {
    "/": index,
    "/public/*": async (req) => {
      const path = new URL(req.url).pathname.replace("/public/", "")
      const file = Bun.file(`./public/${path}`)
      if (await file.exists()) {
        return new Response(file)
      }
      return new Response("Not found", { status: 404 })
    },
  },
  development: true,
})

console.log("Dev server running at http://localhost:3000")
