Skip to content
TypeScript
905 B
Raw Blame
import * as Cloudflare from "@alchemy.run/cloudflare";
import * as Alchemy from "alchemy";
import * as Effect from "effect/Effect";
import LocalRemoteContainerWorker from "./local-worker.ts";

/**
 * Same worker/DO/container arrangement as `stack.ts`, but under a distinct
 * stack name AND a distinct fixture identity (`local-worker.ts` /
 * `local-object.ts` — LocalRemoteContainer* logical ids) so the local-dev
 * test (`LocalContainer.test.ts`) never shares state, a container
 * application, or a workers.dev worker with the live `Container.test.ts`
 * deployment when the two files run concurrently.
 */
export const state = Alchemy.inMemoryState();

export default Alchemy.Stack(
  "LocalRemoteContainerStack",
  { providers: Cloudflare.providers(), state },
  Effect.gen(function* () {
    const worker = yield* LocalRemoteContainerWorker;
    return { url: worker.url.as<string>() };
  }),
);