1.0.2 • Published 8 years ago

express-bootstrapper v1.0.2

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
8 years ago

express-bootstrapper


GitHub build GitHub tag GitHub license

This modules lets you easily require a set of files (e.g. middlewares, libraries...) and will help you to keep your app.js clean. You only have to maintain a JSON configuration and the bootstrapper takes care that the items are loaded in the specified order. Inspired by Loopback boot

Installation

npm i express-bootstrapper

Usage

app.js

'use strict';

let express = require('express');
let app = express();
let bootstrap = require('express-bootstrapper');

bootstrap(app, () => {
  app.listen(3000, () => {});
});

bootstrap.json

{
  "middleware": [
    "session",
    "authentication",
    "whatever"
  ]
}

The configuration contains one item with an array of filenames which are loaded (required) in the specified order. In the given example it loads middleware/session.js, middleware/authentication.js and then middleware/whatever.js

Debugging: This module uses the express-bootstrapper namespace for debugging. To enable debug mode do the following DEBUG=express-bootstrapper node app.js.

Parameter

  • app: express application (required)
  • callback: object (optional)