Comparing version 5.1.1 to 5.1.2
@@ -30,22 +30,9 @@ var Hapi = require('hapi'); | ||
//server.ext('onRequest', function (request, reply) { | ||
// | ||
// if (request.connection.info.protocol === 'http') { | ||
// return reply.redirect('https://' + request.headers.host + request.url.path).permanent(); | ||
// } | ||
// | ||
// reply.continue(); | ||
//}); | ||
server.on('request-internal', function (request, event, tags) { | ||
if (tags.received) { | ||
console.log('new request'); | ||
} | ||
}); | ||
server.ext('onRequest', function (request, reply) { | ||
console.log('onRequest'); | ||
if (request.connection.info.protocol === 'http') { | ||
return reply.redirect('https://' + request.headers.host + request.url.path).permanent(); | ||
} | ||
reply.continue(); | ||
reply.continue(); | ||
}); | ||
@@ -52,0 +39,0 @@ |
@@ -116,3 +116,3 @@ // Load modules | ||
var item = this.settings.reporters[i] || {}; | ||
var item = this.settings.reporters[i]; | ||
var reporter; | ||
@@ -119,0 +119,0 @@ |
@@ -40,3 +40,3 @@ // Declare internals | ||
var port = request.connection.info.port; | ||
var statusCode = request.response.statusCode; | ||
var statusCode = request.response && request.response.statusCode; | ||
@@ -51,4 +51,6 @@ this._responseTimes[port] = this._responseTimes[port] || { count: 0, total: 0, max: 0 }; | ||
this._requests[port].statusCodes[statusCode] = this._requests[port].statusCodes[statusCode] || 0; | ||
this._requests[port].statusCodes[statusCode]++; | ||
if (statusCode) { | ||
this._requests[port].statusCodes[statusCode] = this._requests[port].statusCodes[statusCode] || 0; | ||
this._requests[port].statusCodes[statusCode]++; | ||
} | ||
}; | ||
@@ -55,0 +57,0 @@ |
{ | ||
"name": "good", | ||
"description": "Server and process monitoring plugin", | ||
"version": "5.1.1", | ||
"version": "5.1.2", | ||
"repository": "git://github.com/hapijs/good", | ||
@@ -22,3 +22,3 @@ "main": "index", | ||
"hoek": "2.x.x", | ||
"joi": "4.x.x" | ||
"joi": "5.x.x" | ||
}, | ||
@@ -25,0 +25,0 @@ "peerDependencies": { |
@@ -28,3 +28,3 @@ ![good Logo](https://raw.github.com/spumko/good/master/images/good.png) | ||
- `[opsInterval]` - the interval in milliseconds to sample system and process performance metrics. Minimum is _100ms_. Defaults to _15 seconds_. | ||
- `[requestsEvent]` - the event type used to capture completed requests. Defaults to 'tail'. Options are: | ||
- `[responseEvent]` - the event type used to capture completed requests. Defaults to 'tail'. Options are: | ||
- 'response' - the response was sent but request tails may still be pending. | ||
@@ -31,0 +31,0 @@ - 'tail' - the response was sent and all request tails completed. |
@@ -268,8 +268,9 @@ // Load modules | ||
var one = new GoodReporter(); | ||
var two; | ||
var one = { | ||
reporter: Hoek.ignore | ||
}; | ||
options.reporters = [one, two]; | ||
options.reporters = [one]; | ||
expect(function( ){ | ||
expect(function() { | ||
@@ -276,0 +277,0 @@ monitor = new Monitor(new Hapi.Server(), options); |
@@ -75,5 +75,3 @@ // Load modules | ||
expect(network._requests[port].statusCodes[200]).to.equal(20); | ||
expect(network._responseTimes[port]).to.exist(); | ||
port = usedPorts.shift(); | ||
@@ -326,2 +324,37 @@ } | ||
}); | ||
it('does not throw if request.response is null', function (done) { | ||
var server = new Hapi.Server(); | ||
server.connection({ host: 'localhost' }); | ||
server.route({ | ||
method: 'GET', | ||
path: '/', | ||
handler: function (request, reply) { reply(); } | ||
}); | ||
// force response to be null to mimic client disconnect | ||
server.on('response', function (request) { | ||
request.response = null; | ||
}); | ||
var network = new NetworkMonitor.Monitor(server); | ||
server.start(function () { | ||
Http.get({ | ||
path: '/', | ||
host: server.info.host, | ||
port: server.info.port | ||
}, function () { | ||
expect(network._requests[server.info.port]).to.exist(); | ||
expect(network._requests[server.info.port].total).to.equal(1); | ||
expect(network._requests[server.info.port].statusCodes).to.deep.equal({}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
2
123292
23
1615