Weather API
This small API was created as a brief challenge to participate in the Golang bootcamp by Wizeline it consists in two only two endpoints, a Hello world endpoint and one that consumes the Open weather API to tell you the curren weather on a mexican zip code.
Getting started
Prerequisites
- You need to have installed Node 15.0.1 or later and npm 7.0.3 or later.
- You need tho have an API key from the Open weather API.
Installing
- Clone the repository in your local machine
- Crete an
.env
file in the config folder, you can use theexample.env
file as draft. You'll need to put your Open weather API key. - Run
npm install
to install all the dependencies.
Usage
- You can start the server with the
npm start
command or withnpm run dev
for start it in development mode with nodemon - Once the server is running you can go to your Localhost port 3000 and you'll get the message
Hello, World!
. That's the firs endpoint - The second endpoint is a GET request to the route
/weather
. this endpoint expects for a query called zip that should be a mexican zip code. i.e:http://localhost:3000/weather?zip=45050
- if the zip code is a valid one you should receive a JSON with the following fields:
{
name: city name,
country: country code
weather: [
{
main: Group of weather parameters (Rain, Snow, Extreme etc.)
description: Weather condition within the group.
icon: an url for the Weather icon id
}
],
temp: Temperature in Celsius degrees
feels_like: This temperature parameter accounts for the human perception of weather
temp_min: Minimum temperature at the moment,
temp_max: Maximum temperature at the moment,
pressure: Atmospheric pressure in hPa,
humidity: Humidity %,
date: Time of data calculation,
}
Running the tests
- The unit testing can be done with the command
npm test
- For watching the tests during development you can use
npm run test-watch
- For checking the coverage you can run the command
npm run test-cover
Code style
This project was developed using the Airbnb JavaScript Style Guide via the Eslint library
Build with
- Node 15.0.1: A JavaScript runtime built on Chrome's V8 JavaScript engine.
- Npm 7.03: A package manager for JavaScript.
- ExpressJS 4.17.1: A fast, unopinionated, minimalist web framework for Node.js
- Dependencies:
- axios
- dotenv
- express
- eslint
- jest
- nodemon