MCPcopy Create free account
hub / github.com/cloudflare/computer / fetch

Function fetch

examples/artifacts/src/index.ts:75–100  ·  view source on GitHub ↗
(request: Request, env: Env)

Source from the content-addressed store, hash-verified

73
74export default {
75 async fetch(request: Request, env: Env): Promise<Response> {
76 const url = new URL(request.url);
77
78 if (url.pathname === "/" && request.method === "GET") {
79 return new Response(
80 [
81 "workspace artifacts example",
82 "",
83 "POST /create",
84 ' body: { "name": "my-worker" }',
85 "",
86 "curl -X POST https://<worker>/create \\",
87 " -H 'content-type: application/json' \\",
88 ' -d \'{"name":"my-worker"}\'',
89 "",
90 "Builds examples/worker-shell in a Workspace and pushes it to a",
91 "new Cloudflare Artifacts repo.",
92 ].join("\n"),
93 { headers: { "content-type": "text/plain; charset=utf-8" } },
94 );
95 }
96
97 if (url.pathname === "/create") return handleCreate(request, env);
98
99 return new Response("not found", { status: 404 });
100 },
101} satisfies ExportedHandler<Env>;
102
103async function handleCreate(request: Request, env: Env): Promise<Response> {

Callers

nothing calls this directly

Calls 1

handleCreateFunction · 0.85

Tested by

no test coverage detected