0.0.4 • Published 6 years ago

seer-checks v0.0.4

Weekly downloads
23
License
Copyright
Repository
github
Last release
6 years ago

SEER Plugin for Node.js Build Status

For use with SEER platform.

Installation

$ yarn add seer-checks

Usage

Koa & Express are supported. Usage across http frameworks looks pretty much the same.

Koa

...
const seer = require('seer-checks')

let myApp = seer(new Koa(), {
  framework: 'koa',
  statusUrl: '/api/v1/__status__', // optional
  debounce: 30000, // debounce checks
  checks: [{
    name: 'some-ping',
    retries: 5, // number of retries allowed
    check: async () => {
      await someCheck();
      // return or throw an error
    }
  }]
})

Express

...
const seer = require('seer-checks')

let myApp = seer(Express(), {
  framework: 'express',
  statusUrl: '/api/__status__', // optional
  debounce: 30000, // debounce checks
  checks: [{
    name: 'some-ping',
    retries: 5, // number of retries allowed
    check: async () => {
      await someCheck();
      // return or throw an error
    }
  }]
})

Barebones - You can get all the power of retries, debouncing, caching, etc. without using routing.

...
const seer = require('seer-checks')

let runChecks = seer(null, {
  framework: 'barebones',
  debounce: 30000, // debounce checks
  checks: [{
    name: 'some-ping',
    retries: 5, // number of retries allowed
    check: async () => {
      await someCheck();
      // return or throw an error
    }
  }]
})

someApplicationRouter.get('whatevermystatus/url/is', function*() {
  let result = yield runChecks()
  // do something with the request
})

Retrieving a status

GET https://whatever-my-api-is.com/api/__status__/ will return a JSON object. If no checks are passed to the plugin, you get a heartbeat check by default.

{
  "status": "ok",
  "healthy": true,
  "seer-version": "0.0.1"
}

If checks have been passed to the plugin, the object will look like:

{
  "status": "ok",
  "healthy": true,
  "seer-version": "0.0.1",
  "checks": {
    "my-check-name": {
      "healthy": false,
      "time": 1230,
      "error": "Some error was thrown"
    },
    "another-check": {
      "healthy": true,
      "time": 400
    }
  }
}
0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago