@spokedev/healthchicken

0.0.9 • Public • Published

healthchicken

pipeline status coverage report

Healthchicken is express middleware that binds routes to ${serviceName}/healthcheck/ping and ${serviceName}/healthcheck/ready. By default, if the app is healthy, these will always return 200 statuscodes and a {message: 'OK'} json body. You can also specify dependent services. These will be pinged by the ready route. If they are all good, the ready route will return a 200 else you are getting a 500.

Install

$ npm i @spokedev/healthchicken

Usage

Basic usage

const healthchicken = require("healthchicken");
const express = require("express");

const app = express();

app.use(healthchicken({
  serviceName: "cats_n_chickens"
}))

// we now have routes at `cats_n_chickens/healthcheck/ready` and `cats_n_chickens/healthcheck/ping`

Specifying dependent services

const healthchicken = require("healthchicken");
const express = require("express");

const app = express();

app.use(healthchicken({
  serviceName: "cats_n_chickens",
  dependentUrls: ["http://some-other.service"]
}))

// `cats_n_chickens/healthcheck/ready` will now ping `http://some-other.service/healthcheck/ping`
// and fail if it doesn't get a 2xx back.

Using a different prefix

const healthchicken = require("healthchicken");
const express = require("express");

const app = express();

app.use(healthchicken({
  serviceName: "cats_n_chickens",
  prefix: "deathwatch"
}))

// we now have routes at `cats_n_chickens/deathwatch/ready` and `cats_n_chickens/deathwatch/ping`

Adding in version

If the version is found as an environment variable as SERVICE_VERSION then it will be output as part of the ready healthcheck.

Readme

Keywords

none

Package Sidebar

Install

npm i @spokedev/healthchicken

Weekly Downloads

2

Version

0.0.9

License

MIT

Unpacked Size

6.04 kB

Total Files

3

Last publish

Collaborators

  • spokedev_rw
  • spokedev_ro