import { Controller, Get, Query } from '@nestjs/common';
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
import {
  SyncBootstrapResponseDto,
  SyncChangesQueryDto,
  SyncChangesResponseDto,
} from './sync.dto';
import { SyncService } from './sync.service';

@ApiTags('sync')
@Controller({
  path: 'sync',
  version: '1',
})
export class SyncController {
  constructor(private readonly syncService: SyncService) {}

  @Get('bootstrap')
  @ApiOkResponse({ type: SyncBootstrapResponseDto })
  async bootstrap(): Promise<SyncBootstrapResponseDto> {
    return this.syncService.bootstrap();
  }

  @Get('changes')
  @ApiOkResponse({ type: SyncChangesResponseDto })
  async changes(
    @Query() query: SyncChangesQueryDto,
  ): Promise<SyncChangesResponseDto> {
    return this.syncService.changes(query.after ?? '0');
  }
}
