0.1.3 • Published 8 years ago

healthkit v0.1.3

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

healthkit NPM Module

Health check utility library

Linux Build Windows Build

Coverage Status Dependency Status bitHound Overall Score

Install

npm install --save healthkit

Example

Checks for signal file and if it exists responds with 404 code (to signal to load balancer to drain incoming requests), if signal file doesn't exist, checks for upstream endpoint, and returns 200 if endpoint is reachable and responds with successful http response. Otherwise returns 500 code when all previous checks fail.

var healthkit = require('healthkit');

var myAppChecks = [
	// first check for lets-drain signal file
  {
    status: 404, // respond with 404 if file present
    file: '/etc/consul/test_file.exists'
  },
  // second check for underlying endpoint
  // proceeded here if previous check failed
  {
    status: 200, // respond with 200 if endpoint responds with successful code (200-299)
    http: 'http://simple.url/endpoint'
  },
  // third (empty, default) check
  // proceeded here if previous check failed
  {
    status: 500 // everything failed, fail the health check
  }
];

// Express handler
app.get('/health', function(req, res)
{
  healthkit(myAppChecks, function(code, result)
  {
    res.status(code).send(result);
  });
});

Want to Know More?

More examples can be found in test folder.

Or open an issue with questions and/or suggestions.

License

HealthKit is released under the MIT license.