import { Controller, Get, Delete, Query, HttpCode, HttpStatus, } from '@nestjs/common'; import { ApiTags, ApiOperation, ApiQuery } from '@nestjs/swagger'; import { FilestackService } from './filestack.service'; import { FileType } from './enums/file-type.enum'; import { LogToDiscord } from 'src/shared/decorators/log-to-discord.decorator'; @ApiTags('Upload: Filestack Storage') @Controller('filestack') @LogToDiscord() export class FilestackController { constructor(private readonly filestackService: FilestackService) {} @Get('upload-params') @ApiOperation({ summary: 'Get upload parameters with optional filename' }) @ApiQuery({ name: 'type', enum: FileType, required: false }) @ApiQuery({ name: 'filename', required: false, description: 'Custom filename for the upload', }) getUploadParams( @Query('type') type?: FileType, @Query('filename') filename?: string, ) { return this.filestackService.getUploadParams(type, filename); } @Get('by-handle') @ApiOperation({ summary: 'Get file details by handle' }) async getFileByHandle(@Query('handle') handle: string): Promise { return this.filestackService.getFileByHandle(handle); } @Delete('by-url') @HttpCode(HttpStatus.OK) @ApiOperation({ summary: 'Delete file by URL' }) async deleteFileByUrl(@Query('url') url: string) { const result = await this.filestackService.deleteFileByUrl(url); return { message: 'File deleted successfully', ...result, }; } }