Add /health endpoint

This commit is contained in:
Christopher Cookman 2025-04-19 08:53:17 -06:00
parent 453442d92f
commit 0d5e5c65a3

View file

@ -13,6 +13,7 @@ const fs = require('fs');
const path = require('path');
const markdown = require('markdown-it')();
const ejs = require('ejs');
const { connect } = require('http2');
const app = express();
expressWs(app);
@ -40,6 +41,19 @@ app.get("/", (req, res) => {
res.render('docViewer', {title: 'Websocket Docs', htmlContent: htmlContent});
});
});
var socketStatus;
app.get('/health', (req, res) => {
res.status(200).json({
status: socketStatus,
connections: wsConnections.length,
uptime: process.uptime(),
messages: messages,
errCount: errCount,
startup: startup,
startTime: startTimestap,
uuid: curUUID,
});
});
global.wsConnections = [];
var roomList = [];
@ -484,6 +498,7 @@ xmpp.on("stanza", (stanza) => {
});
xmpp.on("status", (status) => {
socketStatus = status;
console.log(`${colors.cyan("[INFO]")} XMPP Status is ${status}`);
// Broadcast a message to all connected WebSocket clients
wsConnections.forEach((connection) => {