refresh token

This commit is contained in:
2025-11-11 09:50:18 +03:30
parent 4c274c3118
commit e34b93aa83
8 changed files with 51 additions and 7 deletions
@@ -0,0 +1,18 @@
import { UseGuards, applyDecorators } from '@nestjs/common';
import { Throttle, ThrottlerGuard } from '@nestjs/throttler';
import {
AUTH_THROTTLE_LIMIT,
AUTH_THROTTLE_TTL,
AUTH__REFRESH_THROTTLE_LIMIT,
AUTH__REFRESH_THROTTLE_TTL,
} from '../constants';
export const RateLimit = (limit: number, ttl: number) =>
applyDecorators(Throttle({ default: { limit, ttl } }), UseGuards(ThrottlerGuard));
// Predefined rate limits for common scenarios
export const StrictRateLimit = () => RateLimit(AUTH_THROTTLE_LIMIT, AUTH_THROTTLE_TTL); // 5 requests per minute
export const StandardRateLimit = () => RateLimit(30, 60000); // 30 requests per minute
export const MailSendRateLimit = () => RateLimit(10, 60000); // 10 emails per minute
export const RefreshTokenRateLimit = () => RateLimit(AUTH__REFRESH_THROTTLE_LIMIT, AUTH__REFRESH_THROTTLE_TTL); // 10 emails per minute