MCPcopy Index your code
hub / github.com/MrgSub/opencode-debug / fetch

Function fetch

src/index.ts:161–186  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

159 return Bun.serve({
160 port,
161 async fetch(req) {
162 const url = new URL(req.url);
163
164 // Handle CORS preflight requests
165 if (req.method === "OPTIONS") {
166 return new Response(null, { status: 204, headers: corsHeaders });
167 }
168
169 if (url.pathname === config.healthEndpoint && req.method === "GET") {
170 return jsonResponse({ status: "ok" });
171 }
172
173 if (url.pathname === config.endpoint && req.method === "POST") {
174 const body = await req.json().catch(() => null);
175 if (!body || !body.label) {
176 return new Response("Missing required field: label", {
177 status: 400,
178 headers: corsHeaders,
179 });
180 }
181 await appendToLog(logPath, body.label, body.data);
182 return jsonResponse({ received: true });
183 }
184
185 return new Response("Not found", { status: 404, headers: corsHeaders });
186 },
187 });
188}
189

Callers

nothing calls this directly

Calls 2

jsonResponseFunction · 0.85
appendToLogFunction · 0.70

Tested by

no test coverage detected