@devries-cameron20 / t3code Mirror · read-only
Fork 0

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, 04:45 UTC

main
ts 31 lines 977 Bytes
Raw
1 import * as Effect from "effect/Effect";
2 import * as Layer from "effect/Layer";
3 import { ReadBucket, type ReadBucketClient } from "./ReadBucket.ts";
4 import { makeStorageBinding, storageHttpLayer } from "./StorageBinding.ts";
5
6 export const makeReadBucketClient = (
7 client: Effect.Success<ReturnType<Effect.Success<ReturnType<typeof makeStorageBinding>>>>,
8 ): ReadBucketClient => ({
9 get: client.get,
10 head: client.head,
11 list: client.list,
12 presignGet: (key, options) => client.presign(key, "GET", options),
13 });
14
15 /**
16 * Use injected same-branch Neon credentials, otherwise manage a scoped credential.
17 *
18 * @layer
19 * @product Bucket
20 * @provides ReadBucket
21 */
22 export const ReadBucketHttp = Layer.effect(
23 ReadBucket,
24 makeStorageBinding("storage:read").pipe(
25 Effect.map((bind) =>
26 Effect.fn(function* (...args: Parameters<typeof bind>) {
27 return makeReadBucketClient(yield* bind(...args));
28 }),
29 ),
30 ),
31 ).pipe(Layer.provide(storageHttpLayer));