import { neon } from "@neondatabase/serverless"; import { drizzle } from "drizzle-orm/neon-http"; import * as schema from "./schema"; let db: ReturnType> | undefined; // Created on first use so modules that import it can load without NEON_URL export function getDb() { if (!db) { const url = process.env.NEON_URL; if (!url) throw new Error("NEON_URL is not set"); db = drizzle(neon(url), { schema }); } return db; }