2024-04-29 05:24:21 +02:00
|
|
|
import { Body, Controller, HttpCode, HttpStatus, Post } from '@nestjs/common';
|
2024-04-16 07:26:37 +02:00
|
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
|
|
|
import { AssetResponseDto } from 'src/dtos/asset-response.dto';
|
|
|
|
|
import { AuthDto } from 'src/dtos/auth.dto';
|
|
|
|
|
import { AssetDeltaSyncDto, AssetDeltaSyncResponseDto, AssetFullSyncDto } from 'src/dtos/sync.dto';
|
|
|
|
|
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
|
|
|
|
import { SyncService } from 'src/services/sync.service';
|
|
|
|
|
|
|
|
|
|
@ApiTags('Sync')
|
|
|
|
|
@Controller('sync')
|
|
|
|
|
export class SyncController {
|
|
|
|
|
constructor(private service: SyncService) {}
|
|
|
|
|
|
2024-04-29 05:24:21 +02:00
|
|
|
@Post('full-sync')
|
|
|
|
|
@HttpCode(HttpStatus.OK)
|
2024-05-09 13:58:44 -04:00
|
|
|
@Authenticated()
|
2024-04-29 05:24:21 +02:00
|
|
|
getFullSyncForUser(@Auth() auth: AuthDto, @Body() dto: AssetFullSyncDto): Promise<AssetResponseDto[]> {
|
|
|
|
|
return this.service.getFullSync(auth, dto);
|
2024-04-16 07:26:37 +02:00
|
|
|
}
|
|
|
|
|
|
2024-04-29 05:24:21 +02:00
|
|
|
@Post('delta-sync')
|
|
|
|
|
@HttpCode(HttpStatus.OK)
|
2024-05-09 13:58:44 -04:00
|
|
|
@Authenticated()
|
2024-04-29 05:24:21 +02:00
|
|
|
getDeltaSync(@Auth() auth: AuthDto, @Body() dto: AssetDeltaSyncDto): Promise<AssetDeltaSyncResponseDto> {
|
|
|
|
|
return this.service.getDeltaSync(auth, dto);
|
2024-04-16 07:26:37 +02:00
|
|
|
}
|
|
|
|
|
}
|