This NestJS project fetches weather data from OpenWeatherMap API and stores it in PostgreSQL. It provides two main endpoints to interact with the weather data.
- Docker
- Docker Compose
- OpenWeatherMap API key (set in .env file)
- Create
.envfile:
cp .env.example .envEdit the .env file with your OpenWeatherMap API key.
- Build and start containers for production:
docker-compose up --buildAfter starting the application, access the interactive API documentation at:
http://localhost:3000/api/v1/docs
- Full documentation of all endpoints
- Try-it-out functionality to test API calls directly
- Schema definitions for all request/response formats
- Multi-select interface for weather parts parameter
POST /api/v1/weather
curl -X POST http://localhost:3000/api/v1/weather \
-H "Content-Type: application/json" \
-d '{
"lat": 51.50,
"lon": 31.28,
"part": "daily,hourly,minutely"
}'GET /api/v1/weather?lat={lat}&lon={lon}&part={part}
curl -X GET http://localhost:3000/api/v1/weather?lat=51.50&lon=31.28&part=daily,hourly,minutely \
-H "Content-Type: application/json"Response Format:
{
"sunrise": 1684926645,
"sunset": 1684977332,
"temp": 292.55,
"feels_like": 292.87,
"pressure": 1014,
"humidity": 89,
"uvi": 0.16,
"wind_speed": 3.13
}To connect to PostgreSQL directly:
docker-compose exec postgres psql -U postgres -d spendbasedocker-compose exec app npm run testsrc/modules/weather- Contains all weather-related functionalitysrc/config- Configuration filessrc/migrations- Database migrationstest- Unit tests
docker-compose up --builddocker-compose updocker-compose down