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

Function fetch

design/src/serve.ts:75–106  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

73 port,
74 hostname,
75 fetch(req) {
76 const url = new URL(req.url);
77
78 // Serve the comparison board HTML. The board JS uses relative paths
79 // (./api/feedback, ./api/progress) and a location.protocol
80 // feature-detect, so no per-request injection is needed.
81 if (
82 req.method === "GET" &&
83 (url.pathname === "/" || url.pathname === "/index.html")
84 ) {
85 return new Response(htmlContent, {
86 headers: { "Content-Type": "text/html; charset=utf-8" },
87 });
88 }
89
90 // Progress polling endpoint (used by board during regeneration)
91 if (req.method === "GET" && url.pathname === "/api/progress") {
92 return Response.json({ status: state });
93 }
94
95 // Feedback submission from the board
96 if (req.method === "POST" && url.pathname === "/api/feedback") {
97 return handleFeedback(req);
98 }
99
100 // Reload endpoint (used by the agent to swap in new board HTML)
101 if (req.method === "POST" && url.pathname === "/api/reload") {
102 return handleReload(req);
103 }
104
105 return new Response("Not found", { status: 404 });
106 },
107 });
108
109 const actualPort = server.port;

Callers 15

checkMockupFunction · 0.70
diffMockupsFunction · 0.70
callImageGenerationFunction · 0.70
publishBoardFunction · 0.70
evolveFunction · 0.70
analyzeScreenshotFunction · 0.70
callWithThreadingFunction · 0.70
callFreshFunction · 0.70
healthCheckFunction · 0.70
extractDesignLanguageFunction · 0.70

Calls 2

handleFeedbackFunction · 0.85
handleReloadFunction · 0.85

Tested by 1

fetchWithFunction · 0.40