Skip to content

Commit

Permalink
feat(microservice): register modules on init call nestjs#2350
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jul 1, 2019
1 parent e8a66ea commit 2487ab8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/core/nest-application-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export class NestApplicationContext implements INestApplicationContext {
* @returns {Promise<this>} The NestApplicationContext instance as Promise
*/
public async init(): Promise<this> {
// Ignore if is already initialized
if (this.isInitialized) return;

if (this.isInitialized) {
return this;
}
await this.callInitHook();
await this.callBootstrapHook();

Expand Down
9 changes: 9 additions & 0 deletions packages/microservices/nest-microservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ export class NestMicroservice extends NestApplicationContext
return this;
}

public async init(): Promise<this> {
if (this.isInitialized) {
return this;
}
await super.init();
await this.registerModules();
return this;
}

public listen(callback: () => void) {
!this.isInitialized && this.registerModules();

Expand Down

0 comments on commit 2487ab8

Please sign in to comment.