Discover how to catch app problems early with just a few lines of code!
Why Health checks (Terminus) in NestJS? - Purpose & Use Cases
Imagine you run a web app and want to know if your database or external services are working fine. You try to check each service by writing separate code everywhere.
Manually checking each service is slow, messy, and easy to forget. If one service fails, you might not notice quickly, causing your app to break without warning.
Health checks with Terminus in NestJS give you a simple, unified way to monitor all parts of your app automatically and report their status clearly.
if (db.isConnected()) { console.log('DB OK'); } else { console.log('DB Down'); }
@HealthCheck()
check() {
return this.health.check([
() => this.db.pingCheck('database'),
]);
}You can easily see your app's health in one place and react fast to problems before users notice.
A company uses Terminus health checks to monitor their payment service and database, so if either fails, their alert system notifies the team immediately.
Manual health checks are slow and error-prone.
Terminus provides automatic, clear health monitoring.
This helps keep apps reliable and users happy.