import { Pool } from 'pg'; import { drizzle } from 'drizzle-orm/node-postgres'; import * as schema from "@shared/schema"; if (!process.env.DATABASE_URL) { throw new Error( "DATABASE_URL must be set. Did you forget to provision a database?", ); } // Configuration pour production avec DATABASE_URL export const pool = new Pool({ connectionString: process.env.DATABASE_URL, ssl: process.env.NODE_ENV === 'production' ? { rejectUnauthorized: false } : false, max: 20, // Maximum number of clients in the pool idleTimeoutMillis: 30000, // Close idle clients after 30 seconds connectionTimeoutMillis: 2000, // Return an error after 2 seconds if connection cannot be established }); export const db = drizzle(pool, { schema });