32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { Controller, Get, Param } from '@nestjs/common';
|
|
import { ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
|
|
|
|
import type { Collection, Locale } from '@sport/types';
|
|
|
|
import { Public } from '@/common/decorators/public.decorator';
|
|
import { RequestLocale } from '@/common/i18n';
|
|
|
|
import { CollectionsService } from './collections.service';
|
|
|
|
@ApiTags('catalog')
|
|
@Controller('collections')
|
|
export class CollectionsController {
|
|
constructor(private readonly collectionsService: CollectionsService) {}
|
|
|
|
@Public()
|
|
@Get()
|
|
@ApiOperation({ summary: 'List live collections' })
|
|
@ApiQuery({ name: 'locale', required: false, enum: ['vi', 'en'] })
|
|
list(@RequestLocale() locale: Locale): Promise<Collection[]> {
|
|
return this.collectionsService.list(locale);
|
|
}
|
|
|
|
@Public()
|
|
@Get(':slug')
|
|
@ApiOperation({ summary: 'Get one collection by slug' })
|
|
@ApiQuery({ name: 'locale', required: false, enum: ['vi', 'en'] })
|
|
getBySlug(@Param('slug') slug: string, @RequestLocale() locale: Locale): Promise<Collection> {
|
|
return this.collectionsService.getBySlug(slug, locale);
|
|
}
|
|
}
|