Skip to content

An opinionated boilerplate for a NodeJs API based on the restify redis and mongo combo

Notifications You must be signed in to change notification settings

Antonhansel/nodejs-restify-redis-mongo-boilerplate

Repository files navigation

nodejs-restify-redis-mongo-boilerplate

Endpoints

This API exposes various endpoints following the REST convention.

Prerequisites

Install Docker on your system.

Install Docker Compose on your system.

Usage

Development

With Docker

Run docker-compose -f docker-compose-dev.yml build in order to:

  • install all dependencies from the package.json in your container with nodemon to have the hot reloading
  • expose port 8000 to the host
  • instruct the container to execute npm start with the proper ENV variables.

To start the API:

  • Run docker-compose -f docker-compose-dev.yml up to create and start the API and all DB containers. The app should then be running on your docker daemon on port 8000.

To find the API IP use the command:

$ docker-machine ip

*/!\ Nodemon is used with -L by default (in package.json) /!*

*/!\ Remove it for better performance (required with Docker tool on Windows 8.1) /!*

Without Docker

To launch the api you will need:

  • A local mongo server running

  • A local redis server running

Then, just type node bin/server and start doing requests on http://localhost:8000 or whatever port you set in your config

Production

With Docker

Run docker-compose -f docker-compose-prod.yml build in order to:

  • install production dependencies from the package.json in your container
  • expose port 80 to the host
  • instruct the container to execute npm start with the proper ENV variables.

To start the API:

  • Run docker-compose -f docker-compose-prod.yml up to create and start the API and all DB containers. The app should then be running on your docker daemon on port 80.

Without Docker

To launch the api you will need:

  • A mongo server running, and the host address set in config/index.js

  • A redis server running, and the host address set in config/index.js

The env variable NODE_ENV set to production

Then, use the command node bin/server and start doing requests on http://localhost:80 or whatever port you set in your config

About

An opinionated boilerplate for a NodeJs API based on the restify redis and mongo combo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published