diff --git a/src/config/weather.open.config.ts b/src/config/weather.open.config.ts index 2182490..94b77d5 100644 --- a/src/config/weather.open.config.ts +++ b/src/config/weather.open.config.ts @@ -4,5 +4,6 @@ export default registerAs( 'openweather-config', (): Record => ({ OPEN_WEATHER_MAP_API_KEY: process.env.OPEN_WEATHER_MAP_API_KEY, + WEATHER_API_URL: process.env.WEATHER_API_URL, }), ); diff --git a/src/weather/services/weather.service.ts b/src/weather/services/weather.service.ts index aa4ea0d..3463b5c 100644 --- a/src/weather/services/weather.service.ts +++ b/src/weather/services/weather.service.ts @@ -9,10 +9,13 @@ import { SuccessResponseDto } from '@app/common/dto/success.response.dto'; @Injectable() export class WeatherService { + private readonly weatherApiUrl: string; constructor( private readonly configService: ConfigService, private readonly httpService: HttpService, - ) {} + ) { + this.weatherApiUrl = this.configService.get('WEATHER_API_URL'); + } async fetchWeatherDetails( query: GetWeatherDetailsDto, @@ -22,7 +25,7 @@ export class WeatherService { const weatherApiKey = this.configService.get( 'OPEN_WEATHER_MAP_API_KEY', ); - const url = `http://api.weatherapi.com/v1/current.json?key=${weatherApiKey}&q=${lat},${lon}&aqi=yes`; + const url = `${this.weatherApiUrl}/current.json?key=${weatherApiKey}&q=${lat},${lon}&aqi=yes`; const response = await firstValueFrom(this.httpService.get(url)); const pm2_5 = response.data.current.air_quality.pm2_5; // Raw PM2.5 (µg/m³)