(req)
| 640 | state.server = Bun.serve({ |
| 641 | port: 0, |
| 642 | async fetch(req) { |
| 643 | const next = state.queue.shift() |
| 644 | if (!next) { |
| 645 | return new Response("unexpected request", { status: 500 }) |
| 646 | } |
| 647 | |
| 648 | const url = new URL(req.url) |
| 649 | const body = (await req.json()) as Record<string, unknown> |
| 650 | next.resolve({ url, headers: req.headers, body }) |
| 651 | |
| 652 | if (!url.pathname.endsWith(next.path)) { |
| 653 | return new Response("not found", { status: 404 }) |
| 654 | } |
| 655 | |
| 656 | return typeof next.response === "function" |
| 657 | ? next.response(req, { url, headers: req.headers, body }) |
| 658 | : next.response |
| 659 | }, |
| 660 | }) |
| 661 | }) |
| 662 |
no test coverage detected