← back to Dw Boardroom Governance

src/api/routes/escalations.ts

37 lines

import { Router, Request, Response } from 'express';
import { getEscalationLog, getActiveEscalations, checkEscalations } from '../../agents/escalation';

const router = Router();

// GET /api/escalations — full log
router.get('/', async (_req: Request, res: Response) => {
  try {
    const log = await getEscalationLog();
    res.json(log);
  } catch (err: any) {
    res.status(500).json({ error: err.message });
  }
});

// GET /api/escalations/active — active only
router.get('/active', async (_req: Request, res: Response) => {
  try {
    const active = await getActiveEscalations();
    res.json(active);
  } catch (err: any) {
    res.status(500).json({ error: err.message });
  }
});

// POST /api/escalations/check — manual trigger
router.post('/check', async (_req: Request, res: Response) => {
  try {
    const result = await checkEscalations();
    res.json(result);
  } catch (err: any) {
    res.status(500).json({ error: err.message });
  }
});

export default router;