@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 32 lines 1.06 KB
Raw
1 import * as Drizzle from "@alchemy.run/drizzle/Postgres";
2 import * as Railway from "@alchemy.run/railway";
3 import * as Effect from "effect/Effect";
4 import * as HttpServerResponse from "effect/http/HttpServerResponse";
5 import { Db, Site } from "./shared.ts";
6
7 /**
8 * HTTP Service. Canvas Functions cap at 96KB and cannot hold
9 * Drizzle; this image is built from `main` like {@link Api}.
10 * Binds the same {@link Db} via {@link Railway.ConnectPostgres}.
11 */
12 export default class Ping extends Railway.Service<Ping>()(
13 "Ping",
14 {
15 project: Site,
16 main: import.meta.url,
17 port: 3000,
18 healthcheck: "/",
19 },
20 Effect.gen(function* () {
21 const conn = yield* Railway.ConnectPostgres(Db);
22 const db = yield* Drizzle.Postgres(conn.connectionString);
23 return {
24 fetch: db.execute("select 1 as ok").pipe(
25 Effect.flatMap(HttpServerResponse.json),
26 Effect.catch((error) =>
27 HttpServerResponse.json({ ok: false, error: String(error) }, { status: 500 }),
28 ),
29 ),
30 };
31 }).pipe(Effect.provide(Railway.ConnectPostgresHttp)),
32 ) {}