-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from game-node-app/dev
Dev
- Loading branch information
Showing
8 changed files
with
126 additions
and
5 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class ChangeExclusionStatusDto { | ||
isActive: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { BaseFindDto } from "../../../utils/base-find.dto"; | ||
import { GameExclusion } from "../entity/game-exclusion.entity"; | ||
import { OmitType } from "@nestjs/swagger"; | ||
import { | ||
PaginationInfo, | ||
PaginationResponseDto, | ||
} from "../../../utils/pagination/pagination-response.dto"; | ||
|
||
export class FindAllExcludedGamesRequestDto extends OmitType( | ||
BaseFindDto<GameExclusion>, | ||
["search"], | ||
) {} | ||
|
||
export class FindAllExcludedGamesResponseDto implements PaginationResponseDto { | ||
data: GameExclusion[]; | ||
pagination: PaginationInfo; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { | ||
Body, | ||
Controller, | ||
Delete, | ||
Get, | ||
HttpCode, | ||
HttpStatus, | ||
Param, | ||
Post, | ||
Put, | ||
Query, | ||
UseGuards, | ||
UseInterceptors, | ||
} from "@nestjs/common"; | ||
import { ApiOkResponse, ApiTags } from "@nestjs/swagger"; | ||
import { GameFilterService } from "./game-filter.service"; | ||
import { Session } from "../../auth/session.decorator"; | ||
import { SessionContainer } from "supertokens-node/recipe/session"; | ||
import { AuthGuard } from "../../auth/auth.guard"; | ||
import { Roles } from "../../auth/roles.decorator"; | ||
import { EUserRoles } from "../../utils/constants"; | ||
import { | ||
FindAllExcludedGamesRequestDto, | ||
FindAllExcludedGamesResponseDto, | ||
} from "./dto/find-all-excluded-games.dto"; | ||
import { PaginationInterceptor } from "../../interceptor/pagination.interceptor"; | ||
import { ChangeExclusionStatusDto } from "./dto/change-exclusion-status.dto"; | ||
|
||
@Controller("game/filter") | ||
@ApiTags("game-filter") | ||
@UseGuards(AuthGuard) | ||
@Roles([EUserRoles.ADMIN, EUserRoles.MOD]) | ||
export class GameFilterController { | ||
constructor(private readonly gameFilterService: GameFilterService) {} | ||
|
||
@Get() | ||
@UseInterceptors(PaginationInterceptor) | ||
@ApiOkResponse({ | ||
type: FindAllExcludedGamesResponseDto, | ||
}) | ||
async findAll(@Query() dto: FindAllExcludedGamesRequestDto) { | ||
return this.gameFilterService.findAll(dto); | ||
} | ||
|
||
@Post(":gameId") | ||
@HttpCode(HttpStatus.CREATED) | ||
async registerExclusion( | ||
@Session() session: SessionContainer, | ||
@Param("gameId") gameId: number, | ||
) { | ||
return this.gameFilterService.register(session.getUserId(), gameId); | ||
} | ||
|
||
@Put(":gameId/status") | ||
@HttpCode(HttpStatus.NO_CONTENT) | ||
async changeStatus( | ||
@Param("gameId") gameId: number, | ||
@Body() dto: ChangeExclusionStatusDto, | ||
) { | ||
await this.gameFilterService.changeStatus(gameId, dto); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters