import { Body, Controller, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { CurrentUser } from '../common/decorators/current-user.decorator';
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';
import type { JwtUserPayload } from '../auth/jwt.types';
import { FilesService } from './files.service';
import { PresignedMeterUploadDto } from './dto/presigned-meter-upload.dto';

@ApiTags('files')
@ApiBearerAuth('access-token')
@Controller('files')
@UseGuards(JwtAuthGuard)
export class FilesController {
  constructor(private readonly files: FilesService) {}

  @Post('presigned-meter-upload')
  presigned(@CurrentUser() user: JwtUserPayload, @Body() body: PresignedMeterUploadDto) {
    return this.files.presignedMeterUpload(
      user,
      body.requestId,
      body.kind,
      body.contentType,
      body.fileName,
    );
  }
}
