Skip to content

IEntryNestModule

reference
1 min readUpdated

Kind: Type

Source: packages/core/nest-factory.ts

Part of: Core

Represents the entry (root) module type accepted by the NestFactory methods.

IEntryNestModule represents the root NestJS module passed to NestFactory when creating an application or microservice. It provides the module metadata Nest needs to initialize dependency injection, controllers, providers, imports, and application lifecycle behavior.

Definition

ts
| Type<any> | DynamicModule | ForwardReference | Promise<IEntryNestModule>

Diagram

mermaid
graph LR
  Root[IEntryNestModule<br/>Root module type] --> Factory[NestFactory]
  Factory --> App[Nest application instance]
  Root --> Imports[Imported modules]
  Root --> Providers[Providers]
  Root --> Controllers[Controllers]

Usage

ts
import { Module } from '@nestjs/common';
import { NestFactory, IEntryNestModule } from '@nestjs/core';

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

async function bootstrap() {
  const entryModule: IEntryNestModule = AppModule;

  const app = await NestFactory.create(entryModule);
  await app.listen(3000);
}

bootstrap();

AI Coding Instructions

  • Pass a NestJS module class decorated with @Module() as the IEntryNestModule value; do not pass a module instance.
  • Use this type for APIs that accept the application's root module and delegate startup to NestFactory.
  • Keep root-module responsibilities focused on application composition: import feature modules and register global providers where appropriate.
  • Ensure controllers and providers are declared in the root module or reachable through its imported module graph.

Relationships

  • IMPORTS → DynamicModule
  • IMPORTS → ForwardReference
  • IMPORTS → HttpServer
  • IMPORTS → INestApplication
  • IMPORTS → INestApplicationContext
  • IMPORTS → INestMicroservice
  • IMPORTS → Type
  • IMPORTS → NestMicroserviceOptions
  • IMPORTS → NestApplicationContextOptions
  • IMPORTS → NestApplicationOptions
  • IMPORTS → ConsoleLogger
  • IMPORTS → Logger
  • IMPORTS → loadPackage
  • IMPORTS → isFunction
  • IMPORTS → isNil
  • IMPORTS → -nestjs-microservices
  • IMPORTS → -nestjs-platform-express

Was this page helpful?

Download as PDF
IEntryNestModule — NestJS head-to-head