/**
 * Database Configuration
 * 
 * Purpose: Centralized database connection settings
 * Manages connection pooling, SSL, and environment-specific configs
 */

import dotenv from 'dotenv';
dotenv.config();

export const databaseConfig = {
  // Database connection
  host: process.env.DB_HOST || 'localhost',
  port: parseInt(process.env.DB_PORT || '5432'),
  database: process.env.DB_NAME || 'skyartshop',
  user: process.env.DB_USER || 'postgres',
  password: process.env.DB_PASSWORD || '',
  
  // Connection pool settings
  pool: {
    min: 2,
    max: 10,
    idleTimeoutMillis: 30000,
    connectionTimeoutMillis: 2000,
  },
  
  // SSL for production
  ssl: process.env.NODE_ENV === 'production' ? { rejectUnauthorized: false } : false,
};

export default databaseConfig;
