Skip to content

InternalCoreModuleFactory

reference
1 min readUpdated

Kind: Class

Source: packages/core/injector/internal-core-module/internal-core-module-factory.ts

Part of: Core

InternalCoreModuleFactory builds the framework’s internal core module definition used by the dependency injection container. Its create() method registers foundational providers such as reflection utilities, request context tokens, module storage, HTTP adapter access, lazy module loading, and graph inspection services.

Methods

MethodSignatureReturns
createcreate(container: NestContainer, scanner: DependenciesScanner, moduleCompiler: ModuleCompiler, httpAdapterHost: HttpAdapterHost, graphInspector: GraphInspector, moduleOverrides: ModuleOverride[])void

Diagram

mermaid
graph LR
  A[Application Bootstrap] --> B[InternalCoreModuleFactory.create]
  B --> C[InternalCoreModule Definition]
  C --> D[Core DI Providers]
  D --> E[Reflector]
  D --> F[ModulesContainer]
  D --> G[HttpAdapterHost]
  D --> H[ExternalContextCreator]
  D --> I[LazyModuleLoader]
  D --> J[SerializedGraph]
  C --> K[NestContainer]

Usage

ts
import { InternalCoreModuleFactory } from './internal-core-module-factory';

// Typically called internally during application initialization.
const internalCoreModule = InternalCoreModuleFactory.create(
  container,
  scanner,
  moduleCompiler,
  httpAdapterHost,
  graphInspector,
);

// Register the generated module definition with the application container.
await container.addModule(internalCoreModule, []);

AI Coding Instructions

  • Treat create() as framework bootstrap infrastructure; application code should generally not call it directly.
  • Keep provider tokens and exports aligned so internal services remain resolvable throughout the container.
  • Pass the active NestContainer, scanner, compiler, HTTP adapter host, and graph inspector from the bootstrap pipeline.
  • Preserve request-scoped provider behavior when adding providers that depend on request context or inquirer resolution.
  • Update this factory when introducing new globally available internal runtime services.

Relationships

  • IMPORTS → Logger

Was this page helpful?

Download as PDF
InternalCoreModuleFactory — NestJS head-to-head