mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
41 lines
2.1 KiB
JavaScript
41 lines
2.1 KiB
JavaScript
/***********************************************************************************************************************************************************************
|
|
* File Name: health.controller.js
|
|
* Type of Program: Controller
|
|
* Description: HTTP layer for health check endpoints. No check logic lives here —
|
|
* all checks and payload assembly are handled by services/health.service.js.
|
|
*
|
|
* GET /api/health → dashboard (rich human-readable, runs all checks)
|
|
* GET /api/health/ready → readiness (compact machine-readable, 200 or 503)
|
|
*
|
|
* Author: Kenneth Obsequio (@lash0000)
|
|
* Date Created: Jun. 20, 2026
|
|
***********************************************************************************************************************************************************************/
|
|
"use strict";
|
|
|
|
const { runDashboard, runReadiness } = require('../services/health.service');
|
|
|
|
// ─── GET /api/health ─────────────────────────────────────────────────────────
|
|
//
|
|
// Human-readable dashboard — runs all checks and returns full context:
|
|
// app metadata, system info, and per-service connection details.
|
|
//
|
|
// Used by: developers, monitoring dashboards, manual inspection.
|
|
|
|
exports.dashboard = async (_req, res) => {
|
|
const { httpStatus, body } = await runDashboard();
|
|
res.status(httpStatus).json(body);
|
|
};
|
|
|
|
// ─── GET /api/health/ready ───────────────────────────────────────────────────
|
|
//
|
|
// Machine-readable readiness check — compact response, meaningful HTTP status.
|
|
// HTTP 200 → healthy or degraded (safe to route traffic)
|
|
// HTTP 503 → unhealthy (critical dependency down; do not route traffic here)
|
|
//
|
|
// Used by: Kubernetes readiness probe, load balancers, deployment gate scripts.
|
|
|
|
exports.readiness = async (_req, res) => {
|
|
const { httpStatus, body } = await runReadiness();
|
|
res.status(httpStatus).json(body);
|
|
};
|