import {
    Controller,
    All,
    Req,
    Res,
    Get,
    Post,
    Patch,
    Param,
    Delete,
    Head,
    Options,
} from '@nestjs/common';
import { Request, Response } from "express"
import { TusService } from './tus.service';

@Controller('upload')
export class UploadController {
    constructor(private readonly tusService: TusService) { }
    // @Post()
    // async handlePost(@Req() req: Request, @Res() res: Response) {
    //     return this.tusService.handleTus(req, res);
    // }


    @Options()
    async handleOptions(@Req() req: Request, @Res() res: Response) {
        return this.tusService.handleTus(req, res);
    }

    @Head()
    async handleHead(@Req() req: Request, @Res() res: Response) {
        return this.tusService.handleTus(req, res);
    }

    @Post()
    async handlePost(@Req() req: Request, @Res() res: Response) {
        return this.tusService.handleTus(req, res);
    }
    @Get("/*")
    async handleGet(@Req() req: Request, @Res() res: Response) {
        return this.tusService.handleTus(req, res);
    }

    @Patch("/*")
    async handlePatch(@Req() req: Request, @Res() res: Response) {
        return this.tusService.handleTus(req, res);
    }

    // Keeping the catch-all method as a fallback
    @All()
    async handleUpload(@Req() req: Request, @Res() res: Response) {
        return this.tusService.handleTus(req, res);
    }
}