import { Global, Module } from "@nestjs/common";
import { RateLimitGuard } from "./rate-limit.guard.js";

/**
 * Global rate limiting module using rate-limiter-flexible with Redis.
 *
 * This replaces @nestjs/throttler with a unified solution that:
 * - Uses the same Redis-backed rate-limiter-flexible as auth rate limiting
 * - Provides consistent rate limiting across the application
 * - Reduces dependency count
 *
 * Usage:
 * ```typescript
 * @Controller('example')
 * @UseGuards(RateLimitGuard)
 * export class ExampleController {
 *   @RateLimit({ limit: 10, ttl: 60 })
 *   @Get()
 *   async example() { ... }
 * }
 * ```
 */
@Global()
@Module({
  providers: [RateLimitGuard],
  exports: [RateLimitGuard],
})
export class RateLimitModule {}
