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

Function fetch

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

Source from the content-addressed store, hash-verified

234 port: 0,
235 hostname: "127.0.0.1",
236 fetch(req) {
237 const url = new URL(req.url);
238 if (url.pathname === "/openapi.json") return Response.json(spec);
239
240 if (url.pathname === "/pets" && req.method === "GET") {
241 return Response.json(pets);
242 }
243
244 const match = /^\/pets\/(\d+)$/.exec(url.pathname);
245 if (match && req.method === "GET") {
246 const pet = pets.find((p) => p.id === Number(match[1]));
247 if (!pet) return new Response("not found", { status: 404 });
248 return Response.json(pet);
249 }
250
251 return new Response("not found", { status: 404 });
252 },
253 });
254 return { server, origin: `http://127.0.0.1:${server.port}` };
255};

Callers 2

isDaemonReachableFunction · 0.50

Calls 2

execMethod · 0.80
jsonMethod · 0.65

Tested by

no test coverage detected