The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import * as Cloudflare from "@alchemy.run/cloudflare"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import { HttpServerRequest } from "effect/http/HttpServerRequest"; |
| 4 | import * as HttpServerResponse from "effect/http/HttpServerResponse"; |
| 5 | |
| 6 | /** A Worker that reaches the Cloudflare package through `import * as Cloudflare`. */ |
| 7 | export default class CanaryWorker extends Cloudflare.Worker<CanaryWorker>()( |
| 8 | "CanaryWorker", |
| 9 | { main: import.meta.url }, |
| 10 | Effect.gen(function* () { |
| 11 | const namespace = yield* Cloudflare.KV.Namespace("CanaryNamespace"); |
| 12 | const kv = yield* Cloudflare.KV.ReadWriteNamespace(namespace); |
| 13 | return { |
| 14 | fetch: Effect.gen(function* () { |
| 15 | const request = yield* HttpServerRequest; |
| 16 | const key = new URL(request.url, "http://x").searchParams.get("key") ?? "index"; |
| 17 | const value = yield* kv.get(key); |
| 18 | return yield* HttpServerResponse.json({ value }); |
| 19 | }).pipe(Effect.orDie), |
| 20 | }; |
| 21 | }).pipe(Effect.provide(Cloudflare.KV.ReadWriteNamespaceBinding)), |
| 22 | ) {} |