mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 20:26:27 -04:00
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
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.interface';
|
|
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
|
import { PartnerService } from 'src/services/partner.service';
|
|
import { UUIDParamDto } from 'src/validation';
|
|
|
|
@ApiTags('Partner')
|
|
@Controller('partner')
|
|
export class PartnerController {
|
|
constructor(private service: PartnerService) {}
|
|
|
|
@Get()
|
|
@ApiQuery({ name: 'direction', type: 'string', enum: PartnerDirection, required: true })
|
|
@Authenticated()
|
|
// TODO: remove 'direction' and convert to full query dto
|
|
getPartners(@Auth() auth: AuthDto, @Query('direction') direction: PartnerDirection): Promise<PartnerResponseDto[]> {
|
|
return this.service.getAll(auth, direction);
|
|
}
|
|
|
|
@Post(':id')
|
|
@Authenticated()
|
|
createPartner(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<PartnerResponseDto> {
|
|
return this.service.create(auth, id);
|
|
}
|
|
|
|
@Put(':id')
|
|
@Authenticated()
|
|
updatePartner(
|
|
@Auth() auth: AuthDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
@Body() dto: UpdatePartnerDto,
|
|
): Promise<PartnerResponseDto> {
|
|
return this.service.update(auth, id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@Authenticated()
|
|
removePartner(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
|
return this.service.remove(auth, id);
|
|
}
|
|
}
|