| 1 | import index from "./index.html"; |
| 2 | |
| 3 | Bun.serve({ |
| 4 | routes: { |
| 5 | "/": index, |
| 6 | "/assets/*": async (req) => { |
| 7 | const url = new URL(req.url); |
| 8 | const file = Bun.file(`./public${url.pathname}`); |
| 9 | return new Response(file); |
| 10 | }, |
| 11 | "/*": async (req) => { |
| 12 | const url = new URL(req.url); |
| 13 | const file = Bun.file(`./public${url.pathname}`); |
| 14 | if (await file.exists()) { |
| 15 | return new Response(file); |
| 16 | } |
| 17 | return new Response("Not found", { status: 404 }); |
| 18 | }, |
| 19 | }, |
| 20 | development: { |
| 21 | hmr: true, |
| 22 | console: true, |
| 23 | }, |
| 24 | }); |
| 25 | |
| 26 | console.log("Dino server running at http://localhost:3000"); |