@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

main
ts 24 lines 860 Bytes
Raw
1 import * as Cloudflare from "@alchemy.run/cloudflare";
2 import * as Effect from "effect/Effect";
3 import { TestDatabase } from "./database.ts";
4 import { d1Routes } from "./routes.ts";
5
6 /**
7 * Effect-native Worker fixture. Binds the shared {@link TestDatabase} via
8 * `Cloudflare.D1.QueryDatabase(...)` during Init (with `QueryDatabaseBinding`
9 * provided to the worker effect) and delegates to the shared
10 * {@link d1Routes}, stamping rows with `style = "effect"`.
11 */
12 export default class D1EffectWorker extends Cloudflare.Worker<D1EffectWorker>()(
13 "D1EffectWorker",
14 {
15 main: import.meta.url,
16 },
17 Effect.gen(function* () {
18 const database = yield* TestDatabase;
19 const db = yield* Cloudflare.D1.QueryDatabase(database);
20 return {
21 fetch: d1Routes(db, "effect"),
22 };
23 }).pipe(Effect.provide(Cloudflare.D1.QueryDatabaseBinding)),
24 ) {}