nir-jas / open-weather-api

A project to fetch weather data using OpenWeather APIs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Weather API Operations

A project to fetch weather data using OpenWeather APIs.

Quick Start

Clone the repo:

git clone --depth 1 https://github.com/nir-jas/open-weather-api.git
cd open-weather-api

Install the dependencies:

yarn install

Set the environment variables:

cp .env.example .env

# open .env and modify the environment variables (if needed)

Table of Contents

Commands

Running locally:

yarn dev

Running in production:

yarn start

Docker:

# run docker container in development mode
yarn docker:dev

# run docker container in production mode
yarn docker:prod

# run all tests in a docker container
yarn docker:test

Linting:

# run ESLint
yarn lint

# fix ESLint errors
yarn lint:fix

# run prettier
yarn prettier

# fix prettier errors
yarn prettier:fix

Environment Variables

The environment variables can be found and modified in the .env file. They come with these default values:

# Port number
PORT=3000

# URL of the Mongo DB
MONGODB_URL=mongodb://127.0.0.1:27017/gonumeral

# API key for OpenWeatherMap
OPEN_WEATHER_API_KEY=YOUR_API_KEY

Project Structure

src\
 |--config\         # Environment variables and configuration related things
 |--controllers\    # Route controllers (controller layer)
 |--docs\           # Swagger files
 |--middlewares\    # Custom express middlewares
 |--models\         # Mongoose models (data layer)
 |--routes\         # Routes
 |--services\       # Business logic (service layer)
 |--utils\          # Utility classes and functions
 |--validations\    # Request data validation schemas
 |--app.js          # Express app
 |--index.js        # App entry point

API Documentation

To view the list of available APIs and their specifications, run the server and go to http://localhost:3000/api/v1/docs in your browser. This documentation page is automatically generated using the swagger definitions written as comments in the route files.

API Endpoints

List of available routes:

Weather routes:
GET /api/v1/weather - get weather data for a location
GET /api/v1/weather/all - get all weather data
DELETE /api/v1/weather/locations/:locationId - delete weather data for a location\

License

MIT

About

A project to fetch weather data using OpenWeather APIs.

License:MIT License


Languages

Language:JavaScript 98.6%Language:Dockerfile 0.8%Language:Shell 0.6%