diff --git a/backend/src/pets/pets.controller.ts b/backend/src/pets/pets.controller.ts index 1e190561..5aa7c534 100644 --- a/backend/src/pets/pets.controller.ts +++ b/backend/src/pets/pets.controller.ts @@ -75,6 +75,18 @@ export class PetsController { }, }), limits: { fileSize: 10 * 1024 * 1024 }, // 10MB + fileFilter: (_req, file, callback) => { + const allowedMimeTypes = ['image/jpeg', 'image/png', 'image/webp', 'image/gif']; + if (!allowedMimeTypes.includes(file.mimetype)) { + return callback( + new BadRequestException( + 'فرمت فایل مجاز نیست. لطفاً یکی از فرمت‌های JPG, PNG, WEBP را انتخاب کنید', + ), + false, + ); + } + callback(null, true); + }, }), ) @ApiOperation({ summary: 'آپلود تصویر حیوان خانگی' }) diff --git a/backend/src/tickets/tickets.controller.ts b/backend/src/tickets/tickets.controller.ts index 7994937d..84b3a124 100644 --- a/backend/src/tickets/tickets.controller.ts +++ b/backend/src/tickets/tickets.controller.ts @@ -1,3 +1,4 @@ +import { Throttle } from '@nestjs/throttler'; import { Controller, Get, @@ -33,6 +34,7 @@ import { export class TicketsController { constructor(private readonly ticketsService: TicketsService) {} + @Throttle({ default: { limit: 5, ttl: 60000 } }) @UseGuards(JwtAuthGuard) @ApiBearerAuth() @Post() @@ -66,6 +68,7 @@ export class TicketsController { return this.ticketsService.getTicketDetails(id, req.user.id, isAdmin); } + @Throttle({ default: { limit: 10, ttl: 60000 } }) @UseGuards(JwtAuthGuard) @ApiBearerAuth() @Post(':id/messages')