import { initializeWcagConfig, getWcagConfig } from '@wcag-ada/config';

// Initialize configuration for API service
const appConfig = initializeWcagConfig('api');

// Export a config object that matches the expected interface
export const config = {
  NODE_ENV: appConfig.environment as 'development' | 'production' | 'test',
  PORT: appConfig.services.api.port,
  
  // Database
  DATABASE_URL: process.env.DATABASE_URL || 
    `postgresql://${appConfig.database.postgres.user || 'postgres'}:${appConfig.database.postgres.password || 'postgres'}@${appConfig.database.postgres.host}:${appConfig.database.postgres.port}/${appConfig.database.postgres.database}`,
  REDIS_URL: `redis://${appConfig.worker.redis.host}:${appConfig.worker.redis.port}/${appConfig.worker.redis.db}`,
  
  // Auth
  JWT_SECRET: appConfig.providers.auth.jwt.secret,
  JWT_EXPIRES_IN: appConfig.providers.auth.jwt.expiresIn,
  
  // Scanner
  SCANNER_CONCURRENCY: appConfig.scanner.concurrency,
  SCANNER_TIMEOUT: appConfig.scanner.timeout,
  
  // API Rate Limiting
  API_RATE_LIMIT: appConfig.services.api.rateLimit.max,
  API_RATE_WINDOW: appConfig.services.api.rateLimit.windowMs,
  
  // Storage
  REPORT_STORAGE_PATH: `${appConfig.providers.storage.local.basePath}/${appConfig.providers.storage.local.reports}`,
  SCREENSHOT_STORAGE_PATH: `${appConfig.providers.storage.local.basePath}/${appConfig.providers.storage.local.screenshots}`,
  
  // CORS
  CORS_ORIGIN: appConfig.services.api.cors.origin,
};

export type Config = typeof config;

// Export the full app config for advanced usage
export { appConfig };