import { Router, Request, Response } from 'express';
import { authenticate, requireRole } from '../../middleware/auth';
import { getCACert } from '../../services/certificate.service';

const router = Router();

/**
 * GET /api/certificates/ca
 * Get the CCP CA public certificate (for manual agent setup).
 */
router.get('/ca', authenticate, requireRole('SUPER_ADMIN'), async (_req: Request, res: Response) => {
  const ca = await getCACert();
  res.json(ca);
});

export default router;
