@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 34 lines 1.21 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
2 import * as Effect from "effect/Effect";
3 import { HttpServerRequest } from "effect/http/HttpServerRequest";
4 import * as HttpServerResponse from "effect/http/HttpServerResponse";
5 import * as Stream from "effect/Stream";
6
7 /**
8 * Private Effect-native Cloud Run Service (invoker IAM enforced).
9 * Called by {@link ./invoke-caller.ts} from {@link ../InvokeService.test.ts}.
10 */
11 export default class InvokeCallee extends GCP.Function<InvokeCallee>()(
12 "InvokeCallee",
13 {
14 main: import.meta.url,
15 location: "us-central1",
16 },
17 Effect.gen(function* () {
18 return {
19 // Served on `/__rpc__/*` behind Cloud Run's IAM invoker check.
20 add: (a: number, b: number) => Effect.succeed(a + b),
21 countdown: (from: number) => Stream.range(1, from).pipe(Stream.map((n) => from - n + 1)),
22 fetch: Effect.gen(function* () {
23 const request = yield* HttpServerRequest;
24 const body = request.method === "POST" ? yield* request.text : "";
25 return yield* HttpServerResponse.json({
26 from: "callee",
27 method: request.method,
28 path: new URL(request.originalUrl, "http://localhost").pathname,
29 body,
30 });
31 }),
32 };
33 }),
34 ) {}