Database health
Gate readiness on a real round-trip to the database — one module import wires the indicator.
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.
Wire it in
Section titled “Wire it in”Import SeaOrmHealthModule alongside HealthModule:
use nest_rs::core::module;use nest_rs::health::HealthModule;use nest_rs::seaorm::{SeaOrmDatabaseModule, SeaOrmHealthModule, SeaOrmModule};
#[module( imports = [ SeaOrmModule::for_root(None), SeaOrmDatabaseModule, SeaOrmHealthModule, HealthModule, ],)]pub struct AppModule;That’s it. Importing the module registers SeaOrmHealthIndicator as both a
readiness and a startup indicator — HealthModule discovers them
through the inventory seam and mounts the probes automatically.
What gets probed
Section titled “What gets probed”Two endpoints exit the box with the database wired in:
| Endpoint | Indicator runs | Failure |
|---|---|---|
GET /health/ready | SeaOrmHealthIndicator::db | 503 while unreachable |
GET /health/startup | SeaOrmHealthIndicator::db_ready | 503 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.
A passing probe
Section titled “A passing probe”$ curl -s http://localhost:3000/health/ready{"status":"up","info":{"db":{"name":"db","status":"up"}},"error":{}, "details":{"db":{"name":"db","status":"up"}}}When the ping fails the indicator moves from info to error, the overall
status switches to down, and the response is a 503. The body carries
the fixed reason "check failed" — never the DbErr, which would put a
DSN or an internal hostname on a routinely unauthenticated endpoint. The
real error goes to the log instead: warn on nest_rs::health, with
indicator, kind and error as fields. Indicators
is the reference for that split; the shape itself is on
Health.
Going further
Section titled “Going further”- Database — the slice the indicator hangs off.
- Repo and executor — the
DatabaseConnectionthe indicator pings. - Health — the indicator registry, the probe endpoints, custom indicators for other dependencies.