import dotenv from 'dotenv';

dotenv.config();

export const config = {
  port: parseInt(process.env.API_PORT || '3000'),
  host: process.env.API_HOST || 'localhost',
  nodeEnv: process.env.NODE_ENV || 'development',
  
  // Database
  databaseUrl: process.env.DATABASE_URL || 'postgresql://cloneweb_user:cloneweb_password@localhost:5432/cloneweb',
  
  // Redis
  redisUrl: process.env.REDIS_URL || 'redis://localhost:6379',
  
  // JWT
  jwtSecret: process.env.JWT_SECRET || 'your-super-secret-jwt-key-change-in-production',
  jwtExpiresIn: process.env.JWT_EXPIRES_IN || '7d',
  
  // Rate Limiting
  rateLimitWindowMs: 15 * 60 * 1000, // 15 minutes
  rateLimitMax: 100, // limit each IP to 100 requests per windowMs
  
  // CORS
  corsOrigins: process.env.CORS_ORIGINS?.split(',') || ['http://localhost:3000', 'http://localhost:3001'],
  
  // Logging
  logLevel: process.env.LOG_LEVEL || 'info',
  
  // Security
  bcryptRounds: 12,
  
  // Services URLs (for microservices communication)
  services: {
    crawler: process.env.CRAWLER_SERVICE_URL || 'http://localhost:3001',
    scraper: process.env.SCRAPER_SERVICE_URL || 'http://localhost:3002',
    generator: process.env.GENERATOR_SERVICE_URL || 'http://localhost:3003',
    assets: process.env.ASSETS_SERVICE_URL || 'http://localhost:3004',
  }
};

export default config;