File

src/module/team/team.controller.ts

Prefix

tutorial/:id/team

Index

Methods

Methods

Async createTeamInTutorial
createTeamInTutorial(tutorialId: string, dto: TeamDTO)
Decorators :
@Post()
@UseGuards(TeamGuard)
@UsePipes(ValidationPipe)
Parameters :
Name Type Optional
tutorialId string No
dto TeamDTO No
Returns : Promise<ITeam>
Async deleteTeamFromTutorial
deleteTeamFromTutorial(tutorialId: string, teamId: string)
Decorators :
@Delete('/:teamId')
@HttpCode(HttpStatus.NO_CONTENT)
@UseGuards(TeamGuard)
Parameters :
Name Type Optional
tutorialId string No
teamId string No
Returns : Promise<void>
Async getAllTeamsInTutorial
getAllTeamsInTutorial(tutorialId: string)
Decorators :
@Get()
@UseGuards(TeamGuard)
@AllowSubstitutes()
@AllowCorrectors()
Parameters :
Name Type Optional
tutorialId string No
Returns : Promise<ITeam[]>
Async getTeamInTutorial
getTeamInTutorial(tutorialId: string, teamId: string)
Decorators :
@Get('/:teamId')
@UseGuards(TeamGuard)
@AllowSubstitutes()
@AllowCorrectors()
Parameters :
Name Type Optional
tutorialId string No
teamId string No
Returns : Promise<ITeam>
Async updateTeamInTutorial
updateTeamInTutorial(tutorialId: string, teamId: string, dto: TeamDTO)
Decorators :
@Patch('/:teamId')
@UseGuards(TeamGuard)
@AllowCorrectors()
@UsePipes(ValidationPipe)
Parameters :
Name Type Optional
tutorialId string No
teamId string No
dto TeamDTO No
Returns : Promise<ITeam>
import {
    Body,
    Controller,
    Delete,
    Get,
    HttpCode,
    HttpStatus,
    Param,
    Patch,
    Post,
    UseGuards,
    UsePipes,
    ValidationPipe,
} from '@nestjs/common';
import { AllowCorrectors } from '../../guards/decorators/allowCorrectors.decorator';
import { AllowSubstitutes } from '../../guards/decorators/allowSubstitutes.decorator';
import { TeamGuard } from '../../guards/team.guard';
import { ITeam } from 'shared/model/Team';
import { TeamDTO } from './team.dto';
import { TeamService } from './team.service';

@Controller('tutorial/:id/team')
export class TeamController {
    constructor(private readonly teamService: TeamService) {}

    @Get()
    @UseGuards(TeamGuard)
    @AllowSubstitutes()
    @AllowCorrectors()
    async getAllTeamsInTutorial(@Param('id') tutorialId: string): Promise<ITeam[]> {
        const teams = await this.teamService.findAllTeamsInTutorial(tutorialId);

        return teams.map((team) => team.toDTO());
    }

    @Post()
    @UseGuards(TeamGuard)
    @UsePipes(ValidationPipe)
    async createTeamInTutorial(
        @Param('id') tutorialId: string,
        @Body() dto: TeamDTO
    ): Promise<ITeam> {
        return await this.teamService.createTeamInTutorial(tutorialId, dto);
    }

    @Get('/:teamId')
    @UseGuards(TeamGuard)
    @AllowSubstitutes()
    @AllowCorrectors()
    async getTeamInTutorial(
        @Param('id') tutorialId: string,
        @Param('teamId') teamId: string
    ): Promise<ITeam> {
        const team = await this.teamService.findById({ tutorialId, teamId });

        return team.toDTO();
    }

    @Patch('/:teamId')
    @UseGuards(TeamGuard)
    @AllowCorrectors()
    @UsePipes(ValidationPipe)
    async updateTeamInTutorial(
        @Param('id') tutorialId: string,
        @Param('teamId') teamId: string,
        @Body() dto: TeamDTO
    ): Promise<ITeam> {
        return await this.teamService.updateTeamInTutorial({ tutorialId, teamId }, dto);
    }

    @Delete('/:teamId')
    @HttpCode(HttpStatus.NO_CONTENT)
    @UseGuards(TeamGuard)
    async deleteTeamFromTutorial(
        @Param('id') tutorialId: string,
        @Param('teamId') teamId: string
    ): Promise<void> {
        await this.teamService.deleteTeamFromTutorial({ tutorialId, teamId });
    }
}

results matching ""

    No results matching ""