Skip to main content

Entrypoint

Nest.js Extends Toolkit providers a set of providers for creating various types of entrypoints, which come in four types:

  • BaseScriptEntrypoint Execute some code once.
  • BaseDaemonEntrypoint Run some code as a daemon.
  • BaseHttpServerEntrypoint Running the HTTP server.
  • BaseMicroserviceEntrypoint Running the Nest Microservice server.

Lifecycle events

Nest.js provides a set of Lifecycle events 1, when you want to use them, you can define the methods directly in the entrypoint class without having to import the relevant interface.

On top of that, Nest.js Extends Toolkit adds an additional Lifecycle event onApplicationListened to BaseHttpServerEntrypoint and BaseMicroserviceEntrypoint which will be called after http server or microservice server listened.

Full lifecycle events sequence:

  1. onModuleInit()
  2. onApplicationBootstrap()
  3. onApplicationListened
  4. onModuleDestroy()
  5. beforeApplicationShutdown()
  6. onApplicationShutdown()