Skip to content

Health-check middleware for Express.

License

Notifications You must be signed in to change notification settings

Entercom/health-check

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Health Check

Health-check middleware for Express.

Returns either HTTP 200 or 500.

Features

  • Fetches fields asynchronously (in parallel)
  • Supports Promises
  • Reports errors individually
  • Custom and optional (non-failing) fields

Usage

var express = require('express'),
  healthCheck = require('@entercom/health-check');

express.use(healthCheck());

exposes /health-check with the following information:

{
}

Environment variables

Environment variables can be reported if they're useful.

var express = require('express'),
  healthCheck = require('@entercom/health-check');

express.use(healthCheck({
  env: [
    'REDIS_HOST',
    'ELASTIC_HOST'
  ]
}));

Custom fields

Can add custom fields to be reported. Thrown errors in custom fields will return a 500.

var express = require('express'),
  healthCheck = require('@entercom/health-check');

express.use(healthCheck({
  stats: {
    searchExists: function () {
      var searchService = require('./search');

      return searchService && searchService.ping();
    }
  }
}));

Required fields

Missing fields will return a 500.

var express = require('express'),
  healthCheck = require('@entercom/health-check');

express.use(healthCheck({
  required: [
    'host',
    'someName',
    'REDIS_HOST'
  ],
  stats: {
    someName: someFunction
  },
  env: [
    'REDIS_HOST'
  ]
}));

Install

npm install --save @entercom/health-check

About

Health-check middleware for Express.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%