This folder contains the backend for the ArduinoWeather project.
It makes use of Node.js, NPM as package manager and Typescript as a programming language.
Import libraries in the repo are Express.js (API framework) and Sequelize (ORM framework).
The API has the following endpoints:
- Weather
- Get current weather:
GET /api/weather/now
- Get all weather:
GET /api/weather/all
- Get weather by date:
GET /api/weather/:startDate/:endDate
- Post current weather:
POST /api/weather/save
- Get current weather:
- User
- User log in:
POST /api/user/login
- User sign up:
POST /api/user/signup
- User log in:
The API makes use of a MySQL localhost database on port 3306. Feel free to clone and modify this backend setup for other purposes.
To modify or add routes, you can simply do the following steps:
- Create a new controller in the controller folder.
- Add a function similar to the existing ones.
- Import the controller in the router class and define a new route.
Node.js and NPM have to be installed on the machine.
First install all the dependencies with NPM
npm install
Run the backend on port 3000
npm run start
Dockerize this!
docker build -t {PREFERRED_TAG_NAME} .
Run the image
docker run -d --network=host --name={DOCKER_CONTAINER_NAME} {IMAGE_NAME}