A nice starting point for a restful JSON API that includes:
- No static file serving or server side templating. This project is all about the data.
- The latest Express.js web application framework (v4.x)
- Token based authentication using express-jwt middleware
- Mongodb and Mongoose ODM
- Portable and isolated development environment using Vagrant, Docker, and Docker Compose
Before getting started, make sure you have Vagrant installed.
- Clone this repo:
git clone https://github.com/projectweekend/Node-Backend-Seed.git New-Name - Change directory:
cd New-Name - Launch the Vagrant VM:
vagrant up - SSH into the VM:
vagrant ssh - Change directory into the project root:
cd /vagrant - Launch the API app and database containers:
docker-compose up
- The first time you issue the
vagrant upcommmand the base box for the VM will be downloaded and provisioned automatically according to the project'sVagrantfile. This may take a little while to complete depending on the speed of your network connection. Subsequent launches usingvagrant upwill run much faster. For more information about other Vagrant commands, check out the documentation. - The first time you issue the
docker-compose upcommand the base NodeJS and MongoDB containers will be downloaded from the Docker Registry, according to the project'sdocker-compose.ymlandDockerfile. This may take a little while to complete depending on the speed of your network connection. Subsequent launches usingdocker-compose upwill run much faster. For more information about Docker Compose, check out the documentation.
- Use the
/routes/index.jsfile for mapping route handler functions to URLs. This helps keepapp.jsfrom getting cluttered. - Route handlers, and all the supporting items they require, are defined in
/api. - Mongoose models related to each handler module are managed in
/api/module_name/models.js - Simple authentication and signup routes are already active in the seed application. These exist as part of the
/api/usermodule.