发送验证码、登陆接口限流20/min

This commit is contained in:
2025-06-19 11:27:00 +08:00
parent 70b90c3ed7
commit b79c84a004
2 changed files with 6 additions and 3 deletions

View File

@@ -1,12 +1,15 @@
import { BadRequestException, Body, Controller, Post } from '@nestjs/common';
import { BadRequestException, Body, Controller, Post, UseGuards } from '@nestjs/common';
import { SendVerificationCodeDto } from './dto/send-verification-code.dto';
import { VerificationService } from './verification.service';
import { Throttle, ThrottlerGuard } from '@nestjs/throttler';
@Controller('verification')
export class VerificationController {
constructor(private readonly verificationService: VerificationService) {}
constructor(private readonly verificationService: VerificationService) { }
@Post('send')
@UseGuards(ThrottlerGuard)
@Throttle({ default: { limit: 20, ttl: 60000 } })
async sendVerificationCode(@Body() dto: SendVerificationCodeDto) {
switch (dto.type) {
case 'login':