import { Router } from "express";
import { getPoolStats } from "../services/browser.js";

export const healthRouter = Router();

healthRouter.get("/", (_req, res) => {
  const pool = getPoolStats();
  res.json({
    status: "ok",
    version: "0.2.1",
    pool: {
      size: pool.poolSize,
      active: pool.totalPages - pool.availablePages,
      available: pool.availablePages,
      queueDepth: pool.queueDepth,
      pdfCount: pool.pdfCount,
      restarting: pool.restarting,
      uptimeSeconds: Math.round(pool.uptimeMs / 1000),
    },
  });
});
