MCPcopy Index your code
hub / github.com/anomalyco/opencode / fetch

Function fetch

packages/opencode/test/session/llm.test.ts:642–659  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 2

jsonMethod · 0.65
responseMethod · 0.45

Tested by

no test coverage detected