MCPcopy Create free account
hub / github.com/acoyfellow/cloudbox / fetch

Function fetch

web/src/worker.ts:19–39  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

17
18export default {
19 async fetch(request: Request): Promise<Response> {
20 const url = new URL(request.url);
21 if (url.pathname === "/api/health") {
22 return new Response(JSON.stringify({ ok: true, name: "cloudbox" }), {
23 headers: { "content-type": "application/json; charset=utf-8" },
24 });
25 }
26 if (url.pathname === "/api/computers") {
27 return new Response(JSON.stringify({ error: "bad_spec", detail: "expected a ComputerSpec body" }), {
28 status: 400,
29 headers: { "content-type": "application/json; charset=utf-8" },
30 });
31 }
32 if (url.pathname === "/api/brief") {
33 return new Response(JSON.stringify({ error: "bad_request", detail: "brief required" }), {
34 status: 400,
35 headers: { "content-type": "application/json; charset=utf-8" },
36 });
37 }
38 return new Response("not found", { status: 404 });
39 },
40};
41
42export function createExports(manifest: ConstructorParameters<typeof App>[0]) {

Callers 5

runRawFunction · 0.50
runRepoFunction · 0.50
materializeFunction · 0.50
fetchJsonFunction · 0.50
postJsonFunction · 0.50

Calls 1

fetchMethod · 0.45

Tested by

no test coverage detected