Node.js + MongoDB RESTful API Boilerplate

Github: https://github.com/chrisleekr/nodejs-mongodb-api-boilerplate

This is a sample project that I followed the tutorial Build Node.js RESTful APIs in 10 Minutes written by Olatunde Garuba.

How to start

$ docker-compose up -d
$ docker logs -f api

This command will build Node.js API and launch docker container mongo and mongo-express

Endpoints

Node.js API

MethodURLSample Data
GEThttp://localhost:3000/tasks
POSThttp://localhost:3000/tasks{"name":"Fix issue 1"}
GEThttp://localhost:3000/tasks/1
PUThttp://localhost:3000/tasks/1{"name":"Fix issue 1","status":"completed"}
DELETEhttp://localhost:3000/tasks/1

Mongo Express Dashboard

Open browser with http://localhost:8081

Troubleshooting

Mongoose connection issue

When you download mongo docker image first time, then it may have a delay on initialising. As a result, api may throw connection exception. To resolve this issue, simply restart api container with below command:

$ docker-compose restart api

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.