aboutsummaryrefslogtreecommitdiff
path: root/examples/http-stop.ts
blob: a9ee90892647a4de0511e8c646445b2eb126fff6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
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);