cloudcms-server
Version:
Cloud CMS Application Server Module
59 lines (47 loc) • 1.33 kB
JavaScript
var util = require("../../util/util");
/**
* Healthcheck middleware.
*
* @type {Function}
*/
exports = module.exports = function()
{
var handle = function(res)
{
res.status(200).json({
"ok": true
});
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// RESULTING OBJECT
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
var r = {};
/**
* Handles healthcheck calls.
*
* @return {Function}
*/
r.handler = function()
{
return util.createHandler("healthcheck", function(req, res, next, stores, cache, configuration) {
var handled = false;
if (req.method.toLowerCase() === "get") {
if ( req.url.indexOf("/healthcheck") === 0 ||
req.url.indexOf("/_healthcheck") === 0 ||
req.url.indexOf("/_hc") === 0 ||
req.url.indexOf("/_health") === 0)
{
handle(res);
handled = true;
}
}
if (!handled)
{
next();
}
});
};
return r;
}();