refacto: DTOs class-validator — validation active sur tous les endpoints
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user