71 lines
1.5 KiB
JavaScript
71 lines
1.5 KiB
JavaScript
import { Router } from 'express';
|
|
import { callAgent } from '../agentClient.js';
|
|
|
|
const router = Router();
|
|
|
|
const unavailable = {
|
|
status: 'unavailable',
|
|
summary: null,
|
|
message: 'Unavailable',
|
|
};
|
|
|
|
const adaptHealthSummary = (raw) => {
|
|
if (raw?.status !== 'ok' || !raw.service || !raw.version) {
|
|
return null;
|
|
}
|
|
return {
|
|
status: raw.status,
|
|
service: raw.service,
|
|
version: raw.version,
|
|
};
|
|
};
|
|
|
|
router.get('/status', async (req, res) => {
|
|
let health;
|
|
try {
|
|
const rawHealth = await callAgent('get_health', {});
|
|
const summary = adaptHealthSummary(rawHealth);
|
|
if (summary) {
|
|
health = { status: 'success', summary, message: 'Available' };
|
|
} else {
|
|
health = unavailable;
|
|
console.warn('[Console API] Platform health data has an unexpected shape.');
|
|
}
|
|
} catch (error) {
|
|
console.warn('[Console API] Platform health data is unavailable.');
|
|
health = unavailable;
|
|
}
|
|
|
|
res.json({
|
|
health,
|
|
buildStatus: unavailable,
|
|
platformState: unavailable,
|
|
});
|
|
});
|
|
|
|
router.get('/projects', (req, res) => {
|
|
res.json({
|
|
status: 'unavailable',
|
|
message: 'No project registry configured yet.',
|
|
projects: [],
|
|
});
|
|
});
|
|
|
|
router.get('/work-queue', (req, res) => {
|
|
res.json({
|
|
status: 'unavailable',
|
|
message: 'No ticket read model configured yet.',
|
|
tickets: [],
|
|
});
|
|
});
|
|
|
|
router.get('/approvals', (req, res) => {
|
|
res.json({
|
|
status: 'unavailable',
|
|
message: 'No approval read model configured yet.',
|
|
approvals: [],
|
|
});
|
|
});
|
|
|
|
export default router;
|