1import { serve } from "bun"; 2import index from "./index.html"; 3 4const server = serve({ 5 routes: { 6 "/.well-known/atproto-did": async () => { 7 return new Response("did:plc:ttdrpj45ibqunmfhdsb4zdwq", { 8 headers: { 9 "Content-Type": "text/plain", 10 }, 11 }); 12 }, 13 14 // Serve index.html for all unmatched routes. 15 "/*": index, 16 17 "/api/hello": { 18 async GET(req) { 19 return Response.json({ 20 message: "Hello, world!", 21 method: "GET", 22 }); 23 }, 24 async PUT(req) { 25 return Response.json({ 26 message: "Hello, world!", 27 method: "PUT", 28 }); 29 }, 30 }, 31 32 "/api/hello/:name": async req => { 33 const name = req.params.name; 34 return Response.json({ 35 message: `Hello, ${name}!`, 36 }); 37 }, 38 }, 39 40 development: process.env.NODE_ENV !== "production" && { 41 // Enable browser hot reloading in development 42 hmr: true, 43 44 // Echo console logs from the browser to the server 45 console: true, 46 }, 47}); 48 49console.log(`🚀 Server running at ${server.url}`);