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

Function fetch

packages/opencode/test/plugin/codex.test.ts:171–194  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

169 using server = Bun.serve({
170 port: 0,
171 async fetch(request) {
172 const url = new URL(request.url)
173 if (url.pathname === "/oauth/token") {
174 expect(await request.text()).toContain("refresh_token=refresh-old")
175 refreshRequests += 1
176 await refreshReady
177 return Response.json({
178 id_token: createTestJwt({ chatgpt_account_id: "acc-123" }),
179 access_token: "access-new",
180 refresh_token: "refresh-new",
181 expires_in: 3600,
182 })
183 }
184
185 if (url.pathname === "/backend-api/codex/responses") {
186 apiRequests.push({
187 authorization: request.headers.get("authorization"),
188 accountId: request.headers.get("ChatGPT-Account-Id"),
189 })
190 return new Response("{}", { status: 200 })
191 }
192
193 return new Response("unexpected request", { status: 500 })
194 },
195 })
196
197 const hooks = await CodexAuthPlugin(

Callers 1

openai-ws.test.tsFile · 0.70

Calls 5

createTestJwtFunction · 0.85
pushMethod · 0.80
textMethod · 0.65
jsonMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected