UNPKG

@nestjs/core

Version:

The core of NestJS, a TypeScript framework for Node.js backends: modules, dependency injection and the request pipeline, on Express, Fastify or node:http.

99 lines (98 loc) • 4.61 kB
import type { DynamicModule, ForwardReference, INestApplication, INestApplicationContext, INestMicroservice, ModuleMetadata, Type } from '@nestjs/common'; import { AbstractHttpAdapter } from './adapters/http-adapter.js'; import { type NestMicroserviceOptions, type NestApplicationContextOptions } from '@nestjs/common/internal'; import { type NestApplicationOptions } from '@nestjs/common'; /** * Represents the entry (root) module type accepted by the NestFactory methods. * * Besides a module class, a dynamic module or a forward reference, it can be * plain module metadata (for example, `{ controllers: [AppController] }`), * from which Nest creates the root module. * * @publicApi */ export type IEntryNestModule = Type<any> | DynamicModule | ForwardReference | ModuleMetadata | Promise<IEntryNestModule>; type ApplicationFromAdapter<TAdapter extends AbstractHttpAdapter> = TAdapter extends AbstractHttpAdapter<any, any, any, infer TApplication> ? TApplication : INestApplication; /** * @publicApi */ export declare class NestFactoryStatic { private readonly logger; private abortOnError; private autoFlushLogs; /** * Creates a Nest application and infers its type from the supplied adapter. * A contextual application type takes precedence when supplied. * Adapters typed as `AbstractHttpAdapter` or `any` use the fallback overloads. * * @param module Entry (root) application module class or module metadata * @param httpAdapter Adapter to proxy the request/response cycle to * the underlying HTTP server * @param options List of options to initialize NestApplication */ create<TAdapter extends AbstractHttpAdapter, T extends INestApplication = ApplicationFromAdapter<TAdapter>>(module: IEntryNestModule, httpAdapter: TAdapter & (AbstractHttpAdapter extends TAdapter ? never : unknown), options?: NestApplicationOptions): Promise<T>; /** * Creates an instance of NestApplication. * * @param module Entry (root) application module class or module metadata * @param options List of options to initialize NestApplication * * @returns A promise that, when resolved, * contains a reference to the NestApplication instance. */ create<T extends INestApplication = INestApplication>(module: IEntryNestModule, options?: NestApplicationOptions): Promise<T>; /** * Preserves the original adapter signature, including an explicit `never` * application type and the signatures seen by `Parameters` and `ReturnType`. */ create<T extends INestApplication = INestApplication>(module: IEntryNestModule, httpAdapter: AbstractHttpAdapter, options?: NestApplicationOptions): Promise<T>; /** * Creates an instance of NestMicroservice. * * @param moduleCls Entry (root) application module class or module metadata * @param options Optional microservice configuration * * @returns A promise that, when resolved, * contains a reference to the NestMicroservice instance. */ createMicroservice<T extends object>(moduleCls: IEntryNestModule, options?: NestMicroserviceOptions & T): Promise<INestMicroservice>; /** * Creates an instance of NestApplicationContext. * * @param moduleCls Entry (root) application module class or module metadata * @param options Optional Nest application configuration * * @returns A promise that, when resolved, * contains a reference to the NestApplicationContext instance. */ createApplicationContext(moduleCls: IEntryNestModule, options?: NestApplicationContextOptions): Promise<INestApplicationContext>; private createNestInstance; private initialize; private toRootModule; private isModuleMetadata; private handleInitializationError; private createProxy; private createExceptionProxy; private createExceptionZone; private registerLoggerConfiguration; private createHttpAdapter; private isHttpServer; private setAbortOnError; private createAdapterProxy; private createGraphInspector; } /** * Use NestFactory to create an application instance. * * ### Specifying an entry module * * Pass the required *root module* for the application via the module parameter. * By convention, it is usually called `ApplicationModule`. Starting with this * module, Nest assembles the dependency graph and begins the process of * Dependency Injection and instantiates the classes needed to launch your * application. * * @publicApi */ export declare const NestFactory: NestFactoryStatic; export {};