(request: Request, env: Env)
| 124 | |
| 125 | export default { |
| 126 | async fetch(request: Request, env: Env): Promise<Response> { |
| 127 | const url = new URL(request.url); |
| 128 | |
| 129 | if (url.pathname === "/" || url.pathname === "") { |
| 130 | return new Response( |
| 131 | ["assets example", "", ' POST /prompt { "prompt": "..." }', ""].join("\n"), |
| 132 | { headers: { "content-type": "text/plain" } }, |
| 133 | ); |
| 134 | } |
| 135 | |
| 136 | if (url.pathname === "/prompt") { |
| 137 | if (request.method !== "POST") { |
| 138 | return new Response("method not allowed", { status: 405, headers: { allow: "POST" } }); |
| 139 | } |
| 140 | return handlePrompt(request, env); |
| 141 | } |
| 142 | |
| 143 | return new Response("not found", { status: 404 }); |
| 144 | }, |
| 145 | } satisfies ExportedHandler<Env>; |
| 146 | |
| 147 | interface PromptRequest { |
nothing calls this directly
no test coverage detected