Nodejs and MongoDB Api
API LINK: https://australia-api.herokuapp.com/api/v1/products/
TODO: Working on Integrating JWT AUTH, Hosting the api on Raspberry PI4 and running it with minikube.
Docker Setup: I have used two images, which i have build & uploaded on my Docker account and i have used docker-compose.yml(included in project) to run services all together.
- I am assuming that docker is intall in the system otherwise its very easy to setup.
- Link: https://docs.docker.com/get-docker/
- Link: https://docs.docker.com/compose/install/
- After installing docker , please run in terminal
-
- docker -v
-
- docker-compose -v
- If above two commands give version number then you are ready to run the app.
-
- RUN: docker-compose up , the server is up and running , to test:
-
- Move to below instruction to run POSTMAN scripts or you can play in POSTMAN.
I have used Postman to setup testing of endpoints.
Endpoints: All routes are defined in routes/product.route.js
GET /products
- gets all products.
GET /products?name={name}
- finds all products matching the specified name.
GET /products/{productID}
- gets the project that matches the specified ID - ID is a GUID.
POST /products
- creates a new product.
PUT /products/{productID}
- updates a product.
DELETE /products/{productID}
- deletes a product and its options.
GET /products/{productID}/options
- finds all options for a specified product.
GET /products/{productID}/options/{optionId}
- finds the specified product option for the specified product.
POST /products/{productID}/options
- adds a new product option to the specified product.
PUT /products/{productID}/options/{optionId}
- updates the specified product option.
DELETE /products/{productID}/options/{optionId}
- deletes the specified product option.
All models are specified in the /Models
folder,
Help while running Docker Solution, (If docker file gives error while executing above commands. Follow below instructions)
Stop container on current dir 2. if there is a docker-compose.yml
- docker-compose down
Remove all containers
- docker rm -fv $(docker ps -aq)
List who's using the port
- sudo lsof -i -P -n | grep 27017
- then: - kill -9 (macOS) or - sudo kill (Linux).