This a module executing procedures, similar to Vertx healthchecks
$ npm install healthychecks
healthychecks();
var healthy = require('healthychecks'); var express = require('express'); var http = require('http'); var app = express(); var promise1 = () => Promise.resolve(3); var promise2 = () => Promise.resolve("ciaone"); //You can pass an array of procedures if you wanted var procedures = [{ root: "path1", procedureFunction: promise1 }, { root: "path2", procedureFunction: promise2 }] var healthyChecks = healthy(procedures) var procedureFunction = () => new Promise((resolve, reject) => { //Write your procedure code here. It can be anything //Resolve wih an optional status "UP": OK(myCustomObject) adds an OK status property to myCustomObject //You can also reject with an optional status "DOWN" with KO(myCustomObject). Adds "DOWN" status property resolve(healthyChecks.OK({ mycustomKey: "message or something else" })); }) //Register your procedure. Callback is optional healthyChecks.register("register path", procedureFunction, (error, procedureEntry) => { //procedureEntry holds the procedure registered at "register path" if (procedureEntry) { console.log(procedureEntry) } else { console.log(error) } }); //Register the handler like you would with an express handler app.use("/anypath", healthyChecks.createHandler()) app.listen(80, () => { var options = { port: 80, host: "localhost", method: 'GET', path: '/anypath', } http.request(options, (res) => { let response = ''; res.on('data', (chunk) => response += chunk); res.on('error', (error) => console.log(error)); res.on('end', () => { //for the example purpose, unregister the procedure when done //the root parameter must be the same as the registration's //expect [3,"ciaone",{"mycustomKey":"message or something else","status":"UP"}] healthyChecks.unregister("register path",(err,procedureEntry)=>{ //Callback for catching any errors or to hold onto the unregistered procedure. Optional }); }); }).on('error', (error) => console.log(error)).end(); });