Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nymdev/health-check

Package Overview
Dependencies
Maintainers
23
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nymdev/health-check

routes for a standardized health-check

  • 0.1.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
139
increased by19.83%
Maintainers
23
Weekly downloads
 
Created
Source

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('@nymdev/health-check');

express.use(healthCheck());

exposes /health-check with the following information:

{
  "nodeVersionExpected": "4.0.0",
  "nodeVersionActual": "4.2.1",
  "memoryUsage": {
    "rss": 66609152,
    "heapTotal": 58772224,
    "heapUsed": 28870104
  },
  "uptime": 14.538,
  "totalMem": 17179869184,
  "freeMem": 1396756480,
  "loadAvg": [
    1.736328125,
    1.65234375,
    1.76123046875
  ],
  "heap": {
    "total_heap_size": 58772224,
    "total_heap_size_executable": 7340032,
    "total_physical_size": 58772224,
    "total_available_size": 1483938640,
    "used_heap_size": 28890440,
    "heap_size_limit": 1535115264
  },
  "host": "<some hostname>"
}

Environment variables

Environment variables can be reported if they're useful.

var express = require('express'),
  healthCheck = require('@nymdev/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('@nymdev/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('@nymdev/health-check');

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

Install

npm install --save @nymdev/health-check

Keywords

FAQs

Package last updated on 27 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc