Files
Sakuin/backend/src/work/work.controller.ts
Tetardtek 13744eaaaa
Some checks failed
CI/CD — Build & Deploy / Build & Deploy (push) Failing after 14s
Merge branch 'security/sakuin/guards-controllers'
# Conflicts:
#	backend/src/work/work.controller.ts
2026-04-05 07:52:59 +02:00

26 lines
802 B
TypeScript

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);
}
}