| 1 | import * as Fly from "@/Fly"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as HttpServerResponse from "effect/http/HttpServerResponse"; |
| 4 | import RpcUsers from "./rpc-users.ts"; |
| 5 | |
| 6 | /** |
| 7 | * A Service on the organization's default network that binds |
| 8 | * {@link RpcUsers}, which is on the stack network. Deploying it fails. |
| 9 | */ |
| 10 | export default class RpcStranger extends Fly.Service<RpcStranger>()( |
| 11 | "RpcStranger", |
| 12 | { |
| 13 | main: import.meta.url, |
| 14 | region: "iad", |
| 15 | public: false, |
| 16 | guest: { cpuKind: "shared", cpus: 1, memoryMb: 256 }, |
| 17 | }, |
| 18 | Effect.gen(function* () { |
| 19 | const users = yield* Fly.bindService(RpcUsers); |
| 20 | return { |
| 21 | fetch: Effect.gen(function* () { |
| 22 | return yield* HttpServerResponse.json(yield* users.listUsers()); |
| 23 | }).pipe(Effect.orDie), |
| 24 | }; |
| 25 | }), |
| 26 | ) {} |