Synchronously call functions before other plugins, as they were some dependencies.
- tasks - an object with functions
If function returned false, then the whole process'd stop there.
server.register({
register: require('./hapi-init'),
options: {
tasks: {
setConfig: function () {
var config = {
prod: {
dbConnection: 'aws'
},
dev:
{
dbConnection: 'localhost'
}
};
if (process.env.NODE_ENV === 'prod') {
server.settings.app = config.prod;
}
else {
server.settings.app = config.dev;
}
},
sayHello: function () {
server.log(['log'], 'hello')
}
}
}
});
npm install hapi-init
- better error reporting/handling