Skip to content

Health

The Health module provides uptime/probing endpoints for external monitoring (Kubernetes, load balancer, Sentry, etc.) and one admin endpoint to toggle the system-wide maintenance mode. The user-facing endpoints are @Public() and do not pass through the global ResponseInterceptor — the response is returned as-is via res.json(...). The admin endpoint follows the standard envelope and is guarded by an ACL permission.

PropertyValue
Base URL{HOST}/v1
AuthPublic for probe endpoints · Bearer JWT for admin maintenance toggle
Content-Typeapplication/json
Error envelopeProbe endpoints use the raw shape (see per-endpoint) · Admin endpoint uses the standard { "message", "statusCode", "error" }
ValidationGlobal ValidationPipe · whitelist: true, forbidNonWhitelisted: true
Related modulesinfrastructure, monitoring (Sentry, k8s probes)
Document versionv1 · 2026-05-20
AudienceInternal FE devs (status page widget) + ops/infra

Public endpoints do not require Bearer and are used for uptime monitoring / readiness probes. The admin endpoint POST /admin/maintenance/toggle enables / disables the in-memory maintenanceMode flag in HealthService — when active, all probe endpoints return maintenance status (HTTP 503).

MethodPathAuthSummary
GET/v1/healthpublicFull status (DB, Mongo, uptime, version)
GET/v1/statuspublicSimple status (ok / maintenance / degraded)
GET/v1/pingpublicSimple ping-pong
GET/v1/readypublicKubernetes readiness probe
GET/v1/livepublicKubernetes liveness probe
GET/v1/debug-sentrypublicTrigger a synthetic Sentry error (dev only)
POST/v1/admin/maintenance/togglebearerEnable/disable maintenance mode (admin)

Full system status: MySQL + MongoDB connectivity, uptime in seconds, version, and timestamp. Suitable for a status dashboard or in-depth check.

public

Response — 200 OK (all services healthy)

Section titled “Response — 200 OK (all services healthy)”
{
"status": "ok",
"message": "All systems operational",
"timestamp": "2026-05-20T10:30:00.000Z",
"version": "1.0.0",
"services": {
"database": { "status": "healthy", "responseTime": 15 },
"mongodb": { "status": "healthy", "responseTime": 8 }
},
"uptime": 3600
}

Response — 503 Service Unavailable (maintenance mode active)

Section titled “Response — 503 Service Unavailable (maintenance mode active)”
{
"status": "maintenance",
"message": "Service is currently under maintenance. Please try again later.",
"timestamp": "2026-05-20T10:30:00.000Z",
"version": "1.0.0",
"services": {
"database": { "status": "healthy" },
"mongodb": { "status": "healthy" }
},
"uptime": 3600
}

Response — 500 Internal Server Error (degraded — one service unhealthy)

Section titled “Response — 500 Internal Server Error (degraded — one service unhealthy)”
{
"status": "degraded",
"message": "Some services are experiencing issues",
"timestamp": "2026-05-20T10:30:00.000Z",
"version": "1.0.0",
"services": {
"database": { "status": "unhealthy" },
"mongodb": { "status": "healthy", "responseTime": 8 }
},
"uptime": 3600
}

The response shape is not wrapped in the global envelope — parse it directly as the object above. uptime is in seconds since the process booted. responseTime is in milliseconds.


Simple status containing only status + message. Useful for monitoring that only needs to know OK/not without per-service detail.

public
{ "status": "ok", "message": "API is healthy and operational" }

Response — 503 Service Unavailable (maintenance)

Section titled “Response — 503 Service Unavailable (maintenance)”
{ "status": "maintenance", "message": "API is currently under maintenance. Please try again later." }

Response — 500 Internal Server Error (degraded)

Section titled “Response — 500 Internal Server Error (degraded)”
{ "status": "degraded", "message": "API is experiencing issues" }

Basic ping-pong. During maintenance, returns 503; otherwise, always 200 with body { "message": "pong" }.

public
{ "message": "pong", "timestamp": "2026-05-20T10:30:00.000Z" }

Response — 503 Service Unavailable (maintenance)

Section titled “Response — 503 Service Unavailable (maintenance)”
{ "message": "API is under maintenance", "timestamp": "2026-05-20T10:30:00.000Z" }

Kubernetes-style readiness probe. 200 if the system is ready to accept traffic, 503 if not (maintenance or degraded).

public
{ "status": "ready", "message": "API is ready to accept traffic" }
{
"status": "not-ready",
"message": "API is not ready to accept traffic",
"reason": "API is currently under maintenance. Please try again later."
}

The reason field only appears on the 503 response and contains the message from getSimpleStatus().


Kubernetes-style liveness probe. Always returns 200 as long as the process is still running — even in maintenance mode (the service is still “alive”).

public
{ "status": "alive", "message": "API is alive" }

Development-only endpoint: throws a synthetic error (My first Sentry error!) to verify the Sentry integration. Do not call from production FE.

public
{
"message": "Internal server error",
"statusCode": 500,
"error": "Internal Server Error"
}

The error is thrown synchronously and caught by the global filter — Sentry will receive an exception event. Only useful for smoke-testing instrumentation.



POST /v1/admin/maintenance/toggle bearer

Section titled “POST /v1/admin/maintenance/toggle ”

Toggle the system-wide maintenance mode. When enabled = true, all public probe endpoints (/health, /status, /ping, /ready) will return maintenance status / HTTP 503 until toggled off.

bearer can-manage-system
FieldTypeRequiredNotes
enabledbooleantrue to enable, false to disable
messagestringoptionalCustom message returned in the data.message field. Default follows enabled ("System is under maintenance" / "System is operational")
{ "enabled": true, "message": "Backend upgrade for 30 minutes" }
{
"status": "success",
"statusCode": 200,
"message": "Maintenance mode enabled successfully",
"data": {
"maintenanceMode": true,
"timestamp": "2026-05-20T10:30:00.000Z",
"message": "Backend upgrade for 30 minutes"
}
}
StatusWhen it occurs
400 Bad Requestenabled is not boolean / empty, or there is an unknown field
401 UnauthorizedBearer/cookie token is invalid
403 ForbiddenCaller lacks can-manage-system permission
  • Modifies the in-memory maintenanceMode flag in HealthService. Not persistent — restarting the process resets it to the value of env MAINTENANCE_MODE.
  • Does not affect DB data; purely gates health probe responses.
  • On multi-replica deployments, the toggle must be sent to each instance (or use an external propagation mechanism — currently none).

  • ok — all services healthy → HTTP 200
  • maintenance — maintenance flag active → HTTP 503
  • degraded — at least one service unhealthy → HTTP 500
  • healthy — test query succeeded
  • unhealthy — test query failed (timeout / exception)
  • API_VERSION — appears in the version field (default 1.0.0)
  • MAINTENANCE_MODE=true — initial flag at boot
{
"message": "Forbidden resource",
"statusCode": 403,
"error": "Forbidden"
}

The user-facing probe endpoints do not use this envelope — the per-endpoint shape is described in each card.

  • 200 system ok
  • 500 system degraded (DB/Mongo unhealthy)
  • 503 maintenance mode active
  • 401 admin endpoint without token
  • 403 admin endpoint without permission