Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50655 views
1
/*
2
* bootstrapper.js: Default logic for bootstrapping broadway applications.
3
*
4
* (C) 2011, Nodejitsu Inc.
5
* MIT LICENSE
6
*
7
*/
8
9
var broadway = require('../broadway');
10
11
//
12
// ### bootstrap (app, callback)
13
// #### @app {broadway.App} Application to bootstrap
14
// #### @callback {function} Continuation to respond to when complete.
15
// Bootstraps the specified `app`.
16
//
17
exports.bootstrap = function (app) {
18
app.options['config'] = app.options['config'] || {};
19
app.options['config'].init = false;
20
app.use(broadway.plugins.config);
21
22
//
23
// Remove initializers run by the bootstrapper.
24
//
25
delete app.initializers['config'];
26
app.initlist.pop();
27
28
//
29
// Set the current environment in the config
30
//
31
app.config.set('env', app.env);
32
};
33
34
//
35
// ### bootstrap (app, callback)
36
// #### @app {broadway.App} Application to bootstrap
37
// #### @callback {function} Continuation to respond to when complete.
38
// Runs the initialization step of the bootstrapping process
39
// for the specified `app`.
40
//
41
exports.init = function (app, callback) {
42
broadway.plugins.config.init.call(app, function (err) {
43
if (err) {
44
return callback(err);
45
}
46
47
if (app.config.get('handleExceptions')) {
48
app.use(broadway.plugins.exceptions, app.options['exceptions'] || {});
49
}
50
51
app.use(broadway.plugins.directories, app.options['directories'] || {});
52
app.use(broadway.plugins.log, app.options['log'] || {});
53
54
//
55
// Ensure the `directories` and `log` plugins initialize before
56
// any other plugins.
57
//
58
app.initlist.unshift.apply(
59
app.initlist,
60
app.initlist.splice(-2, 2)
61
);
62
63
callback();
64
});
65
};
66
67