/**
 * PostgreSQL database connection for Discord logs
 */
import postgres from 'postgres';
import type { Sql } from 'postgres';

// Database connection configuration
const sql: Sql<any> = postgres({
  host: import.meta.env.DISCORD_DB_HOST || 'localhost',
  port: parseInt(import.meta.env.DISCORD_DB_PORT || '5432', 10),
  database: import.meta.env.DISCORD_DB_NAME || 'discord',
  username: import.meta.env.DISCORD_DB_USER || 'discord',
  password: import.meta.env.DISCORD_DB_PASSWORD || '',
  max: 10, // Max connections in pool
  idle_timeout: 20,
  connect_timeout: 10,
});

export default sql;
