@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 54 lines 1.64 KB
Raw
1 import * as Neon from "@alchemy.run/neon";
2 import * as Effect from "effect/Effect";
3 import * as Schema from "effect/Schema";
4
5 export const resources = Effect.gen(function* () {
6 const project = yield* Neon.Project("Project", { region: "aws-us-east-2" });
7 const branch = yield* Neon.Branch("Backend", {
8 project,
9 migrations: "./migrations",
10 });
11 const uploads = yield* Neon.Bucket("Uploads", {
12 branch,
13 access: "private",
14 // A presigned URL authorizes the PUT, not CORS. No browser cookies are used.
15 cors: [
16 {
17 AllowedOrigins: ["*"],
18 AllowedMethods: ["PUT"],
19 AllowedHeaders: ["content-type"],
20 MaxAgeSeconds: 300,
21 },
22 ],
23 forceDestroy: true,
24 });
25 const auth = yield* Neon.Auth("Auth", {
26 branch,
27 name: "Upload journal",
28 allowLocalhost: true,
29 emailAndPassword: {
30 enabled: true,
31 require_email_verification: false,
32 send_verification_email_on_sign_up: false,
33 },
34 });
35 const appOrigin = yield* Effect.sync(() => process.env.UPLOAD_APP_ORIGIN ?? "*");
36 const publicAssets = yield* Neon.Bucket("PublicAssets", {
37 branch,
38 access: "public_read",
39 forceDestroy: true,
40 });
41 const settings = yield* Neon.Object("Settings", {
42 bucket: uploads,
43 key: "config/settings.json",
44 value: { theme: "system", pageSize: 25 },
45 schema: Schema.Struct({ theme: Schema.String, pageSize: Schema.Number }),
46 });
47 yield* Neon.Object("Welcome", {
48 bucket: publicAssets,
49 key: "welcome.txt",
50 body: "Public read, authenticated write.",
51 contentType: "text/plain",
52 });
53 return { project, branch, uploads, auth, appOrigin, publicAssets, settings };
54 });