cr
This commit is contained in:
@@ -4,20 +4,20 @@ import {
|
||||
Param,
|
||||
Query,
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
} from "@nestjs/common";
|
||||
import {
|
||||
ApiTags,
|
||||
ApiOperation,
|
||||
ApiResponse,
|
||||
ApiQuery,
|
||||
ApiParam,
|
||||
} from '@nestjs/swagger';
|
||||
import { LeaguesService } from './leagues.service';
|
||||
import { Sport } from '@prisma/client';
|
||||
import { Public } from '../../common/decorators';
|
||||
} from "@nestjs/swagger";
|
||||
import { LeaguesService } from "./leagues.service";
|
||||
import { Sport } from "@prisma/client";
|
||||
import { Public } from "../../common/decorators";
|
||||
|
||||
@ApiTags('Leagues')
|
||||
@Controller('leagues')
|
||||
@ApiTags("Leagues")
|
||||
@Controller("leagues")
|
||||
export class LeaguesController {
|
||||
constructor(private readonly leaguesService: LeaguesService) {}
|
||||
|
||||
@@ -25,10 +25,10 @@ export class LeaguesController {
|
||||
* GET /leagues/countries
|
||||
* Get all countries
|
||||
*/
|
||||
@Get('countries')
|
||||
@Get("countries")
|
||||
@Public()
|
||||
@ApiOperation({ summary: 'Get all countries' })
|
||||
@ApiResponse({ status: 200, description: 'List of countries' })
|
||||
@ApiOperation({ summary: "Get all countries" })
|
||||
@ApiResponse({ status: 200, description: "List of countries" })
|
||||
async getCountries() {
|
||||
return this.leaguesService.findAllCountries();
|
||||
}
|
||||
@@ -37,13 +37,13 @@ export class LeaguesController {
|
||||
* GET /leagues/countries/:id
|
||||
* Get country by ID with leagues
|
||||
*/
|
||||
@Get('countries/:id')
|
||||
@Get("countries/:id")
|
||||
@Public()
|
||||
@ApiOperation({ summary: 'Get country by ID with leagues' })
|
||||
@ApiParam({ name: 'id', description: 'Country ID' })
|
||||
async getCountryById(@Param('id') id: string) {
|
||||
@ApiOperation({ summary: "Get country by ID with leagues" })
|
||||
@ApiParam({ name: "id", description: "Country ID" })
|
||||
async getCountryById(@Param("id") id: string) {
|
||||
const country = await this.leaguesService.findCountryById(id);
|
||||
if (!country) throw new NotFoundException('Country not found');
|
||||
if (!country) throw new NotFoundException("Country not found");
|
||||
return country;
|
||||
}
|
||||
|
||||
@@ -53,13 +53,13 @@ export class LeaguesController {
|
||||
*/
|
||||
@Get()
|
||||
@Public()
|
||||
@ApiOperation({ summary: 'Get all leagues' })
|
||||
@ApiOperation({ summary: "Get all leagues" })
|
||||
@ApiQuery({
|
||||
name: 'sport',
|
||||
name: "sport",
|
||||
required: false,
|
||||
enum: ['football', 'basketball'],
|
||||
enum: ["football", "basketball"],
|
||||
})
|
||||
async getLeagues(@Query('sport') sport?: string) {
|
||||
async getLeagues(@Query("sport") sport?: string) {
|
||||
return this.leaguesService.findAllLeagues(sport as Sport);
|
||||
}
|
||||
|
||||
@@ -68,21 +68,21 @@ export class LeaguesController {
|
||||
* Get head-to-head matches between two teams
|
||||
* NOTE: Must come before /teams/:id to avoid route conflict
|
||||
*/
|
||||
@Get('teams/h2h')
|
||||
@Get("teams/h2h")
|
||||
@Public()
|
||||
@ApiOperation({ summary: 'Get head-to-head matches between two teams' })
|
||||
@ApiQuery({ name: 'team1', required: true })
|
||||
@ApiQuery({ name: 'team2', required: true })
|
||||
@ApiQuery({ name: 'limit', required: false, type: Number })
|
||||
@ApiOperation({ summary: "Get head-to-head matches between two teams" })
|
||||
@ApiQuery({ name: "team1", required: true })
|
||||
@ApiQuery({ name: "team2", required: true })
|
||||
@ApiQuery({ name: "limit", required: false, type: Number })
|
||||
async getHeadToHead(
|
||||
@Query('team1') team1: string,
|
||||
@Query('team2') team2: string,
|
||||
@Query('limit') limit?: string,
|
||||
@Query("team1") team1: string,
|
||||
@Query("team2") team2: string,
|
||||
@Query("limit") limit?: string,
|
||||
) {
|
||||
return this.leaguesService.getHeadToHead(
|
||||
team1,
|
||||
team2,
|
||||
parseInt(limit || '10', 10),
|
||||
parseInt(limit || "10", 10),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -90,16 +90,16 @@ export class LeaguesController {
|
||||
* GET /leagues/teams/search
|
||||
* Search teams by name
|
||||
*/
|
||||
@Get('teams/search')
|
||||
@Get("teams/search")
|
||||
@Public()
|
||||
@ApiOperation({ summary: 'Search teams by name' })
|
||||
@ApiQuery({ name: 'q', required: true, description: 'Search query' })
|
||||
@ApiOperation({ summary: "Search teams by name" })
|
||||
@ApiQuery({ name: "q", required: true, description: "Search query" })
|
||||
@ApiQuery({
|
||||
name: 'sport',
|
||||
name: "sport",
|
||||
required: false,
|
||||
enum: ['football', 'basketball'],
|
||||
enum: ["football", "basketball"],
|
||||
})
|
||||
async searchTeams(@Query('q') query: string, @Query('sport') sport?: string) {
|
||||
async searchTeams(@Query("q") query: string, @Query("sport") sport?: string) {
|
||||
return this.leaguesService.searchTeams(query, sport as Sport);
|
||||
}
|
||||
|
||||
@@ -107,13 +107,13 @@ export class LeaguesController {
|
||||
* GET /leagues/teams/:id
|
||||
* Get team by ID
|
||||
*/
|
||||
@Get('teams/:id')
|
||||
@Get("teams/:id")
|
||||
@Public()
|
||||
@ApiOperation({ summary: 'Get team by ID' })
|
||||
@ApiParam({ name: 'id', description: 'Team ID' })
|
||||
async getTeamById(@Param('id') id: string) {
|
||||
@ApiOperation({ summary: "Get team by ID" })
|
||||
@ApiParam({ name: "id", description: "Team ID" })
|
||||
async getTeamById(@Param("id") id: string) {
|
||||
const team = await this.leaguesService.findTeamById(id);
|
||||
if (!team) throw new NotFoundException('Team not found');
|
||||
if (!team) throw new NotFoundException("Team not found");
|
||||
return team;
|
||||
}
|
||||
|
||||
@@ -121,18 +121,18 @@ export class LeaguesController {
|
||||
* GET /leagues/teams/:id/matches
|
||||
* Get team's recent matches
|
||||
*/
|
||||
@Get('teams/:id/matches')
|
||||
@Get("teams/:id/matches")
|
||||
@Public()
|
||||
@ApiOperation({ summary: "Get team's recent matches" })
|
||||
@ApiParam({ name: 'id', description: 'Team ID' })
|
||||
@ApiQuery({ name: 'limit', required: false, type: Number })
|
||||
@ApiParam({ name: "id", description: "Team ID" })
|
||||
@ApiQuery({ name: "limit", required: false, type: Number })
|
||||
async getTeamMatches(
|
||||
@Param('id') id: string,
|
||||
@Query('limit') limit?: string,
|
||||
@Param("id") id: string,
|
||||
@Query("limit") limit?: string,
|
||||
) {
|
||||
return this.leaguesService.getTeamRecentMatches(
|
||||
id,
|
||||
parseInt(limit || '10', 10),
|
||||
parseInt(limit || "10", 10),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -140,13 +140,13 @@ export class LeaguesController {
|
||||
* GET /leagues/:id
|
||||
* Get league by ID
|
||||
*/
|
||||
@Get(':id')
|
||||
@Get(":id")
|
||||
@Public()
|
||||
@ApiOperation({ summary: 'Get league by ID' })
|
||||
@ApiParam({ name: 'id', description: 'League ID' })
|
||||
async getLeagueById(@Param('id') id: string) {
|
||||
@ApiOperation({ summary: "Get league by ID" })
|
||||
@ApiParam({ name: "id", description: "League ID" })
|
||||
async getLeagueById(@Param("id") id: string) {
|
||||
const league = await this.leaguesService.findLeagueById(id);
|
||||
if (!league) throw new NotFoundException('League not found');
|
||||
if (!league) throw new NotFoundException("League not found");
|
||||
return league;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user