The weather-api project exposes a Rest Api which proxies requests to the openweathermap apis to retrieve the weather for a given lat/lon. Configuration of the weather-api project is done through dotenv (.env and .env.local files). Users of weather-api can utilize the npm run scripts defined in package.json to start, test, lint, etc.
-
NodeJS 18.2.0
-
NPM 8.11.0
-
OpenWeatherMap OneCall Subscription and API Key
-
This subscription and api key can be obtained from https://openweathermap.org/guide
-
Once obtained the api key must be configured in .env.local
-
Configuration of the weather-api project utilizes dotenv. All configuration parameters can be seen in the .env file. To prevent accidentally adding api keys into source code it is recommended that the user copies the .env to create a .env.local in the root directory.
You can use your favorite Rest Api tool like curl, postman, or a browser to execute the weather-api rest apis. Here is an example using curl: curl 'http://localhost:8080/weather/current?lat=90&lon=90'
Note: the above link assumes weather-api is running on port 8080. This can be changed using the PORT environment variable through .env.local .
Logs are written to ./output/weather-api.log
Unit tests can be executed by executing the npm test run script. From the root of the project run: npm run test
Test coverage can be calculated by executing the following from the root of the project: npm run coverage. Unit test coverage minimums are defined in package.json.
The weather-api project exposes an OpenAPI document hosted at http://localhost:8080/api-docs/openapi.json .
An interactive Swagger UI is available at http://localhost:8080/api-docs
Note: the above link assumes weather-api is running on port 8080. This can be changed using the PORT environment variable through .env.local .