1import * as GCP from "@/GCP";
2import * as Effect from "effect/Effect";
3import { HttpServerRequest } from "effect/http/HttpServerRequest";
4import * as HttpServerResponse from "effect/http/HttpServerResponse";
5
6/**
7 * Private Effect-native Cloud Run Service (invoker IAM enforced).
8 * Called by {@link ./invoke-caller.ts} from {@link ../InvokeService.test.ts}.
9 */
10export default class InvokeCallee extends GCP.Function<InvokeCallee>()(
11 "InvokeCallee",
12 {
13 main: import.meta.url,
14 location: "us-central1",
15 },
16 Effect.gen(function* () {
17 return {
18 fetch: Effect.gen(function* () {
19 const request = yield* HttpServerRequest;
20 const body = request.method === "POST" ? yield* request.text : "";
21 return yield* HttpServerResponse.json({
22 from: "callee",
23 method: request.method,
24 path: new URL(request.originalUrl, "http://localhost").pathname,
25 body,
26 });
27 }),
28 };
29 }),
30) {}