Back-end of Weather app Front-end. Contains method for database(mongo) operations, validation of user and weather operations.
- Clone
https://github.com/Web-Rats/BackEnd.git. - Install dependencies using
npm install. - Create an
.envfile in root directoty (insert your credential for accessing database), withUSER="yourUser"andPSWD="yourPassword" - Start with
node index.jsor for develop modenpm run api.
DB functions
User
├───dbApi
│
└───Methods
│
└───User
├─delete.js
├─find.js
├─register.js
└─update.jsasync function registerUser(object)Take as parameter the object user and save it in database.
async function deleteUser(email)Take as parameter the email of the user for deleting user from database.
async function findUser(email)Take as parameter the email of the user for finding it in the database. When it finds the user it will return the object 'user'.
async function updateUser(update, email)Take as parameters an object 'update', that contains the key to update, and the email for finding the user. When the update is succeful it returns the update object 'user'.
Weather
├───dbApi
│
└───Methods
│
└───Prevision
├───addDaily.js
├───addHourly.js
├───addPrevisions.js
└───findWeather.jsasync function addPrevisions(cityName, countryCode, stateCode, object)async function findWeather(cityName, countryCode, stateCode, endD = undefined, startD = undefined)Remove in the Dockerfile the '#' before ENV, then insert your creditial for the database connection:
#remove '#'
ENV USER yourUser
ENV PSWD yourPassword
After that, in the root directory, create the image with the command:
docker build -t nameImage:latest In the end run the image with the command:
docker run --name containerName nameImage:latest If you want to run it detatch:
docker run -d --name containerName nameImage:latest