This is a NodeJS backend service (only a RESTful API) which will return the forecast of a specified location using publicly available APIs.
The goal is that a caller can provide a location (city, zipcode, full address) and will receive the forecast for the next 5 periods that location.
Frameworks included in the project:
- NestJS - Backend framework, provides IOC/DI for lifecycle management
- Axios - Promise based HTTP client
- Jest - Testing framework
There is only a single endpoint exposed by the service.
/weather?location=[string]
Behind the scenes, this endpoint will make use of two services to convert the location into the final forecast.
- Openstreetmap
/search- Returns a list of geocoded data in order of importance
- Weather.gov
/points/{lat},{lon}- Returns the point information (location + station information). We'll show the forecast./gridpoints/{gridId}/{gridX),{gridY}/forecast- Returns the forecast for the location
- Openweather
- To run the tests via
docker-compose, simply rundocker-compose upand the service will launch with the test suite running in--watchmode.- In this mode, the test suite will run in full once, and then listen for changes.
- If changes are detected, the suite will only rerun the affected specs.
Running the test suite
- To run the test suite once, run
npm run test - To run the test suite in
--watchmode, runnpm run test:watch.- In this mode, the test suite will run in full once, and then listen for changes.
- If changes are detected, the suite will only rerun the affected specs.
- To run the tests in debug mode, run
npm run test:debug
Running the service
- To start the service, run
npm run start:devto have Node hot-reload file changes in realtime. - To start the service in debug mode, run
npm run start:debug
- To run the test suite once, run
make test.all - To run the test suite in
--watchmode, runmake test.watch.- In this mode, the test suite will run in full once, and then listen for changes.
- If changes are detected, the suite will only rerun the affected specs.