2026-01-20 09:02:26 -06:00

25 lines
643 B
TypeScript
Executable File

// db/db.ts
// PostgreSQL connection
import * as schema from "./schema.ts";
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
const pool = new Pool({
connectionString: Deno.env.get("POSTGRES_OPTIONS")!,
});
export const db = drizzle({ client: pool, schema });
/** Check if database connection is available */
export async function checkDatabaseConnection(): Promise<boolean> {
try {
const client = await pool.connect();
await client.query("SELECT 1");
client.release();
return true;
} catch (error) {
console.error("Database connection check failed:", error);
return false;
}
}