NestJS Terminus
The official health-check module for NestJS applications
Repository Health
Technical Analysis
@nestjs/terminus is the official NestJS integration for building /health endpoints, providing a HealthCheckService plus a library of ready-made health indicators for databases (TypeORM, Mongoose, Sequelize, Prisma, MikroORM), disk and memory usage, HTTP dependencies (via Axios), and microservice transports (gRPC, and others reachable through Nest’s microservice client). It only requires the driver dependency for the checks you actually use, throwing a clear error if a required peer dependency is missing.
Health checks are composed declaratively: a @HealthCheck() decorated controller method calls HealthCheckService.check([...indicators]) with an array of indicator functions, and Terminus aggregates their results into a standard health-check response shape consumable by orchestrators like Kubernetes liveness/readiness probes or uptime monitors.
What You Get
HealthCheckServiceand@HealthCheck()decorator for aggregating multiple indicator results into one endpoint response- Database health indicators for TypeORM, Mongoose, Sequelize, Prisma, and MikroORM connections
- Disk-usage and memory (heap/RSS) health indicators with configurable thresholds
- HTTP health indicator built on Axios for checking reachability of external dependencies
- Microservice health indicators (gRPC and other Nest microservice transports)
- A graceful-shutdown-timeout utility for coordinating health status during application shutdown
Common Use Cases
- Exposing a
/healthendpoint for Kubernetes liveness and readiness probes - Aggregating database, disk, and memory checks into a single health-check response for uptime monitoring tools
- Verifying downstream HTTP or microservice dependencies are reachable before reporting an application as healthy
- Coordinating graceful shutdown so load balancers stop routing traffic before in-flight requests are dropped
Under The Hood
Architecture — The library is centered on lib/terminus.module.ts registering providers, with the actual work split between lib/health-check/health-check-executor.service.ts (runs the array of indicator functions passed to @HealthCheck() and aggregates pass/fail results) and lib/health-indicator/ (one subdirectory per dependency type: database/, disk/, memory/, http/, microservice/, each exporting an indicator class with a .pingCheck()-style method). lib/errors/ defines typed error classes per failure mode (connection not found, storage exceeded, timeout, unhealthy response code) so failures are distinguishable programmatically, not just by message string.
Tech Stack — Peer-dependency driven: Terminus itself has a small core dependency footprint and dynamically requires the ORM/HTTP client package matching whichever indicator you use (e.g. only needs typeorm installed if you use TypeOrmHealthIndicator), checked via lib/utils/checkPackage.util.ts which throws a descriptive error if the peer dependency is missing. Built with pnpm workspaces and tested against a docker-compose.yml stack of real database services for integration coverage.
Code Quality — Indicator services and the check-executor carry .spec.ts unit tests (health-check.service.spec.ts, health-check-executor.service.spec.ts, http.health.spec.ts, grpc.health.spec.ts, graceful-shutdown-timeout.service.spec.ts), and the repo has a separate e2e/ directory exercising indicators against real services via the docker-compose stack rather than mocks alone — a meaningfully more rigorous test posture than typical for a peer-dependency-heavy integration package.
API Design — The @HealthCheck() + HealthCheckService.check([...]) pattern keeps a health endpoint to a few lines: pass an array of indicator function calls (() => this.db.pingCheck('database')) and Terminus handles aggregation, timeout, and response shaping. Each indicator follows the same .pingCheck(key, options) shape regardless of underlying dependency type, so adding a new check type to an existing endpoint requires no new mental model — a deliberate consistency choice across an otherwise heterogeneous set of integrations.
Used by 7 apps in this directory
APITable
Low Code Platforms · Databases
API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.
Docmost
Productivity · Note Taking · Collaboration
Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.
Hoppscotch
Developer Tools
A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.
Novu
Developer Tools
Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.
Swetrix
Analytics
Privacy-first, cookieless web analytics with error tracking, session replays, and performance monitoring — self-host or use Cloud.
Teable
Databases · No Code Platforms
A no-code PostgreSQL database with spreadsheet UX, real-time collaboration, and native AI agents — built for teams that outgrow Airtable.
twenty
CRM
The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.