| 17 | |
| 18 | export 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 | |
| 42 | export function createExports(manifest: ConstructorParameters<typeof App>[0]) { |