import { Controller, Delete, Get, Param, Res } from '@nestjs/common';
import { Response } from 'express';
import { MediasService } from './medias.service';
@Controller('medias')
export class MediasController {
  constructor(private readonly mediaService: MediasService) {}

  @Get(':type/:subdir/:filename')
  async serveMedia(
    @Param('type') type: 'avatars' | 'products',
    @Param('subdir') subdir: string,
    @Param('filename') filename: string,
    @Res() res: Response,
  ) {
    return this.mediaService.serveMedia(type, subdir, filename, res);
  }

  @Delete(':type/:subdir/:filename')
  async deleteMedia(
    @Param('type') type: 'avatars' | 'products',
    @Param('subdir') subdir: string,
    @Param('filename') filename: string,
  ) {
    return this.mediaService.deleteMedia(type, subdir, filename);
  }
}
