From 16ab7407de6f61843d650bd47e6826031bacc888 Mon Sep 17 00:00:00 2001 From: Alp Date: Sun, 28 Jan 2024 14:23:26 +0300 Subject: [PATCH] Change status codes --- src/controllers/auth.controller.ts | 11 +++++++++-- src/controllers/tournament.controller.ts | 12 ++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/controllers/auth.controller.ts b/src/controllers/auth.controller.ts index 1b326c1..dedc550 100644 --- a/src/controllers/auth.controller.ts +++ b/src/controllers/auth.controller.ts @@ -1,4 +1,10 @@ -import { Body, Controller, Post, UseInterceptors } from '@nestjs/common'; +import { + Body, + Controller, + HttpCode, + Post, + UseInterceptors, +} from '@nestjs/common'; import { ApiBearerAuth, ApiResponse, ApiTags } from '@nestjs/swagger'; import { AuthService } from '../services'; import { @@ -38,9 +44,10 @@ export class AuthController { } @Post('/login') + @HttpCode(200) @UseInterceptors(new SerializerInterceptor(LoginResponseDto)) @ApiResponse({ - status: 201, + status: 200, description: 'Login successful.', type: LoginResponseDto, }) diff --git a/src/controllers/tournament.controller.ts b/src/controllers/tournament.controller.ts index cd1cc45..924de72 100644 --- a/src/controllers/tournament.controller.ts +++ b/src/controllers/tournament.controller.ts @@ -1,4 +1,4 @@ -import { Controller, UseGuards, Req, Post } from '@nestjs/common'; +import { Controller, UseGuards, Req, Post, HttpCode } from '@nestjs/common'; import { ApiBearerAuth, ApiResponse, ApiTags } from '@nestjs/swagger'; import { TournamentService } from '../services'; import { AuthGuard } from '../services/guards'; @@ -13,8 +13,9 @@ export class TournamentController { constructor(private readonly tournamentService: TournamentService) {} @UseGuards(AuthGuard) + @HttpCode(200) @ApiResponse({ - status: 201, + status: 200, description: 'User joined the tournament successfully.', }) @ApiResponse({ @@ -38,8 +39,9 @@ export class TournamentController { } @UseGuards(AuthGuard) + @HttpCode(200) @ApiResponse({ - status: 201, + status: 200, description: 'User claimed his/her reward successfully.', }) @ApiResponse({ @@ -56,7 +58,9 @@ export class TournamentController { description: 'Internal server error, contact with backend team.', }) @Post('/claim-reward') - public async claimReward(@Req() req: IAuthorizedRequest): Promise { + public async claimReward( + @Req() req: IAuthorizedRequest, + ): Promise { const user = req.user; await this.tournamentService.claimReward(user.username); return { message: 'Your reward claim is successfully processed.' };