| 1 | // An ordinary nitro API route. `event.context.cloudflare` is the |
| 2 | // cloudflare_module preset's runtime contract: `{ request, env, context }` |
| 3 | // plus `event.context.cf` (the request's cf object). |
| 4 | export default defineEventHandler((event) => { |
| 5 | const cloudflare = event.context.cloudflare as |
| 6 | | { |
| 7 | env?: Record<string, unknown>; |
| 8 | context?: { waitUntil?: unknown }; |
| 9 | } |
| 10 | | undefined; |
| 11 | return { |
| 12 | marker: "api-route-ok", |
| 13 | secret: |
| 14 | typeof cloudflare?.env?.FIXTURE_SECRET === "string" |
| 15 | ? cloudflare.env.FIXTURE_SECRET |
| 16 | : null, |
| 17 | hasWaitUntil: typeof cloudflare?.context?.waitUntil === "function", |
| 18 | }; |
| 19 | }); |