import { ExecutionContext, ModuleMetadata, Type } from '@nestjs/common/interfaces'; import { ThrottlerStorage } from './throttler-storage.interface'; import { ThrottlerLimitDetail } from './throttler.guard.interface'; export type Resolvable = T | ((context: ExecutionContext) => T | Promise); export interface ThrottlerOptions { name?: string; limit: Resolvable; ttl: Resolvable; blockDuration?: Resolvable; ignoreUserAgents?: RegExp[]; skipIf?: (context: ExecutionContext) => boolean; getTracker?: ThrottlerGetTrackerFunction; generateKey?: ThrottlerGenerateKeyFunction; setHeaders?: boolean; } export type ThrottlerModuleOptions = Array | { ignoreUserAgents?: RegExp[]; skipIf?: (context: ExecutionContext) => boolean; getTracker?: ThrottlerGetTrackerFunction; generateKey?: ThrottlerGenerateKeyFunction; errorMessage?: string | ((context: ExecutionContext, throttlerLimitDetail: ThrottlerLimitDetail) => string); storage?: ThrottlerStorage; throttlers: Array; setHeaders?: boolean; }; export interface ThrottlerOptionsFactory { createThrottlerOptions(): Promise | ThrottlerModuleOptions; } export interface ThrottlerAsyncOptions extends Pick { useExisting?: Type; useClass?: Type; useFactory?: (...args: any[]) => Promise | ThrottlerModuleOptions; inject?: any[]; } export type ThrottlerGetTrackerFunction = (req: Record, context: ExecutionContext) => Promise | string; export type ThrottlerGenerateKeyFunction = (context: ExecutionContext, trackerString: string, throttlerName: string) => string;