Files
server/demo.ts
T
2024-03-19 22:05:08 -04:00

23 lines
414 B
TypeScript

import { serve } from "bun";
const port = 3000;
serve({
port,
fetch: async (req) => {
const url = new URL(req.url);
console.log(req.method, url.pathname, url.search);
const bod = await req.text();
bod && console.log("Body: ", bod);
const res = new Response(`hello from localhost:${port}`, {
status: 200,
});
return res;
},
});
console.log(`Serving on port ${port}!`);