refresh token
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user