@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 34 lines 1.06 KB
Raw
1 import * as Railway from "@alchemy.run/railway";
2 import * as Effect from "effect/Effect";
3 import * as pathe from "pathe";
4 import { Db } from "./postgres-shared.ts";
5 import { Partition, Site } from "./suite-env.ts";
6
7 export { Db, Site };
8
9 /**
10 * Async (non-Effect) canvas Function. Postgres is declared on `env` as a
11 * string URI — Railway has no native bindings, so {@link Railway.InferEnv}
12 * maps every key to `string`. The handler in `async-postgres.ts` reads
13 * `env.DATABASE_URL` with plain `pg`.
14 *
15 * Props are an Effect so `Db` is yielded first and `connectionUri` is a
16 * resolved Output (not a nested Effect that `toEnvRecord` would drop).
17 */
18 export const PostgresFn = Railway.Function(
19 "PostgresFn",
20 Effect.gen(function* () {
21 const db = yield* Db;
22 return {
23 project: Site,
24 environment: Partition,
25 main: pathe.resolve(import.meta.dirname, "async-postgres.ts"),
26 env: {
27 DATABASE_URL: db.connectionUri,
28 },
29 build: { install: ["pg"] },
30 };
31 }),
32 );
33
34 export type PostgresFnEnv = Railway.InferEnv<typeof PostgresFn>;