MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / fetch

Function fetch

apps/desktop/scripts/smoke-sidecar.ts:223–239  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

221 port: 0,
222 hostname: "127.0.0.1",
223 fetch(req) {
224 const url = new URL(req.url);
225 if (url.pathname === "/openapi.json") return Response.json(spec);
226
227 if (url.pathname === "/pets" && req.method === "GET") {
228 return Response.json(pets);
229 }
230
231 const match = /^\/pets\/(\d+)$/.exec(url.pathname);
232 if (match && req.method === "GET") {
233 const pet = pets.find((p) => p.id === Number(match[1]));
234 if (!pet) return new Response("not found", { status: 404 });
235 return Response.json(pet);
236 }
237
238 return new Response("not found", { status: 404 });
239 },
240 });
241 return { server, origin: `http://127.0.0.1:${server.port}` };
242};

Callers 1

isDaemonReachableFunction · 0.50

Calls 2

execMethod · 0.80
jsonMethod · 0.65

Tested by

no test coverage detected