Skip to content

This template suggests architecture convention for Node.js daemon.

Notifications You must be signed in to change notification settings

vaderangry/node-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js template

This template suggests architecture convention for Node.js daemon.

Architecture

Directories

Overview of directory tree:

  • server/ - Base directory with server logic.
  • server/models - Place for your stored models.
  • server/schemas - Directory contains validation schemas for your input data streams.
  • server/domain - Your domain logic.
  • server/lib - Your support logic.
  • client/ - Client scripts (optional).
  • config/ - Config files.
  • web/ - Third party web-framework (optional).

Launch

Daemon starting from /server/server.js.

Config

Config.

Logs

Mag - fast streaming logger. Use object container and markers for organize log streams.

Example:

var logger = {
    server: require('mag')('server'),
    amqp:   require('mag')('amqp')
};

Management

Use pm2 for process management.

Tests

Install globally mocha. For assertion use chai.

Example:

// File test/example.js

var assert = require('chai').assert;

function incNumber(number) {
    return number++;
}

describe('censor', function () {
    it('Test of incNumber function', function () {
        let number = 0;
        let result = incNumber(number);
        assert.equal(result, 1);
    });
});

Run $ mocha.

About

This template suggests architecture convention for Node.js daemon.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published