| 1 | import * as Cloudflare from "@/Cloudflare"; |
| 2 | import * as Alchemy from "@/index.ts"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import ReadBindingWorker from "./read-binding.ts"; |
| 5 | import ReadHttpWorker from "./read-http.ts"; |
| 6 | import ReadWriteBindingWorker from "./readwrite-binding.ts"; |
| 7 | import ReadWriteHttpWorker from "./readwrite-http.ts"; |
| 8 | import WriteBindingWorker from "./write-binding.ts"; |
| 9 | import WriteHttpWorker from "./write-http.ts"; |
| 10 | |
| 11 | /** |
| 12 | * Deploys six Workers that all bind one shared R2 bucket — read / write / |
| 13 | * read-write, each over the native Worker binding (`*BucketBinding`) and over a |
| 14 | * scoped HTTP API token (`*BucketHttp`). Extracted into its own stack file so |
| 15 | * it can be deployed by the test suite AND inspected directly, e.g. |
| 16 | * |
| 17 | * ```sh |
| 18 | * alchemy logs --tail --stage test --config ./test/Cloudflare/R2/fixtures/stack.ts |
| 19 | * ``` |
| 20 | */ |
| 21 | export default Alchemy.Stack( |
| 22 | "R2BindingStack", |
| 23 | { providers: Cloudflare.providers(), state: Cloudflare.state() }, |
| 24 | Effect.gen(function* () { |
| 25 | const readBinding = yield* ReadBindingWorker; |
| 26 | const writeBinding = yield* WriteBindingWorker; |
| 27 | const readWriteBinding = yield* ReadWriteBindingWorker; |
| 28 | const readHttp = yield* ReadHttpWorker; |
| 29 | const writeHttp = yield* WriteHttpWorker; |
| 30 | const readWriteHttp = yield* ReadWriteHttpWorker; |
| 31 | return { |
| 32 | readBinding: readBinding.url.as<string>(), |
| 33 | writeBinding: writeBinding.url.as<string>(), |
| 34 | readWriteBinding: readWriteBinding.url.as<string>(), |
| 35 | readHttp: readHttp.url.as<string>(), |
| 36 | writeHttp: writeHttp.url.as<string>(), |
| 37 | readWriteHttp: readWriteHttp.url.as<string>(), |
| 38 | }; |
| 39 | }), |
| 40 | ); |