@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 32 lines 1.21 KB
Raw
1 import { bindService } from "@alchemy.run/railway/Bind";
2 import { Function } from "@alchemy.run/railway/Function";
3 import { enableRailwayRpc } from "@alchemy.run/railway/rpc-server";
4 import * as Effect from "effect/Effect";
5 import { HttpServerRequest } from "effect/http/HttpServerRequest";
6 import * as HttpServerResponse from "effect/http/HttpServerResponse";
7 import { Api } from "./rpc-api-tag.ts";
8 import { Partition, Site } from "./rpc-shared.ts";
9
10 /**
11 * Tagged Function that hosts `greet` and binds the tagged {@link Api}
12 * Service. `GET /` is local so the public probe does not deadlock on
13 * private-mesh RPC; `GET /pong` calls `api.ping()`.
14 */
15 export default class Query extends Function<Query>()(
16 "Query",
17 { project: Site, environment: Partition, main: import.meta.url },
18 Effect.gen(function* () {
19 enableRailwayRpc();
20 const api = yield* bindService(Api);
21 return {
22 greet: (name: string) => Effect.succeed(`hello ${name}`),
23 fetch: Effect.gen(function* () {
24 const request = yield* HttpServerRequest;
25 if (request.url.includes("/pong")) {
26 return HttpServerResponse.text(yield* api.ping());
27 }
28 return HttpServerResponse.text("query");
29 }),
30 };
31 }),
32 ) {}