import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common'; import { ApiQuery, ApiTags } from '@nestjs/swagger'; import { AuthDto } from 'src/dtos/auth.dto'; import { PartnerResponseDto, UpdatePartnerDto } from 'src/dtos/partner.dto'; import { PartnerDirection } from 'src/interfaces/partner.repository'; import { Auth, Authenticated } from 'src/middleware/auth.guard'; import { PartnerService } from 'src/services/partner.service'; import { UUIDParamDto } from 'src/validation'; @ApiTags('Partner') @Controller('partner') @Authenticated() export class PartnerController { constructor(private service: PartnerService) {} @Get() @ApiQuery({ name: 'direction', type: 'string', enum: PartnerDirection, required: true }) // TODO: remove 'direction' and convert to full query dto getPartners(@Auth() auth: AuthDto, @Query('direction') direction: PartnerDirection): Promise { return this.service.getAll(auth, direction); } @Post(':id') createPartner(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise { return this.service.create(auth, id); } @Put(':id') updatePartner( @Auth() auth: AuthDto, @Param() { id }: UUIDParamDto, @Body() dto: UpdatePartnerDto, ): Promise { return this.service.update(auth, id, dto); } @Delete(':id') removePartner(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise { return this.service.remove(auth, id); } }