| 1 | import type { AsyncWorkerEnv } from "./stack.ts"; |
| 2 | |
| 3 | /** |
| 4 | * Async (non-Effect) Worker fixture for the Cloudflare Images binding declared |
| 5 | * via `env: { MEDIA: Cloudflare.Images.Images(...) }`. `InferEnv` maps the marker to |
| 6 | * the native `cf.ImagesBinding`, so the handler calls `env.MEDIA.info(...)` |
| 7 | * directly with the request body's `ReadableStream`. |
| 8 | */ |
| 9 | export default { |
| 10 | async fetch(request: Request, env: AsyncWorkerEnv): Promise<Response> { |
| 11 | const info = await env.MEDIA.info(request.body!); |
| 12 | return Response.json({ mode: "async", ...info }); |
| 13 | }, |
| 14 | }; |