/** * Database connection using Drizzle ORM + postgres.js */ import { drizzle } from 'drizzle-orm/postgres-js'; import postgres from 'postgres'; import * as schema from './schema/index'; let db: ReturnType> | null = null; export function getDb(databaseUrl: string) { if (!db) { const client = postgres(databaseUrl, { max: 10 }); db = drizzle(client, { schema }); } return db; } export type Database = ReturnType;