Server options (port defaults to $PORT || 8080)
Start a fast HTTP server.
Bun.serve({
fetch(req: Request): Response | Promise<Response> {
return new Response("Hello World!");
},
// Optional port number - the default value is 3000
port: process.env.PORT || 3000,
});
Send a file
Bun.serve({
fetch(req: Request): Response | Promise<Response> {
return new Response(Bun.file("./package.json"));
},
// Optional port number - the default value is 3000
port: process.env.PORT || 3000,
});
Server options (port defaults to $PORT || 8080)
Generated using TypeDoc
Start a fast HTTP server.
Example
Example
Send a file