@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, 06:00 UTC

main
ts 60 lines 1.83 KB
Raw
1 /**
2 * The Git host with its bytes on S3 (DESIGN §22): the same building-block
3 * assembly as `stack.ts`, with `BlobStoreS3(GitObjects)` in place of R2. Needs BOTH
4 * provider sets — the bucket is an `AWS.S3.Bucket` and the Worker binds
5 * the S3 operations cross-cloud (an IAM identity is minted for it).
6 */
7 import * as AWS from "@alchemy.run/aws";
8 import * as Cloudflare from "@alchemy.run/cloudflare";
9 import {
10 BlobStoreS3,
11 GIT_WORKER_OPTIONS,
12 ApiHandlersLive,
13 HasherInline,
14 ReposDurableObject,
15 RegistryDurableObject,
16 } from "@alchemy.run/git";
17 import * as Alchemy from "alchemy";
18 import * as Effect from "effect/Effect";
19 import * as HttpRouter from "effect/http/HttpRouter";
20 import * as Layer from "effect/Layer";
21 import { TestRoutes } from "./http.ts";
22 import { TEST_SECRET, TestApi, TestAuthLive } from "./stack.ts";
23 export { TEST_SECRET };
24
25 /** Declared here so the stack tears it down with the packs still inside. */
26 export const GitObjects = AWS.S3.Bucket("GitS3Objects", { forceDestroy: true });
27
28 const GitLive = TestRoutes.pipe(
29 Layer.provide(ApiHandlersLive),
30 Layer.provide(ReposDurableObject),
31 Layer.provide(RegistryDurableObject),
32 Layer.provide(HasherInline),
33 Layer.provide(BlobStoreS3(GitObjects)),
34 );
35
36 export default class S3GitHost extends Cloudflare.Worker<S3GitHost>()(
37 "GitS3Worker",
38 {
39 main: import.meta.url,
40 ...GIT_WORKER_OPTIONS,
41 observability: { enabled: true },
42 },
43 Effect.gen(function* () {
44 const fetch = yield* HttpRouter.toHttpEffect(GitLive);
45 return { fetch };
46 }),
47 ) {}
48
49 export const makeS3TestStack = (name: string) =>
50 Alchemy.Stack(
51 name,
52 {
53 providers: Layer.mergeAll(AWS.providers(), Cloudflare.providers()),
54 state: Cloudflare.state(),
55 },
56 Effect.gen(function* () {
57 const host = yield* S3GitHost;
58 return { url: host.url.as<string>() };
59 }),
60 );