bugbot comment

This commit is contained in:
Vikhyath Mondreti
2026-01-29 17:45:24 -08:00
parent 1fbe3029f4
commit df1a951e98

View File

@@ -17,15 +17,21 @@ interface Logger {
export function createHttpHandler(roomManager: IRoomManager, logger: Logger) {
return async (req: IncomingMessage, res: ServerResponse) => {
if (req.method === 'GET' && req.url === '/health') {
const connections = await roomManager.getTotalActiveConnections()
res.writeHead(200, { 'Content-Type': 'application/json' })
res.end(
JSON.stringify({
status: 'ok',
timestamp: new Date().toISOString(),
connections,
})
)
try {
const connections = await roomManager.getTotalActiveConnections()
res.writeHead(200, { 'Content-Type': 'application/json' })
res.end(
JSON.stringify({
status: 'ok',
timestamp: new Date().toISOString(),
connections,
})
)
} catch (error) {
logger.error('Error in health check:', error)
res.writeHead(503, { 'Content-Type': 'application/json' })
res.end(JSON.stringify({ status: 'error', message: 'Health check failed' }))
}
return
}