chrisleekr / nodejs-mongodb-api-boilerplate

A boilerplate for Node.js RESTful API with MongoDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node.js + MongoDB RESTful 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

Method URL Sample Data
GET http://localhost:3000/tasks
POST http://localhost:3000/tasks {"name":"Fix issue 1"}
GET http://localhost:3000/tasks/1
PUT http://localhost:3000/tasks/1 {"name":"Fix issue 1","status":"completed"}
DELETE http://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

About

A boilerplate for Node.js RESTful API with MongoDB


Languages

Language:JavaScript 89.3%Language:Dockerfile 10.7%