-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
37 lines (30 loc) · 1.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var _ = require('lodash'),
path = require('path'),
caller = require('caller'),
Initializer = require('./lib/Initializer'),
ExpressInitializer = require('./lib/ExpressInitializer'),
/*jshint -W079 */
Promise = require('bluebird');
function expressInitializers(app, opts, done) {
opts = _.defaults(opts || {}, {
// Default to the initializers directory where we were called from
directory: path.join(path.dirname(caller()), 'initializers')
});
var init = new ExpressInitializer(opts);
return init.configureApp(app)
.then(function () {
if (_.isFunction(done)) {
done(null, app);
}
return app;
})
.catch(function (err) {
if (_.isFunction(done)) {
done(err);
}
return Promise.reject(err);
});
}
expressInitializers.ExpressInitializer = ExpressInitializer;
expressInitializers.Initializer = Initializer;
module.exports = expressInitializers;