You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2 KiB

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';
2 years ago
@Controller('seasons')
export class SeasonsController {
constructor(
private seasonsService: SeasonsService,
private seasonStandingsService: SeasonStandingsService,
) {}
2 years ago
@Get()
findAll() {
return this.seasonsService.findAll();
}
@Get(':id')
findOne(@Param() params: any) {
return this.seasonsService.findOne(params.id);
2 years ago
}
@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);
}
2 years ago
}