import { HttpStatus } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { ErrorResponse } from '..';

export class AppConfig {
  private static configService: ConfigService;

  static initialize(configService: ConfigService) {
    this.configService = configService;
  }

  static get(key: string): any {
    if (!this.configService) {
      throw new ErrorResponse(
        'AppConfig not initialized',
        HttpStatus.BAD_REQUEST,
      );
    }
    return this.configService.get(key);
  }
}
