| 1 | import * as Cloudflare from "@/Cloudflare"; |
| 2 | import * as Alchemy from "@/index"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import AsyncSecretWorker from "./async-worker.ts"; |
| 5 | import EffectSecretWorker from "./effect-worker.ts"; |
| 6 | |
| 7 | /** |
| 8 | * Deploys both invocation styles against ONE shared Secret (declared in |
| 9 | * `secret.ts`): |
| 10 | * |
| 11 | * - {@link EffectSecretWorker} — `Cloudflare.SecretsStore.ReadSecret(secret)` |
| 12 | * inside the Worker init, binding provided via `ReadSecretBinding`; |
| 13 | * - {@link AsyncSecretWorker} — the Secret declared on the Worker `env`, |
| 14 | * used from a plain async-style `fetch`. |
| 15 | * |
| 16 | * Extracted into its own stack file so it can be deployed by the suite AND |
| 17 | * inspected directly, e.g. |
| 18 | * `alchemy logs --tail --stage test --config ./test/Cloudflare/SecretsStore/fixtures/stack.ts`. |
| 19 | */ |
| 20 | export default Alchemy.Stack( |
| 21 | "SecretsStoreBindingStack", |
| 22 | { |
| 23 | providers: Cloudflare.providers(), |
| 24 | state: Cloudflare.state(), |
| 25 | }, |
| 26 | Effect.gen(function* () { |
| 27 | const effectWorker = yield* EffectSecretWorker; |
| 28 | const asyncWorker = yield* AsyncSecretWorker; |
| 29 | return { |
| 30 | effect: effectWorker.url.as<string>(), |
| 31 | async: asyncWorker.url.as<string>(), |
| 32 | }; |
| 33 | }), |
| 34 | ); |