/** * NestJS App Configuration Helper * * Configures a NestJS application with middleware based on CoreInitOptions. * Call this in your main.ts after creating the app. * * @example * ```typescript * import { NestFactory } from '@nestjs/core'; * import { configureNestApp } from '@plyaz/core/nestjs'; * import { AppModule } from './app.module'; * import { buildCoreConfig } from './config'; * * async function bootstrap() { * const app = await NestFactory.create(AppModule); * const options = buildCoreConfig(); * * // Configure middleware, validation, security, etc. * await configureNestApp(app, options); * * await app.listen(3000); * } * ``` */ import { type INestApplication } from '@nestjs/common'; import type { CoreNestJsMiddlewareConfig } from '@plyaz/types/core'; import { type CoreInitOptions } from '../CoreInitializer'; /** * Result of configuring a NestJS app */ export interface ConfigureNestAppResult { /** Features that were enabled */ enabled: string[]; /** Features that were skipped (not configured or dependencies missing) */ skipped: string[]; /** Any warnings during configuration */ warnings: string[]; /** Configured paths */ paths: { /** API prefix (e.g., 'api') */ prefix?: string; /** Swagger docs path (e.g., 'api/docs') */ swagger?: string; }; } /** * Configure a NestJS application with middleware based on CoreInitOptions. * * This function applies: * - Compression middleware (if compression: true) * - Helmet security headers (if helmet: true) * - Rate limiting (if rateLimit config provided) * - Global validation pipe (if validation: true) * - Body size limits * - Request timeout * - Raw body parsing for webhooks * - Swagger documentation (if swagger config provided) * - CORS configuration * - Global prefix * - Graceful shutdown handlers * * @param app - NestJS application instance * @param options - Core initialization options (reads nestjs config) * @returns Configuration result with enabled/skipped features * * @example Basic usage * ```typescript * const app = await NestFactory.create(AppModule); * await configureNestApp(app, { * nestjs: { * compression: true, * helmet: true, * validation: true, * }, * }); * ``` * * @example Full production config * ```typescript * await configureNestApp(app, { * nestjs: { * compression: true, * helmet: true, * rateLimit: { ttl: 60, limit: 100 }, * validation: { whitelist: true, transform: true }, * bodyLimit: '10mb', * timeout: 30000, * rawBody: { paths: ['/webhooks/*'] }, * swagger: { enabled: false }, * globalPrefix: 'api', * excludeFromPrefix: ['health', 'metrics'], * gracefulShutdown: true, * }, * }); * ``` */ export declare function configureNestApp(app: INestApplication, options: CoreInitOptions): Promise; /** * Get default NestJS middleware configuration. * Use this as a base and override specific options. * * @param isProduction - Whether running in production * @returns Default configuration */ export declare function getDefaultNestJsConfig(isProduction?: boolean): CoreNestJsMiddlewareConfig; //# sourceMappingURL=configureNestApp.d.ts.map