The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import { R2 } from "@alchemy.run/cloudflare"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import { Files, UploadError } from "./Files.ts"; |
| 5 | |
| 6 | // #region show |
| 7 | export const FilesR2 = Layer.effect( |
| 8 | Files, |
| 9 | Effect.gen(function* () { |
| 10 | const bucket = yield* R2.Bucket("Files"); |
| 11 | const files = yield* R2.ReadBucket(bucket); |
| 12 | |
| 13 | return { |
| 14 | upload: (name: string, body: string) => |
| 15 | files |
| 16 | .put(name, body) /*hide*/ |
| 17 | .pipe( |
| 18 | Effect.asVoid, |
| 19 | Effect.mapError((cause) => new UploadError({ cause })), |
| 20 | ) /*end*/, |
| 21 | }; |
| 22 | }), |
| 23 | ) /*hide*/ |
| 24 | .pipe(Layer.provide(R2.ReadBucketBinding)); /*end*/ |
| 25 | // #endregion show |