UNPKG

@opra/nestjs-http

Version:

Opra NestJS Http Module

68 lines (67 loc) 2.49 kB
import { type DynamicModule, Logger, type Type } from '@nestjs/common'; import type { ApiDocumentFactory } from '@opra/common'; import type { HttpAdapter } from '@opra/http'; export declare namespace OpraHttpModule { /** * Synchronous configuration options for OpraHttpModule. */ export interface ModuleOptions extends BaseModuleOptions, ApiConfig { } /** * Asynchronous configuration options for OpraHttpModule. */ export interface AsyncModuleOptions extends BaseModuleOptions { /** Providers to be injected into the factory function */ inject?: any[]; /** Factory function that returns the ApiConfig object asynchronously */ useFactory?: (...args: any[]) => Promise<ApiConfig> | ApiConfig; } /** * Base configuration options for the module. */ interface BaseModuleOptions extends Pick<DynamicModule, 'imports' | 'providers' | 'exports' | 'controllers' | 'global'> { /** Custom token for the module */ token?: any; /** Base path for the API */ basePath?: string; /** Whether the API schema is public */ schemaIsPublic?: boolean; /** Interceptor list for the HTTP adapter */ interceptors?: (HttpAdapter.InterceptorFunction | HttpAdapter.IHttpInterceptor | Type<HttpAdapter.IHttpInterceptor>)[]; } /** * OPRA API configuration details. */ export interface ApiConfig extends Pick<ApiDocumentFactory.InitArguments, 'types' | 'references' | 'info'> { /** API name */ name: string; /** API description */ description?: string; /** API scope */ scope?: string; /** Logger to be used */ logger?: Logger; } export {}; } /** * OpraHttpModule * * Module that integrates OPRA HTTP support into the NestJS application. */ export declare class OpraHttpModule { /** * Configures the module synchronously and imports it at the root level. * * @param init - Module configuration options. * @returns {DynamicModule} NestJS dynamic module. */ static forRoot(init: OpraHttpModule.ModuleOptions): DynamicModule; /** * Configures the module asynchronously and imports it at the root level. * * @param options - Asynchronous module configuration options. * @returns {DynamicModule} NestJS dynamic module. */ static forRootAsync(options: OpraHttpModule.AsyncModuleOptions): DynamicModule; }