Skip to content

Commit

Permalink
Change status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alputer committed Jan 28, 2024
1 parent ad7215a commit 16ab740
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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,
})
Expand Down
12 changes: 8 additions & 4 deletions src/controllers/tournament.controller.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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({
Expand All @@ -38,8 +39,9 @@ export class TournamentController {
}

@UseGuards(AuthGuard)
@HttpCode(200)
@ApiResponse({
status: 201,
status: 200,
description: 'User claimed his/her reward successfully.',
})
@ApiResponse({
Expand All @@ -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<ClaimRewardResponseDto> {
public async claimReward(
@Req() req: IAuthorizedRequest,
): Promise<ClaimRewardResponseDto> {
const user = req.user;
await this.tournamentService.claimReward(user.username);
return { message: 'Your reward claim is successfully processed.' };
Expand Down

0 comments on commit 16ab740

Please sign in to comment.