simple-health
v0.0.99
Published
Simple middleware module for health cheking
Downloads
6
Readme
Simple-Health
Simple middleware module for health cheking.
Install with npm
:
$ npm install simple-health --save
Quick start
Import npm module:
const SimpleHealth = require('simple-health');
Configure:
let health = new SimpleHealth({
data: [
{key: 'name', value: 'module_name', public: true}
]
});
Initialize middleware:
app.use( health );
Follow the link:
http://YOUR_HOST/health
Config
limit - timeout for response in milliseconds (1000)
url - URL for request ('/health')
headers - object with response headers
data - array with settings for response object
Data config:
key - field key
value - field value (simple type, function or Promise)
public - show field without apikey
promise - for promise function
Example
{
key: 'date',
value: (new Date).getTime()
},
{
key: 'alive',
value: function () {
return (new Date).getTime() - this.result.date
}
},
{
key: 'reportsLink',
value: function() {
return new Promise((success, fail)=>{
setTimeout(()=>success(true), 700);
})
},
promise: true
}
Use this.result to access other keys of response object.