Enhance health check and inventory endpoints: include bridge connection status and web client count
This commit is contained in:
@@ -74,7 +74,13 @@ const server = createServer(app);
|
||||
|
||||
// Health check
|
||||
app.get('/api/health', (req, res) => {
|
||||
res.json({ status: 'ok', lastUpdate, uptime: process.uptime() });
|
||||
res.json({
|
||||
status: 'ok',
|
||||
lastUpdate,
|
||||
uptime: process.uptime(),
|
||||
bridgeConnected: bridgeClients.size > 0,
|
||||
webClients: webClients.size,
|
||||
});
|
||||
});
|
||||
|
||||
// Get current inventory state
|
||||
@@ -89,6 +95,7 @@ app.get('/api/inventory', (req, res) => {
|
||||
craftable: craftableRecipes,
|
||||
craftTurtleOk,
|
||||
lastUpdate,
|
||||
bridgeConnected: bridgeClients.size > 0,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -396,6 +403,7 @@ function updateStateFromBridge(data) {
|
||||
craftable: craftableRecipes,
|
||||
craftTurtleOk,
|
||||
lastUpdate,
|
||||
bridgeConnected: bridgeClients.size > 0,
|
||||
});
|
||||
|
||||
// Persist to SQLite (debounced — won't block the broadcast)
|
||||
@@ -489,6 +497,7 @@ wss.on('connection', (ws, req) => {
|
||||
craftable: craftableRecipes,
|
||||
craftTurtleOk,
|
||||
lastUpdate,
|
||||
bridgeConnected: bridgeClients.size > 0,
|
||||
}));
|
||||
|
||||
ws.on('pong', () => { ws.isAlive = true; });
|
||||
|
||||
Reference in New Issue
Block a user