t3-code-android-nightly/.repos/alchemy-effect/examples/fly-microservices/alchemy.run.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

40 lines
1.3 KiB
TypeScript

/**
* Three Services connected over a private Fly network:
*
* - `Users` — private, serves `list` and `get` methods (`src/users.ts`)
* - `Orders` — private, binds Users (`src/orders.ts`)
* - `Gateway` — the only public Service, binds both (`src/gateway.ts`)
*
* Each Service is its own Fly App. All three join `Fly.stackNetwork`, a
* private network unique to this stack and stage, so Users and Orders are
* unreachable from the internet and from every other App in the org.
* `Fly.bindService` connects them: only a Service that binds another
* receives its caller token, so it can call its methods.
*/
import * as Alchemy from "alchemy";
import * as Fly from "alchemy/Fly";
import * as Effect from "effect/Effect";
import Gateway from "./src/gateway.ts";
import Orders from "./src/orders.ts";
import Users from "./src/users.ts";
export default Alchemy.Stack(
"FlyMicroservices",
{
providers: Fly.providers(),
state: Alchemy.localState(),
},
Effect.gen(function* () {
const users = yield* Users;
const orders = yield* Orders;
const gateway = yield* Gateway;
return {
url: gateway.url,
network: gateway.network,
usersUrl: users.url,
usersPrivateUrl: users.privateUrl,
ordersPrivateUrl: orders.privateUrl,
};
}),
);