import { Body, Controller, Get, Param, Post, UseGuards } from '@nestjs/common'; import { SeasonsService } from './seasons.service'; import { SeasonStandingsService } from 'src/season-standings/season-standings.service'; import { AuthGuard } from '@nestjs/passport'; import { JwtAuthGuard } from 'src/authz/authz.guard'; import { RolesGuard } from 'src/authorization/roles.guard'; import { Roles } from 'src/authorization/roles.decorator'; @Controller('seasons') export class SeasonsController { constructor( private seasonsService: SeasonsService, private seasonStandingsService: SeasonStandingsService, ) {} @Get() findAll() { return this.seasonsService.findAll(); } @Get(':id') findOne(@Param() params: any) { return this.seasonsService.findOne(params.id); } @Get(':id/refresh') updateSeason(@Param() params: any) { return this.seasonStandingsService.updateStandings(params.id); } @UseGuards(JwtAuthGuard, RolesGuard) @Post('create') @Roles(['create:seasons']) create(@Body() body: any) { return this.seasonsService.create(body.title, body.subTitle, body.startingDate); } }