2026-06-01 21:44:29 +07:00
|
|
|
import type { Router } from "express";
|
|
|
|
|
import express from "express";
|
2026-07-26 14:27:36 +07:00
|
|
|
import { collectDefaultMetrics } from "prom-client";
|
2026-06-10 20:56:16 +07:00
|
|
|
import { handleHealthCheck, handleMetrics } from "./health.controller.js";
|
|
|
|
|
|
|
|
|
|
// Initialize default Node.js runtime metrics (event loop lag, memory, GC, etc.)
|
|
|
|
|
// Called once at module load, not per-request.
|
|
|
|
|
collectDefaultMetrics();
|
2026-06-01 21:44:29 +07:00
|
|
|
|
|
|
|
|
export function createHealthRouter(): Router {
|
|
|
|
|
const router = express.Router();
|
|
|
|
|
|
|
|
|
|
// GET /api/health
|
|
|
|
|
router.get("/health", handleHealthCheck);
|
|
|
|
|
|
2026-06-10 20:56:16 +07:00
|
|
|
// GET /api/metrics — Prometheus scrape endpoint
|
|
|
|
|
router.get("/metrics", handleMetrics);
|
|
|
|
|
|
2026-06-01 21:44:29 +07:00
|
|
|
return router;
|
|
|
|
|
}
|