NestJS · Middle · Question 20 of 75

Which lifecycle hook is the right place to open a connection that other modules rely on during startup?

Explanation

Constructors can't be async. Nest awaits async onModuleInit hooks before calling onApplicationBootstrap.

Further reading

Problem with a question

NestJS · Middle · question 20

Test yourself

Take the NestJS · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz