asclepius

0.0.2 • Public • Published

Asclepius

Asclepius is a healthcheck module that allows you to define functions that report back their status. Much like the famed doctor of mythology, it will diagnose and prescribe fixes for whatever ails your applications.

API

// some base types
type resultType = { healthyType: bool, name: string, reason: string };
type healthcheckType = () => Promise<resultType>;
type resultsType = { [string]: { healthy: bool, reason: string } };

asclepius.healthcheck(name, check, timeoutDelay)

string -> (void -> Promise<mixed>) -> ?number -> healthcheckType

asclepius.makeRunner(healthchecks: Array<>)

Array<healthcheckType> -> void -> Promise<{ healthy: bool, results: resultsType }>

asclepius.makeRoute()

Array<healthcheckType> -> expressRoute

Example

const { healthcheck, makeRoute } = require('asclepius');
const canHitDatabase = healthcheck('canHitDatabase', () => db.query('select current_timestamp'));
const canHitRedis = healthcheck('canHitRedis', () => redis.get('__not_a_key__'));

app.get('/health', makeRoute([canHitDatabase, canHitRedis]));

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.2
    310
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.2
    310
  • 0.0.1
    1

Package Sidebar

Install

npm i asclepius

Weekly Downloads

311

Version

0.0.2

License

MIT

Last publish

Collaborators

  • bassjacob