mirror of
https://github.com/R0m1k3/Regisflow.git
synced 2026-10-11 17:29:48 +02:00
Adjusts database connection to use DATABASE_URL for production and switches to PostgreSQL storage when NODE_ENV is 'production'. Replit-Commit-Author: Agent Replit-Commit-Session-Id: a388004f-01c5-42b1-b1d1-f18daf8bdd0c Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/a388004f-01c5-42b1-b1d1-f18daf8bdd0c/h5q2Xzp
20 lines
742 B
TypeScript
20 lines
742 B
TypeScript
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 }); |