/*1* bootstrapper.js: Default logic for bootstrapping broadway applications.2*3* (C) 2011, Nodejitsu Inc.4* MIT LICENSE5*6*/78var broadway = require('../broadway');910//11// ### bootstrap (app, callback)12// #### @app {broadway.App} Application to bootstrap13// #### @callback {function} Continuation to respond to when complete.14// Bootstraps the specified `app`.15//16exports.bootstrap = function (app) {17app.options['config'] = app.options['config'] || {};18app.options['config'].init = false;19app.use(broadway.plugins.config);2021//22// Remove initializers run by the bootstrapper.23//24delete app.initializers['config'];25app.initlist.pop();2627//28// Set the current environment in the config29//30app.config.set('env', app.env);31};3233//34// ### bootstrap (app, callback)35// #### @app {broadway.App} Application to bootstrap36// #### @callback {function} Continuation to respond to when complete.37// Runs the initialization step of the bootstrapping process38// for the specified `app`.39//40exports.init = function (app, callback) {41broadway.plugins.config.init.call(app, function (err) {42if (err) {43return callback(err);44}4546if (app.config.get('handleExceptions')) {47app.use(broadway.plugins.exceptions, app.options['exceptions'] || {});48}4950app.use(broadway.plugins.directories, app.options['directories'] || {});51app.use(broadway.plugins.log, app.options['log'] || {});5253//54// Ensure the `directories` and `log` plugins initialize before55// any other plugins.56//57app.initlist.unshift.apply(58app.initlist,59app.initlist.splice(-2, 2)60);6162callback();63});64};656667