MCPcopy
hub / github.com/garrytan/gstack / fetch

Function fetch

test/skill-e2e.test.ts:1333–1345  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

1331 port: 0,
1332 hostname: '127.0.0.1',
1333 fetch(req) {
1334 const url = new URL(req.url);
1335 let filePath = url.pathname === '/' ? '/index.html' : url.pathname;
1336 filePath = filePath.replace(/^\//, '');
1337 const fullPath = path.join(qaFixDir, filePath);
1338 if (!fs.existsSync(fullPath)) {
1339 return new Response('Not Found', { status: 404 });
1340 }
1341 const content = fs.readFileSync(fullPath, 'utf-8');
1342 return new Response(content, {
1343 headers: { 'Content-Type': 'text/html' },
1344 });
1345 },
1346 });
1347 });
1348

Callers 3

apiFunction · 0.70
fetchJsonFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected