express-bootstrapper
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 = ;let app = ;let bootstrap = ; ;
bootstrap.json
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)