The best way to control Claude Code, Codex and more from any computer or phone

main
ts 29 lines 967 Bytes
Raw
1 import type { AsyncWorkerEnv } from "./stack.ts";
2
3 /**
4 * Async (non-Effect) Worker fixture for the Cloudflare Flagship binding
5 * declared via `env: { FLAGS: App }` with a `FlagshipApp` resource. `InferEnv`
6 * maps the resource to the native `Flagship` runtime binding, so the handler
7 * calls `env.FLAGS.getBooleanValue(...)` directly.
8 */
9 export default {
10 async fetch(request: Request, env: AsyncWorkerEnv): Promise<Response> {
11 const url = new URL(request.url);
12
13 if (url.pathname.startsWith("/bool")) {
14 const enabled = await env.FLAGS.getBooleanValue("test-flag", false, {
15 userId: "user-42",
16 });
17 return Response.json({ mode: "async", enabled });
18 }
19
20 if (url.pathname.startsWith("/details")) {
21 const details = await env.FLAGS.getStringDetails("nonexistent-flag", "fallback", {
22 userId: "user-42",
23 });
24 return Response.json({ mode: "async", details });
25 }
26
27 return new Response("ok");
28 },
29 };