@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, 07:15 UTC

main
ts 72 lines 2.4 KB
Raw
1 import * as Cloudflare from "@alchemy.run/cloudflare";
2 import * as Output from "alchemy/Output";
3 import * as Effect from "effect/Effect";
4
5 export const publicationApplications = (contexts: {
6 shared: string;
7 other: string;
8 changed: string;
9 }) =>
10 Effect.gen(function* () {
11 const first = yield* Cloudflare.Container("PublicationFirst", {
12 context: contexts.shared,
13 env: { SLOT: "first" },
14 maxInstances: 2,
15 }).Application;
16 const second = yield* Cloudflare.Container("PublicationSecond", {
17 context: contexts.shared,
18 env: { SLOT: "second" },
19 maxInstances: 3,
20 }).Application;
21 const other = yield* Cloudflare.Container("PublicationOtherContext", {
22 context: contexts.other,
23 maxInstances: 2,
24 }).Application;
25 const changed = yield* Cloudflare.Container("PublicationChangedContent", {
26 context: contexts.changed,
27 maxInstances: 2,
28 }).Application;
29 return { first, second, other, changed };
30 });
31
32 export const sharedApplication = (context: string, repository?: string) =>
33 Effect.gen(function* () {
34 const app = yield* Cloudflare.Container("SharedPublication", {
35 context,
36 publish: repository === undefined ? undefined : { repository },
37 maxInstances: 2,
38 }).Application;
39 return { app };
40 });
41
42 export const historyApplications = (converge = false) =>
43 Effect.gen(function* () {
44 const target = converge
45 ? yield* Cloudflare.Container("HistoryTarget", {
46 image: "docker.io/alpine:3.19",
47 }).Application
48 : undefined;
49 const image = target?.configuration.pipe(Output.map((configuration) => configuration.image!));
50 const first = yield* Cloudflare.Container("HistoryFirst", {
51 image: image ?? "alpine:3.19",
52 }).Application;
53 const second = yield* Cloudflare.Container("HistorySecond", {
54 image: image ?? "alpine:3.20",
55 }).Application;
56 return { first, second, target };
57 });
58
59 export const recoveryApplications = (delay: number, includeSecond = false) =>
60 Effect.gen(function* () {
61 const props = {
62 dockerfile: {
63 content: `FROM alpine:3.19\nRUN sleep ${delay}\nCMD ["sleep", "3600"]\n`,
64 },
65 maxInstances: 2,
66 };
67 const first = yield* Cloudflare.Container("RecoveryFirst", props).Application;
68 const second = includeSecond
69 ? yield* Cloudflare.Container("RecoverySecond", props).Application
70 : undefined;
71 return { first, second };
72 });