Files
continuum-backend/src/index.ts
T
octoturge c8167804c2 Fix bun-types resolution; fix possibly-undefined health-check row
Same bun-types-vs-@types/bun fix as continuum-common. Also fixes a real
noUncheckedIndexedAccess violation in the /health route: db.execute()'s
result is T[], so rows[0] is 'T | undefined', not T — destructuring assumed
it always existed. Verified with a clean 'bunx tsc --noEmit'.
2026-08-28 18:28:06 +00:00

31 lines
994 B
TypeScript

import { Elysia } from "elysia";
import { cors } from "@elysiajs/cors";
import { swagger } from "@elysiajs/swagger";
import { sql } from "drizzle-orm";
import { db } from "./db";
import { redis } from "./queue";
import { authRoutes } from "./routes/auth";
import { farmRoutes } from "./routes/farms";
import { printerRoutes } from "./routes/printers";
import { jobRoutes } from "./routes/jobs";
import { edgeWsRoute } from "./routes/ws/edge";
const app = new Elysia()
.use(cors())
.use(swagger({ path: "/docs" }))
.get("/health", async () => {
const rows = await db.execute<{ ok: number }>(sql`select 1 as ok`);
const redisPing = await redis.ping();
return { status: "ok", db: rows[0]?.ok === 1, redis: redisPing === "PONG" };
})
.use(authRoutes)
.use(farmRoutes)
.use(printerRoutes)
.use(jobRoutes)
.use(edgeWsRoute)
.listen(Number(process.env.PORT ?? 3000));
console.log(`continuum-backend listening on :${app.server?.port}`);
export type App = typeof app;