MCPcopy
hub / github.com/lissy93/web-check / fetchAndProcess

Function fetchAndProcess

src/web-check-live/jobs/registry.ts:47–54  ·  view source on GitHub ↗
(path: string, process: (raw: any) => any = (r) => r)

Source from the content-addressed store, hash-verified

45// Build a fetcher that hits a local /api path then maps the success body
46const fetchAndProcess =
47 (path: string, process: (raw: any) => any = (r) => r) =>
48 async (ctx: JobContext) => {
49 const target = path.includes('${ip}') ? ctx.ipAddress || '' : ctx.address;
50 const url = path.replace(/\$\{(ip|url)\}/g, target);
51 const res = await fetch(`${ctx.api}/${url}`, { signal: ctx.signal });
52 const raw = await parseJson(res);
53 return raw?.error ? raw : process(raw);
54 };
55
56const card = (
57 id: string,

Callers 1

registry.tsFile · 0.85

Calls 1

parseJsonFunction · 0.90

Tested by

no test coverage detected