juntekim.com/stripe_to_invoice/lib/db.ts
2025-12-31 00:02:22 +00:00

19 lines
448 B
TypeScript

// lib/db.ts
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
// Fail fast if env is missing
if (!process.env.DATABASE_URL) {
throw new Error("DATABASE_URL is not set");
}
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl:
process.env.NODE_ENV === "production"
? { rejectUnauthorized: false }
: false,
});
// Export a single db instance
export const db = drizzle(pool);