import { Controller, Get, Query, UseGuards } from '@nestjs/common'; import { Throttle } from '@nestjs/throttler'; import { AuthGuard } from '../auth/auth.guard'; import { Public } from '../auth/public.decorator'; import { WorkService } from './work.service'; @UseGuards(AuthGuard) @Controller('api/works') export class WorkController { constructor(private readonly workService: WorkService) {} @Public() @Throttle([{ ttl: 60000, limit: 20 }]) @Get('search') async search( @Query('q') query: string, @Query('type') type?: 'ANIME' | 'MANGA', @Query('page') page?: string, ) { if (!query || query.trim().length < 2) { return { media: [], total: 0, hasNextPage: false }; } return this.workService.search(query.trim(), type, page ? parseInt(page, 10) : 1); } }