Skip to content

chrisleekr/nodejs-mongodb-api-boilerplate

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
api
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published