Can anyone explain the new format for the options json object that needs to be passed to the server.register()
method in hapijs?
This is how I structured my
server.register()
call.
server.register({
register: require('good'),
options: {
opsInterval: 5000,
reporters: [
{
reporter: require('good-file'),
events: { ops: '*'},
config: {
path: './logs',
prefix: 'hapi-process',
rotate: 'daily'
}
},
{
reporter: require('good-file'),
events: { response: '*' },
config: {
path: './logs',
prefix: 'hapi-requests',
rotate: 'daily'
}
},
{
reporter: require('good-file'),
events: { error: '*' },
config: {
path: './logs',
prefix: 'hapi-process',
rotate: 'daily'
}
}
]
}
}, function(err) {
console.log(err);
});
This is the error message I'm receiving:
Error: Invalid monitorOptions options child "reporters" fails because ["reporters" must be an object]
at Object.exports.assert (/home/rodrigo/Projetos/estudos/api/greetings-hapi/node_modules/hoek/lib/index.js:736:11)
at Object.exports.register (/home/rodrigo/Projetos/estudos/api/greetings-hapi/node_modules/good/lib/index.js:31:10)
at Object.target [as register] (/home/rodrigo/Projetos/estudos/api/greetings-hapi/node_modules/hapi/node_modules/joi/lib/object.js:77:34)
at each (/home/rodrigo/Projetos/estudos/api/greetings-hapi/node_modules/hapi/lib/plugin.js:318:14)
at iterate (/home/rodrigo/Projetos/estudos/api/greetings-hapi/node_modules/hapi/node_modules/items/lib/index.js:36:13)
at Object.exports.serial (/home/rodrigo/Projetos/estudos/api/greetings-hapi/node_modules/hapi/node_modules/items/lib/index.js:39:9)
at internals.Plugin.register (/home/rodrigo/Projetos/estudos/api/greetings-hapi/node_modules/hapi/lib/plugin.js:321:11)
at Object.<anonymous> (/home/rodrigo/Projetos/estudos/api/greetings-hapi/server.js:26:8)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
It seems that "reporters" should be an object not an array. How should I structure it and what are the correct properties?