79273662

Date: 2024-12-12 02:31:51
Score: 2.5
Natty:
Report link

I created a project from scratch with only one injectable service that implements the OnApplicationBoostrap interface.

@Injectable()
export class AppService implements OnApplicationBootstrap {
  public async onApplicationBootstrap(): Promise<void> {
    console.log('foobar');
  }
}

I only have one module:

@Module({
  providers: [AppService],
})
export class AppModule {}

And even tho, I'm facing the same issue as Jack.

my-terminal

What is really happening is, when using createMicroservice(AppModule), we don't need to call init() because when creating a microservice it'll execute the initializing flow which calls the OnApplicationBootstrap, and if you call init() it'll execute the same flow again.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): I'm facing the same issue
  • Low reputation (1):
Posted by: Matheus Vinícius Andrade