Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.get(config.brokerHealthcheckPath || '/healthcheck', (req, res) => {
// healthcheck state depends on websocket connection status
// value of primus.Spark.OPEN means the websocket connection is open
const isConnOpen = (io.readyState === primus.Spark.OPEN);
const status = isConnOpen ? 200 : 500;
const data = {
ok: isConnOpen,
websocketConnectionOpen: isConnOpen,
brokerServerUrl: io.url.href,
version,
};
return res.status(status).json(data);
});