Giter VIP home page Giter VIP logo

node-rest-starter's Introduction

Node REST Starter

Build Status Maintainability Test Coverage

Getting Started

  1. Install Node module dependencies via: npm install
  2. Use the default configuration in ./config/env/default.js or override with your own configuration that matches the NODE_ENV environment variable by copying the ./config/env/development.template.js file and renaming it to match the value of $NODE_ENV
  3. Start the application via npm start

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.js can be controlled via the mailer.provider configuration to use any of the three out-of-the-box providers:

  1. HTTPS
  2. Log
  3. SMTP

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 series of commands is available to run on the production Mongo instance / cluster to create all required indices.

db.audit.createIndex({ created: -1 }, { background: true });
db.audit.createIndex({
    'message': 'text',
    'audit.auditType': 'text',
    'audit.action': 'text',
    'audit.object': 'text'
}, { background: true });

db.cache.entry.createIndex({ ts: 1 }, { background: true });
db.cache.entry.createIndex({ key: 1 }, { background: true });

db.exportconfigs.createIndex({ created: 1 }, { background: true });

db.feedback.createIndex({ 'created': -1 }, { background: true, expireAfterSeconds: 15552000 });
db.feedback.createIndex({ 'type': 1 }, { background: true });
db.feedback.createIndex({ 'creator': 1 }), { background: true };
db.feedback.createIndex({ 'url': 1 }, { background: true });
db.feedback.createIndex({ 'os': 1 }, { background: true });
db.feedback.createIndex({ 'browser': 1 }, { background: true });
db.feedback.createIndex({ 'body': 'text' }, { background: true });

db.messages.createIndex({ title: 'text', body: 'text', type: 'text' }, { background: true });
db.messages.dismissed.createIndex({ created: -1 }, { expireAfterSeconds: 2592000, background: true });
db.messages.dismissed.createIndex({ userId: 1 }, { background: true });

db.notifications.createIndex({ user: 1, created: -1 }, { background: true });
db.notifications.createIndex({ created: 1 }, { background: true });

db.owners.createIndex({ name: 1 }, { background: true });

db.preferences.createIndex({ 'user' : 1, 'updated' : -1 }, { background: true });
db.preferences.createIndex({ 'user' : 1, 'preferenceType' : 1, 'updated' : -1 }, { background: true });

db.resources.createIndex({ 'created' : 1, 'updated' : -1 }, { background: true });
db.resources.createIndex({ 'owner.name' : 1 }, { background: true });
db.resources.createIndex({ 'title_lowercase': 'text', 'description': 'text' }, { background: true });

db.teams.createIndex({ name: 'text', description: 'text' }, { background: true });

db.useragreements.createIndex({ title: 'text', text: 'text' }, { background: true });

db.users.createIndex({ username: 1 }, { background: true });
db.users.createIndex({ name: 'text', email: 'text', username: 'text' }, { background: true });

node-rest-starter's People

Contributors

jrassa avatar brianghig avatar abemac avatar tzfx avatar sshah-asymmetrik avatar reblace avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.