hapi-lbstatus
Advanced tools
Comparing version 2.1.2 to 3.0.0
10
index.js
var service = require('./lib/provider'); | ||
exports.register = function(plugin, options, next){ | ||
plugin.route( | ||
exports.register = function(server, options, next){ | ||
server.route( | ||
{ | ||
@@ -10,3 +10,3 @@ method: "GET", | ||
handler: function(request, reply) { | ||
service.lbstatus(plugin.servers, options, function(result){ | ||
service.lbstatus(request.server, options, function(result){ | ||
reply(result.body).code(result.code); | ||
@@ -19,4 +19,4 @@ }); | ||
plugin.expose('lbstatus', function(cb){ | ||
service.lbstatus(plugin.servers, options, function(result){ | ||
server.expose('lbstatus', function(cb){ | ||
service.lbstatus(server, options, function(result){ | ||
cb(result.code === 200); | ||
@@ -23,0 +23,0 @@ }); |
var fs = require("fs"), | ||
async = require("async"), | ||
@@ -33,3 +32,3 @@ getStatus = function(applicationStatus, dependenciesStatusCode){ | ||
lbstatus = function(servers, config, callback){ | ||
lbstatus = function(server, config, callback){ | ||
var on = config.on || "ON"; | ||
@@ -39,12 +38,7 @@ var off = config.off || "ON"; | ||
async.forEach(servers, function(server, done){ | ||
applicationOffLine(server, config.file, function(file){ | ||
checkDependencies(server, config.liveness, config.headers, function(statusCode){ | ||
results.push(getStatus(file, statusCode)); | ||
done(); | ||
}); | ||
applicationOffLine(server, config.file, function(file){ | ||
checkDependencies(server, config.liveness, config.headers, function(statusCode){ | ||
var success = getStatus(file, statusCode); | ||
callback({ body: success ? on : off, code: success ? 200 : 503}); | ||
}); | ||
}, function(){ | ||
var failed = results.filter(function(i){ return i === false; }).length > 0; | ||
callback({ body: failed ? off : on, code: failed ? 503 : 200}); | ||
}); | ||
@@ -51,0 +45,0 @@ }; |
{ | ||
"name": "hapi-lbstatus", | ||
"version": "2.1.2", | ||
"version": "3.0.0", | ||
"description": "lbstatus plugin for hapi", | ||
@@ -31,5 +31,6 @@ "main": "index.js", | ||
}, | ||
"dependencies": { | ||
"async": "^0.9.0" | ||
"dependencies": {}, | ||
"peerDependencies": { | ||
"hapi": "^8.0.0" | ||
} | ||
} |
describe('lbstatus tests', function(){ | ||
var should = require('should'), | ||
provider = require('../lib/provider'), | ||
servers = [{ | ||
server = { | ||
inject: function(options, callback){ | ||
@@ -9,4 +9,4 @@ callback({ statusCode: 200 }); | ||
log: function(){} | ||
}], | ||
badservers = [{ | ||
}, | ||
badserver = { | ||
inject: function(options, callback){ | ||
@@ -16,3 +16,3 @@ callback({ statusCode: 500 }); | ||
log: function(){} | ||
}]; | ||
}; | ||
@@ -50,3 +50,3 @@ it('should register the route', function(){ | ||
it('should read the file', function(done){ | ||
provider.lbstatus(servers, { | ||
provider.lbstatus(server, { | ||
file: __dirname + '/statusfile-on', | ||
@@ -64,3 +64,3 @@ liveness: '/my/app/123', | ||
it('should return off when the file says off', function(done){ | ||
provider.lbstatus(servers, { | ||
provider.lbstatus(server, { | ||
file: __dirname + '/statusfile-off', | ||
@@ -78,3 +78,3 @@ liveness: '/my/app/123', | ||
it('should return off when the file is missing', function(done){ | ||
provider.lbstatus(servers, { | ||
provider.lbstatus(server, { | ||
file: __dirname + '/statusfile-missing', | ||
@@ -92,3 +92,3 @@ liveness: '/my/app/123', | ||
it('should use the config value for returning the string', function(done){ | ||
provider.lbstatus(servers, { | ||
provider.lbstatus(server, { | ||
file: __dirname + '/statusfile-on', | ||
@@ -106,3 +106,3 @@ liveness: '/my/app/123', | ||
it('should return off when the liveness check fails', function(done){ | ||
provider.lbstatus(badservers, { | ||
provider.lbstatus(badserver, { | ||
file: __dirname + '/statusfile-on', | ||
@@ -109,0 +109,0 @@ liveness: '/my/app/123', |
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
9966
194
+ Addedaccept@1.1.0(transitive)
+ Addedammo@1.0.1(transitive)
+ Addedb64@2.0.1(transitive)
+ Addedboom@2.10.1(transitive)
+ Addedcall@2.0.2(transitive)
+ Addedcatbox@4.3.0(transitive)
+ Addedcatbox-memory@1.1.2(transitive)
+ Addedcontent@1.0.2(transitive)
+ Addedcryptiles@2.0.5(transitive)
+ Addedh2o2@4.0.2(transitive)
+ Addedhapi@8.8.1(transitive)
+ Addedheavy@3.0.1(transitive)
+ Addedhoek@2.16.3(transitive)
+ Addedinert@2.1.6(transitive)
+ Addediron@2.1.3(transitive)
+ Addedisemail@1.2.0(transitive)
+ Addeditems@1.1.1(transitive)
+ Addedjoi@6.10.1(transitive)
+ Addedkilt@1.1.1(transitive)
+ Addedlru-cache@2.6.5(transitive)
+ Addedmime-db@1.53.0(transitive)
+ Addedmimos@2.0.2(transitive)
+ Addedmoment@2.30.1(transitive)
+ Addednigel@1.0.1(transitive)
+ Addedpeekaboo@1.0.0(transitive)
+ Addedpez@1.0.0(transitive)
+ Addedqs@4.0.0(transitive)
+ Addedshot@1.7.0(transitive)
+ Addedstatehood@2.1.1(transitive)
+ Addedsubtext@1.1.1(transitive)
+ Addedtopo@1.1.0(transitive)
+ Addedvise@1.0.0(transitive)
+ Addedvision@2.0.1(transitive)
+ Addedwreck@6.3.0(transitive)
- Removedasync@^0.9.0
- Removedasync@0.9.2(transitive)