@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, 03:37 UTC

main
ts 28 lines 919 Bytes
Raw
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 import { Gateway } from "./Gateway.ts";
6
7 export default class TestWorker extends Cloudflare.Worker<TestWorker>()(
8 "AiGatewayTestWorker",
9 {
10 main: import.meta.url,
11 },
12 Effect.gen(function* () {
13 const aiGateway = yield* Cloudflare.AI.QueryGateway(Gateway);
14
15 return {
16 fetch: Effect.gen(function* () {
17 const request = yield* HttpServerRequest;
18
19 if (request.url.startsWith("/url")) {
20 const url = yield* aiGateway.getUrl().pipe(Effect.orDie);
21 return yield* HttpServerResponse.json({ url });
22 }
23
24 return HttpServerResponse.text("ok");
25 }),
26 };
27 }).pipe(Effect.provide(Cloudflare.AI.QueryGatewayBinding)),
28 ) {}