middle-pinger
Yet another tiny healthcheck middleware designed for express 4.x
Quick start
Install
npm install --save middle-pinger
Use
const express = ;const ping = ; const app = ; app; app;
Example
curl http://localhost:8080/ping
HTTP/1.1 200 OK
content-type: application/json
options
The ping middleware accepts an options
object which can control the ping path as well as the value of the JSON response.
options.path
String
. Defaults to /ping
.
const express = ;const ping = ; const app = ; const options = path: '/healthcheck'; app;
options.responder(req)
Function
. This function must return a JSON.stringify
-able value. Defaults to an Object
that contains three keys: ip
set to the value of req.ip
, pong
set to the value of Date.now()
, and uptime
set to the difference between when the middleware was instantited and now (in milliseconds).
const express = ;const ping = ; const app = ; const options = headers: reqheaders status: 'ok' ; app;
Hat tips
@jden
for first version used within@agilemd
products@izs
and pingme