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.
| Property | Value |
|---|---|
| Base URL | {HOST}/v1 |
| Auth | Public for probe endpoints · Bearer JWT for admin maintenance toggle |
| Content-Type | application/json |
| Error envelope | Probe endpoints use the raw shape (see per-endpoint) · Admin endpoint uses the standard { "message", "statusCode", "error" } |
| Validation | Global ValidationPipe · whitelist: true, forbidNonWhitelisted: true |
| Related modules | infrastructure, monitoring (Sentry, k8s probes) |
| Document version | v1 · 2026-05-20 |
| Audience | Internal FE devs (status page widget) + ops/infra |
Summary
Section titled “Summary”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).
| Method | Path | Auth | Summary |
|---|---|---|---|
| GET | /v1/health | public | Full status (DB, Mongo, uptime, version) |
| GET | /v1/status | public | Simple status (ok / maintenance / degraded) |
| GET | /v1/ping | public | Simple ping-pong |
| GET | /v1/ready | public | Kubernetes readiness probe |
| GET | /v1/live | public | Kubernetes liveness probe |
| GET | /v1/debug-sentry | public | Trigger a synthetic Sentry error (dev only) |
| POST | /v1/admin/maintenance/toggle | bearer | Enable/disable maintenance mode (admin) |
GET /v1/health public
Section titled “GET /v1/health ”Full system status: MySQL + MongoDB connectivity, uptime in seconds, version, and timestamp. Suitable for a status dashboard or in-depth check.
publicResponse — 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.
GET /v1/status public
Section titled “GET /v1/status ”Simple status containing only status + message. Useful for monitoring that only needs to know OK/not without per-service detail.
Response — 200 OK
Section titled “Response — 200 OK”{ "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" }GET /v1/ping public
Section titled “GET /v1/ping ”Basic ping-pong. During maintenance, returns 503; otherwise, always 200 with body { "message": "pong" }.
Response — 200 OK
Section titled “Response — 200 OK”{ "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" }GET /v1/ready public
Section titled “GET /v1/ready ”Kubernetes-style readiness probe. 200 if the system is ready to accept traffic, 503 if not (maintenance or degraded).
Response — 200 OK
Section titled “Response — 200 OK”{ "status": "ready", "message": "API is ready to accept traffic" }Response — 503 Service Unavailable
Section titled “Response — 503 Service Unavailable”{ "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().
GET /v1/live public
Section titled “GET /v1/live ”Kubernetes-style liveness probe. Always returns 200 as long as the process is still running — even in maintenance mode (the service is still “alive”).
Response — 200 OK
Section titled “Response — 200 OK”{ "status": "alive", "message": "API is alive" }GET /v1/debug-sentry public
Section titled “GET /v1/debug-sentry ”Development-only endpoint: throws a synthetic error (My first Sentry error!) to verify the Sentry integration. Do not call from production FE.
Response — 500 Internal Server Error
Section titled “Response — 500 Internal Server Error”{ "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.
Admin endpoint
Section titled “Admin endpoint”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.
Request body — MaintenanceModeDto
Section titled “Request body — MaintenanceModeDto”| Field | Type | Required | Notes |
|---|---|---|---|
enabled | boolean | ✓ | true to enable, false to disable |
message | string | optional | Custom message returned in the data.message field. Default follows enabled ("System is under maintenance" / "System is operational") |
Example request
Section titled “Example request”{ "enabled": true, "message": "Backend upgrade for 30 minutes" }Response — 200 OK
Section titled “Response — 200 OK”{ "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" }}Errors
Section titled “Errors”| Status | When it occurs |
|---|---|
400 Bad Request | enabled is not boolean / empty, or there is an unknown field |
401 Unauthorized | Bearer/cookie token is invalid |
403 Forbidden | Caller lacks can-manage-system permission |
Side effects
Section titled “Side effects”- Modifies the in-memory
maintenanceModeflag inHealthService. Not persistent — restarting the process resets it to the value of envMAINTENANCE_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).
Reference
Section titled “Reference”Enum: HealthStatus.status
Section titled “Enum: HealthStatus.status”ok— all services healthy → HTTP 200maintenance— maintenance flag active → HTTP 503degraded— at least one service unhealthy → HTTP 500
Enum: services.{db|mongo}.status
Section titled “Enum: services.{db|mongo}.status”healthy— test query succeededunhealthy— test query failed (timeout / exception)
Env vars
Section titled “Env vars”API_VERSION— appears in theversionfield (default1.0.0)MAINTENANCE_MODE=true— initial flag at boot
Standard error envelope (admin endpoint)
Section titled “Standard error envelope (admin endpoint)”{ "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.
Common HTTP codes
Section titled “Common HTTP codes”200system ok500system degraded (DB/Mongo unhealthy)503maintenance mode active401admin endpoint without token403admin endpoint without permission