import type { ConfigService } from "@nestjs/config";
import type { ThrottlerModuleOptions } from "@nestjs/throttler";

export const createThrottlerConfig = (configService: ConfigService): ThrottlerModuleOptions => [
  {
    ttl: configService.get<number>("RATE_LIMIT_TTL", 60),
    limit: configService.get<number>("RATE_LIMIT_LIMIT", 100),
  },
  {
    name: "auth",
    ttl: configService.get<number>("AUTH_RATE_LIMIT_TTL", 900),
    limit: configService.get<number>("AUTH_RATE_LIMIT_LIMIT", 3),
  },
  {
    name: "auth-refresh",
    ttl: configService.get<number>("AUTH_REFRESH_RATE_LIMIT_TTL", 300),
    limit: configService.get<number>("AUTH_REFRESH_RATE_LIMIT_LIMIT", 10),
  },
];
