READMEmain
We couldn't render this README. Read it on GitHub
NestJS Weather API Project
This is a NestJS application that provides weather data for global locations, including both US and international locations like India.
Description
This repository contains a NestJS application with a weather API that uses multiple data sources:
- National Weather Service (NWS) API for US locations
- OpenWeatherMap API for global locations (including India)
Installation
$ npm install
Configuration
-
Copy the
.env.examplefile to.env:cp .env.example .env -
Get an API key from OpenWeatherMap and add it to the
.envfile:OPENWEATHER_API_KEY=your_api_key_here
Running the app
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
Test
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
API Endpoints
Get Weather Forecast
GET /weather/forecast?latitude=<lat>&longitude=<lon>
Example:
- For New York (US):
/weather/forecast?latitude=40.7128&longitude=-74.0060 - For Delhi (India):
/weather/forecast?latitude=28.6139&longitude=77.2090
Get Weather Alerts
GET /weather/alerts?latitude=<lat>&longitude=<lon>
Note: Weather alerts are currently only available for US locations.
Features
- Basic NestJS application structure
- Weather API with support for global locations
- Automatic detection of US vs. international locations
- Environment-based configuration
- TypeScript configuration
Getting Started
- Clone the repository
- Install dependencies with
npm install - Configure your
.envfile with your OpenWeatherMap API key - Run the application with
npm run start:dev - Access the API at
http://localhost:3000/weather/forecast?latitude=28.6139&longitude=77.2090(example for Delhi, India)
License
This project is MIT licensed.