Skip to content

Health

The readiness probe should fail when the database is unreachable. NestRS ships a SeaORM-backed indicator that runs DatabaseConnection::ping and plugs straight into nest-rs-health’s indicator registry — no glue code, no probe handler to write.

Import DatabaseHealthModule alongside HealthModule:

src/module.rs
use nest_rs_health::HealthModule;
use nest_rs_seaorm::DatabaseHealthModule;
#[module(
imports = [
DatabaseModule::for_root(None),
HealthModule,
DatabaseHealthModule,
],
)]
pub struct AppModule;

That’s it. Importing the module registers DbHealthIndicator as both a readiness and a startup indicator — HealthModule discovers them through the inventory seam and mounts the probes automatically.

Two endpoints exit the box with the database wired in:

EndpointIndicator runsFailure
GET /health/readyDbHealthIndicator::db503 while unreachable
GET /health/startupDbHealthIndicator::db_ready503 until first ping succeeds

The liveness probe (GET /health/live) deliberately does not depend on the database — a brief DB outage should not kill the pod.

Terminal window
curl -s http://localhost:3000/health/ready
{
"status": "ok",
"details": {
"db": { "status": "up" }
}
}

A failure response surfaces the typed DbErr as the error field on the failing indicator, and the overall status switches to down with a 503. The same shape across every indicator means a single dashboard template covers them all.

  • Database — the slice the indicator hangs off.
  • Repo and executor — the DatabaseConnection the indicator pings.
  • Health — the indicator registry, the probe endpoints, custom indicators for other dependencies.