0
0
NestJSframework~5 mins

Health checks (Terminus) in NestJS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of health checks in a NestJS application using Terminus?
Health checks help monitor if the application and its dependencies are working correctly. Terminus provides easy ways to create these checks so the system can report its status.
Click to reveal answer
beginner
How do you add a simple HTTP health check endpoint using Terminus in NestJS?
You create a controller with the @HealthCheck() decorator and use the HealthCheckService to run built-in checks like HTTP or database checks. This endpoint returns the status of the app.
Click to reveal answer
intermediate
What is a 'readiness' health check and why is it important?
A readiness check tells if the app is ready to handle requests. It usually checks if dependencies like databases are connected. This helps load balancers send traffic only to ready instances.
Click to reveal answer
intermediate
Explain how Terminus integrates with NestJS dependency injection for custom health indicators.
You create a custom health indicator class that extends HealthIndicator. Then you inject it into your health controller to include custom checks in the health endpoint.
Click to reveal answer
intermediate
What is the difference between liveness and readiness probes in Terminus health checks?
Liveness probes check if the app is alive (not stuck or crashed). Readiness probes check if the app is ready to serve traffic (all dependencies are working). Both help Kubernetes manage app lifecycle.
Click to reveal answer
Which decorator is used to mark a health check endpoint in NestJS Terminus?
A@CheckHealth()
B@GetHealth()
C@HealthCheck()
D@Health()
What does a readiness probe typically check?
AIf the app dependencies are connected and ready
BIf the app process is running
CIf the server CPU is below 50%
DIf the app has received any requests
How do you add a custom health check in Terminus?
ACreate a custom HealthIndicator class and inject it
BOverride the default health controller
CUse @CustomHealth() decorator
DModify the main.ts file
Which service runs the health checks in a Terminus controller?
AHealthService
BHealthCheckService
CTerminusService
DCheckService
What HTTP status code does a healthy Terminus endpoint usually return?
A302 Redirect
B404 Not Found
C500 Internal Server Error
D200 OK
Describe how you would implement a basic health check endpoint in a NestJS app using Terminus.
Think about the steps from module setup to controller method.
You got /5 concepts.
    Explain the difference between liveness and readiness probes and why both are useful in a cloud environment.
    Consider how Kubernetes uses these probes.
    You got /4 concepts.