This is a sample node app with connection to mongoDB to troubleshoot or play around with Node.js APM. It uses express.js and routes to create endpoints and MongoDB to store data. (Note: The data is wiped everytime to destroy the containers)
List of endpoints:
http://localhost:4000/
Homepage (GET)http://localhost:4000/api
Sample Page (GET)http://lochalhost:4000/api/contacts
Endpoint to post and retrieve data (GET AND POST) (Includes request to MongoDB)
- Download the folder
- Add your api key in docker-compose
- Run
docker-compose build
to build the docker image - Run
docker-compose up
to spin up the containers - Open Chrome and hit
http://localhost:4000/api/contacts
orhttp://localhost:4000/api/
- User curl to add data (takes in 4 values: name, email, phone and gender)
curl -X POST \
http://localhost:4000/api/contacts/ \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Postman-Token: f032b670-b8e0-409a-b817-37ae6cac1868' \
-H 'cache-control: no-cache' \
-d 'name=Hetansh&email=sample@gmail.com&phone=12345678&gender=Male&undefined='
- You can see the data by going to
http://localhost:4000/api/contacts
from you chrome browser - See traces in your account
Remember to run docker-compose down
to stop and remove the containers