32 lines
940 B
TypeScript
32 lines
940 B
TypeScript
import { Body, Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
|
|
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
|
|
import { RolesGuard } from '../../common/guards/roles.guard';
|
|
import { Roles } from '../../common/decorators/roles.decorator';
|
|
import { Role } from '../../common/enums/role.enum';
|
|
import { ClubsService } from './clubs.service';
|
|
import { CreateClubDto } from './dto/create-club.dto';
|
|
|
|
@Controller('clubs')
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
export class ClubsController {
|
|
constructor(private readonly clubsService: ClubsService) {}
|
|
|
|
@Post()
|
|
@Roles(Role.SUPER_ADMIN)
|
|
create(@Body() dto: CreateClubDto) {
|
|
return this.clubsService.create(dto);
|
|
}
|
|
|
|
@Get()
|
|
@Roles(Role.SUPER_ADMIN)
|
|
findAll() {
|
|
return this.clubsService.findAll();
|
|
}
|
|
|
|
@Get(':id')
|
|
@Roles(Role.ADMIN, Role.SUPER_ADMIN)
|
|
findOne(@Param('id') id: string) {
|
|
return this.clubsService.findById(id);
|
|
}
|
|
}
|