0
0
NestJSframework~5 mins

Application lifecycle in NestJS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the Application Lifecycle in NestJS?
It is the sequence of events from starting the app, running it, to shutting it down, including hooks to run code at each stage.
Click to reveal answer
beginner
Name the lifecycle hook used to run code right after the application has fully started.
The hook is called onApplicationBootstrap().
Click to reveal answer
intermediate
What is the purpose of the onModuleDestroy() hook in NestJS?
It allows you to run cleanup code when a module is about to be destroyed, like closing database connections.
Click to reveal answer
intermediate
How does NestJS handle graceful shutdown of an application?
NestJS listens for shutdown signals and calls lifecycle hooks like onApplicationShutdown() to clean resources before exit.
Click to reveal answer
intermediate
Which interface should a service implement to run code when the application is shutting down?
Implement the OnApplicationShutdown interface and define the onApplicationShutdown() method.
Click to reveal answer
Which lifecycle hook runs after a module is initialized in NestJS?
AonModuleInit()
BonApplicationShutdown()
ConModuleDestroy()
DbeforeApplicationStart()
What does the onApplicationBootstrap() hook do?
ARuns code after the entire application has bootstrapped
BRuns code during shutdown
CRuns code when a module is destroyed
DRuns code before the app starts
Which interface is used to handle cleanup during app shutdown?
AOnModuleInit
BOnApplicationShutdown
COnModuleDestroy
DOnBootstrap
What signal does NestJS listen for to trigger graceful shutdown?
ASIGBOOT
BSIGSTART
CSIGRUN
DSIGINT
Which lifecycle hook is NOT part of NestJS application lifecycle?
AonModuleDestroy
BonApplicationShutdown
ConAppStart
DonModuleInit
Explain the main lifecycle hooks in NestJS and when they run.
Think about the app starting, running, and stopping phases.
You got /4 concepts.
    Describe how NestJS supports graceful shutdown and why it is important.
    Consider what happens when you stop a running app.
    You got /4 concepts.