(request: Request, env: Env)
| 73 | |
| 74 | export 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 | |
| 103 | async function handleCreate(request: Request, env: Env): Promise<Response> { |
nothing calls this directly
no test coverage detected