Home

Awesome

Node REST Starter

Build Status Maintainability Test Coverage

Getting Started

Prereqs

Required

Recommended

Start Up

  1. To get started run npm run init(if you do not have mongo running use npm run init:mongo)
    • This will install the dependencies and setup the development.js environment from the template
  2. Start the application via npm start

Related Commands

API Documentation

Endpoint Documentation for this application is generated from the *.routes.js files in each module.
Model/Schema documentation should be included in with each model and will be compiled from any file matching *.model.js.

When the application is started, Swagger provides an interface for this API that is available by default at http://localhost:3000/api-docs

The existence and path for this Swagger page is configurable via the apiDocs parameter, which defaults to:

{
	"enabled": true,
	"path": "/api-docs"
}

Providers

Several services use configurable "providers" in order to easily swap functionality in and out of the application.

For example, the Email Service at ./src/app/core/email/email.service.ts can be controlled via the mailer.provider configuration to use any of the out-of-the-box providers:

  1. HTTPS
  2. SMTP
  3. Log
  4. File
  5. Noop

The default provider for a service will be included in dependencies in NPM's package.json. On the other hand, any non-default providers should include their dependencies as devDependencies in order to reduce the inclusion of unnecessary modules in production builds.

If a non-default provider is used (e.g., node-kafka for the Event service), the application instance should include this module in dependencies on its own fork, instead of updating the node-rest-starter reference application.

Testing

Tests run as an NPM script. To support development, npm run test will watch all files via nodemon and will run tests as files are updated.

In order to generate code coverage output via a single run of the test suite, npm run test:ci will output coverage results into the top-level ./coverage directory, both in HTML and LCOV formats.

Installing on Production

Since Mongoose suggests not automatically creating Mongo indices on-the-fly, the following utility script can be run, targeting the production Mongo instance / cluster, to create/sync all required indices.

node ./src/sync-indexes.js