training_data/apps/server/src/upload/upload.controller.ts

55 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-01-06 08:45:23 +08:00
import {
2025-01-27 22:43:31 +08:00
Controller,
All,
Req,
Res,
Get,
Post,
Patch,
Param,
Delete,
Head,
Options,
2025-01-06 08:45:23 +08:00
} from '@nestjs/common';
2025-01-27 22:43:31 +08:00
import { Request, Response } from 'express';
2025-01-06 18:30:16 +08:00
import { TusService } from './tus.service';
2025-01-03 09:24:46 +08:00
2025-01-06 08:45:23 +08:00
@Controller('upload')
2025-01-03 09:24:46 +08:00
export class UploadController {
2025-01-27 22:43:31 +08:00
constructor(private readonly tusService: TusService) {}
// @Post()
// async handlePost(@Req() req: Request, @Res() res: Response) {
// return this.tusService.handleTus(req, res);
// }
2025-01-08 00:52:11 +08:00
2025-01-27 22:43:31 +08:00
@Options()
async handleOptions(@Req() req: Request, @Res() res: Response) {
return this.tusService.handleTus(req, res);
}
2025-01-08 00:52:11 +08:00
2025-01-27 22:43:31 +08:00
@Head()
async handleHead(@Req() req: Request, @Res() res: Response) {
return this.tusService.handleTus(req, res);
}
2025-01-08 00:52:11 +08:00
2025-01-27 22:43:31 +08:00
@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);
}
2025-01-08 00:52:11 +08:00
2025-01-27 22:43:31 +08:00
@Patch('/*')
async handlePatch(@Req() req: Request, @Res() res: Response) {
return this.tusService.handleTus(req, res);
}
2025-01-06 08:45:23 +08:00
2025-01-27 22:43:31 +08:00
// Keeping the catch-all method as a fallback
@All()
async handleUpload(@Req() req: Request, @Res() res: Response) {
return this.tusService.handleTus(req, res);
}
}