feat: db connection and migration

This commit is contained in:
2026-06-10 07:51:00 +00:00
parent 935ff5b757
commit 63714f5960
3 changed files with 58 additions and 0 deletions

13
server/utils/db.ts Normal file
View File

@@ -0,0 +1,13 @@
import postgres from "postgres";
let _sql: ReturnType<typeof postgres> | null = null;
/** Lazily-created shared postgres.js connection pool. */
export function getSql() {
if (!_sql) {
const url = process.env.DATABASE_URL;
if (!url) throw new Error("DATABASE_URL not set");
_sql = postgres(url, { max: 5, idle_timeout: 30 });
}
return _sql;
}