This project will be used for calculating the area of different shapes. The task involves building a RESTful API for the project using Node, Express, and any database, of your choice. In this case made use of mongoDB.
The list of supported shapes, their dimensions and formulas have been given below.
Shape | Dimensions | Formula for Area |
---|---|---|
Square | - Side (side) | side * side |
Rectangle | - Length, - Breadth | length * breadth |
Triangle | length_a, length_b, length_c, | √s (s − length_a) (s − length_b) (s − length_c) |
Circle | -Radius (radius) | πradius² |
- An endpoint to authenticate a user
- Signup: api/v1/auth/signup
- login: api/v1/auth/login
- An endpoint to perform a calculation
- api/v1/calculate
- An endpoint to view previous calculations
- api/v1/calculate/all
This API is hosted on Base URL: https://abindev-test.herokuapp.com/
Read the docs: https://documenter.getpostman.com/view/7357882/TzY68EBR
To run this application locally on your PC, you should have the following installed
- Node js version > 11
git clone https://github.com/phawazzzy/nodejs-with-oop.git
cd nodejs-with-oop
npm install
The project uses environment variables for configuration,
In the root project folder create a .env
file and fill it with the content in the .env.example
file.
Create file from the terminal, from the root directory
touch .env
Provide the mongoDB uri on the .env file In my case used mongoDB
Using nodemon if you have nodemon installed on your system you can make use of the commang
npm run dev
Using node
npm start
build the docker file if you havent before
docker build -t node-with-oop .
run the docker file
docker run -p 3000:3000 node-with-oop
Create the .env file before building with docker