mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
fix(core): fix lifecycle hooks for middleware, injectables
This commit is contained in:
@@ -39,7 +39,12 @@ export async function callModuleInitHook(module: Module): Promise<void> {
|
||||
// Module (class) instance is the first element of the providers array
|
||||
// Lifecycle hook has to be called once all classes are properly initialized
|
||||
const [_, { instance: moduleClassInstance }] = providers.shift();
|
||||
const instances = [...module.controllers, ...providers];
|
||||
const instances = [
|
||||
...module.controllers,
|
||||
...providers,
|
||||
...module.injectables,
|
||||
...module.middlewares,
|
||||
];
|
||||
|
||||
const nonTransientInstances = getNonTransientInstances(instances);
|
||||
await Promise.all(callOperator(nonTransientInstances));
|
||||
|
||||
Reference in New Issue
Block a user