/**
 * Prometheus metrics endpoint for SentryAgent.ai AgentIdP.
 * Unauthenticated — intended for internal Prometheus scraping only.
 * Do NOT expose this endpoint on a public-facing network interface.
 */
import { Router, Request, Response } from 'express';
import { metricsRegistry } from '../metrics/registry.js';

/**
 * Creates and returns the Express router for the Prometheus metrics endpoint.
 * Returns metrics in Prometheus text exposition format.
 *
 * @returns Configured Express router.
 */
export function createMetricsRouter(): Router {
  const router = Router();

  router.get('/', async (_req: Request, res: Response): Promise<void> => {
    const metrics = await metricsRegistry.metrics();
    res.set('Content-Type', metricsRegistry.contentType);
    res.end(metrics);
  });

  return router;
}
