refacto: DTOs class-validator — validation active sur tous les endpoints

This commit is contained in:
2026-04-05 07:41:01 +02:00
parent 6dcb6bf4b5
commit 075afa1063
6 changed files with 209 additions and 4 deletions

View File

@@ -15,6 +15,10 @@ import { ListService } from './list.service';
import { ListStatus } from './user-work.entity';
import { AuthGuard } from '../auth/auth.guard';
import { UserService } from '../user/user.service';
import { AddToListDto } from './dto/add-to-list.dto';
import { UpdateProgressDto } from './dto/update-progress.dto';
import { UpdateStatusDto } from './dto/update-status.dto';
import { SetScoreDto } from './dto/set-score.dto';
@Controller('api/list')
@UseGuards(AuthGuard)
@@ -37,7 +41,7 @@ export class ListController {
@Post()
async addToList(
@Req() req: any,
@Body() body: { anilistId: number; status: ListStatus },
@Body() body: AddToListDto,
) {
const user = await this.userService.findOrCreate({
id: req.user.id,
@@ -51,7 +55,7 @@ export class ListController {
async updateProgress(
@Req() req: any,
@Param('id', ParseIntPipe) id: number,
@Body() body: { progress: number },
@Body() body: UpdateProgressDto,
) {
const user = await this.userService.findOrCreate({
id: req.user.id,
@@ -65,7 +69,7 @@ export class ListController {
async updateStatus(
@Req() req: any,
@Param('id', ParseIntPipe) id: number,
@Body() body: { status: ListStatus },
@Body() body: UpdateStatusDto,
) {
const user = await this.userService.findOrCreate({
id: req.user.id,
@@ -79,7 +83,7 @@ export class ListController {
async setScore(
@Req() req: any,
@Param('id', ParseIntPipe) id: number,
@Body() body: { score: number },
@Body() body: SetScoreDto,
) {
const user = await this.userService.findOrCreate({
id: req.user.id,