import { Controller, Post, UseInterceptors, UploadedFiles, ParseFilePipe, MaxFileSizeValidator, FileTypeValidator } from '@nestjs/common';
import { FilesInterceptor } from '@nestjs/platform-express';
import { TempUploadService } from './temp-upload.service';

@Controller('uploads/temp')
export class TempUploadController {
  constructor(private readonly tempUploadService: TempUploadService) { }

  @Post()
  @UseInterceptors(FilesInterceptor('photos', 4))
  async uploadTemp(
    @UploadedFiles(
      new ParseFilePipe({
        validators: [
          new MaxFileSizeValidator({ maxSize: 20 * 1024 * 1024 }), // bump to 20MB for PDFs
          new FileTypeValidator({ fileType: /image\/(jpeg|png|webp)|application\/pdf/ }), // ✅ add PDF
        ],
      }),
    )
    files: Express.Multer.File[],
  ) {
    return this.tempUploadService.saveTempFiles(files)
  }
}