Files
bun.sh/examples/http-stop.ts
2022-04-11 05:59:39 -07:00

13 lines
235 B
TypeScript

import { serve } from "bun";
const server = serve({
fetch(req) {
return new Response(`Pending requests count: ${this.pendingRequests}`);
},
});
// Stop the server after 5 seconds
setTimeout(() => {
server.stop();
}, 5000);