MCPcopy Create free account
hub / github.com/ShipSecAI/studio / fetch

Function fetch

worker/src/components/core/__tests__/http-request.test.ts:32–69  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

30 server = Bun.serve({
31 port,
32 async fetch(req) {
33 const url = new URL(req.url);
34
35 if (url.pathname === '/json' && req.method === 'POST') {
36 const body = await req.json();
37 return Response.json({ received: body, headers: Object.fromEntries(req.headers) });
38 }
39
40 if (url.pathname === '/status/404') {
41 return new Response('Not Found', { status: 404 });
42 }
43
44 if (url.pathname === '/status/500') {
45 return new Response('Server Error', { status: 500 });
46 }
47
48 if (url.pathname === '/text') {
49 return new Response('Hello World', {
50 headers: { 'Content-Type': 'text/plain' },
51 });
52 }
53
54 if (url.pathname === '/headers') {
55 return Response.json({ headers: Object.fromEntries(req.headers) });
56 }
57
58 if (url.pathname === '/delete' && req.method === 'DELETE') {
59 return Response.json({ deleted: true });
60 }
61
62 if (url.pathname === '/timeout') {
63 // Sleep for 200ms
64 await new Promise((r) => setTimeout(r, 200));
65 return new Response('Finally');
66 }
67
68 return new Response('OK');
69 },
70 });
71 });
72

Callers 15

handleSubmitFunction · 0.85
loadFunction · 0.85
connectMethod · 0.85
LocalAuthProviderFunction · 0.85
apiRequestFunction · 0.85
fetchWithHeadersFunction · 0.85
listGroupsFunction · 0.85
listTemplatesFunction · 0.85
getGroupFunction · 0.85
getGroupServersFunction · 0.85
getGroupHealthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected