Closed makusan closed 8 years ago
What version of good? Can I see your config setup?
Hi, here's my config, i'm running nodejs on Windows 10 x64
maku@FALCON MINGW64 ~/Documents/NodeProjects/hapijs/myproject
$ node -v && npm -v
v6.2.0
3.9.0
// Exactly the same from tutorial
// server.js
'use strict';
const Hapi = require('hapi');
const Good = require('good');
const server = new Hapi.Server();
server.connection({ port: 3000 });
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
reply('Hello, world!');
}
});
server.route({
method: 'GET',
path: '/{name}',
handler: function (request, reply) {
reply('Hello, ' + encodeURIComponent(request.params.name) + '!');
}
});
server.register({
register: Good,
options: {
reporters: {
console: [{
module: 'good-squeeze',
name: 'Squeeze',
args: [{
response: '*',
log: '*'
}]
}, {
module: 'good-console'
}, 'stdout']
}
}
}, (err) => {
if (err) {
throw err; // something bad happened loading the plugin
}
server.start((err) => {
if (err) {
throw err;
}
server.log('info', 'Server running at: ' + server.info.uri);
});
});
// package.json :
{
"name": "myproject",
"version": "0.0.1",
"description": "HapiJS Web App Tutorial",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/makusan/hapijs-tutorial/tutorial.git"
},
"author": "Makusan <makufx@gmail.com>",
"license": "MIT",
"dependencies": {
"good": "^7.0.0",
"good-console": "^6.1.1",
"good-squeeze": "^3.0.1",
"hapi": "^13.4.0",
"inert": "^4.0.0"
}
}
Try adding and empty ops
object to your options into good. I think we have a bug here, but I'm trying to just get this working for you right now.
How should i put that? Sorry, kinda new into this.
Thanks for your reply.
options: {
reporters: {
console: [{
module: 'good-squeeze',
name: 'Squeeze',
args: [{
response: '*',
log: '*'
}]
}, {
module: 'good-console'
}, 'stdout']
},
ops: {}
}
Looks like these options throw an error for interval being set to an invalid value (Running good@7.0.0 and good-console@6.1.1)
Error: interval must be less than 2147483648
const opts = options: {
ops: {},
reporters: {
console: [{
module: 'good-console',
args: [{ log: ['error', 'medium'], response: '*' }]
}, 'stdout']
}
}
Here is a working example of the Good setup for the tutorial - not the ops -> interval .. this runs fine for me.
server.register({ register: Good, options: { ops: { interval: 1000 }, reporters: { console: [{ module: 'good-squeeze', name: 'Squeeze', args: [{ response: '*', log: '*' }] }, { module: 'good-console' }, 'stdout'] } }
The interval
object isn't required. There are defaults and you should only set it if you need something other than the defaults. This bug was fixed in version 7.0.1.
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
Hi,
I was just following the hapijs tutorial and i got this error after adding the logging part "good". When trying to run the node server, the following errors occurred. What should i do?