@juntoz/koa-health-probe
v1.0.7
Published
Health probe for Koa
Downloads
3
Keywords
Readme
koa-health-probe
Health probe for Koa that uses http://github.com/juntoz/koa-last-request to provide a bit meaningful info
Usage
const Koa = require('koa');
const KoaRouter = require('koa-router');
const setupKoaHealthProbe = require('koa-health-probe');
// create koa app
var app = new Koa();
var router = new KoaRouter();
// setup the probe
setupKoaHealthProbe(router, youroptions);
// setup routes on the app
app.use(router.routes()).use(router.allowedMethods());
Options
var options = {
// route path to use, default is /tools/probe
path: string,
// function to customize the object returned for every probe tryout
onRequest: function
}
Optional dependency on http://github.com/juntoz/koa-last-request
The package koa-last-request
is used to provide the last timestamp the koa app has processed something (you can configure it to ignore certain paths, for example, this probe :)).
If the package is not present, then the timestamp is not generated.
When you setup the koa-last-request, do not forget to add this probe's path to be ignored, this way only "real" requests get logged.
// require
const lastreq = require("koa-last-request");
// setup
var koa = new Koa();
koa.use(lastreq({ pathsToIgnore: ['tools/probe'] });