improvent for invites

This commit is contained in:
Raven Scott
2025-12-17 21:13:46 -05:00
parent d3b61e9823
commit d1ee8b979a
6 changed files with 477 additions and 75 deletions
@@ -8,6 +8,7 @@ const { trackRequest, trackRequestWithTiming } = require('../../../maintenance/m
const { createErrorResponse } = require('../../../infrastructure/error_handler');
const execAsync = promisify(exec);
const { state } = require('../../../infrastructure/state');
async function handleDiagnosticsRoutes(req, res) {
const urlPath = req.urlPath || new URL(req.url, `https://${req.headers.host}`).pathname;
@@ -502,6 +503,30 @@ async function handleDiagnosticsRoutes(req, res) {
return true;
}
// GET /api/diagnostics/invites
if (method === 'GET' && urlPath === '/api/diagnostics/invites') {
try {
if (!state.diagnoseInviteIssues) {
res.writeHead(503, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ error: 'Invite diagnostics not available - system not fully initialized' }));
trackRequest(urlPath, false);
return true;
}
const diagnostics = state.diagnoseInviteIssues();
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify(diagnostics));
trackRequest(urlPath, true);
return true;
} catch (err) {
logError('DiagnosticsRoute', `Invite diagnostics error: ${err.message}`);
res.writeHead(500, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ error: err.message }));
trackRequest(urlPath, false);
return true;
}
}
return false;
}