The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Cloudflare from "@alchemy.run/cloudflare"; |
| 2 | import * as DomainCloudflare from "@alchemy.run/cloudflare/Domain"; |
| 3 | import * as Domain from "@alchemy.run/domain"; |
| 4 | import * as Effect from "effect/Effect"; |
| 5 | import * as HttpServerResponse from "effect/http/HttpServerResponse"; |
| 6 | import * as Layer from "effect/Layer"; |
| 7 | import { Account, Billing } from "./isolation.ts"; |
| 8 | |
| 9 | /** A different model with Billing's name. */ |
| 10 | class OtherBilling extends Domain.Model("Billing", { aggregates: [Account] }) {} |
| 11 | |
| 12 | /** Hosts two different models named Billing, each provided on its own. */ |
| 13 | export default class DomainDuplicateWorker extends Cloudflare.Worker<DomainDuplicateWorker>()( |
| 14 | "DomainDuplicateWorker", |
| 15 | { main: import.meta.url }, |
| 16 | Effect.gen(function* () { |
| 17 | const accounts = Effect.map(Effect.all({ accounts: Account }), ({ accounts }) => accounts); |
| 18 | const Platform = DomainCloudflare.layerDurableObjects(); |
| 19 | yield* Effect.provide(accounts, Billing.layer(Layer.empty).pipe(Layer.provide(Platform))); |
| 20 | yield* Effect.provide(accounts, OtherBilling.layer(Layer.empty).pipe(Layer.provide(Platform))); |
| 21 | return { fetch: Effect.succeed(HttpServerResponse.text("unreachable")) }; |
| 22 | }), |
| 23 | ) {} |