Refactor files controller imports and rearrange decorators

Reorganized import statements for cleaner structure and added a missing import for CreateFileTypeDto. Adjusted the placement of UseGuards decorators to maintain consistency across methods.
This commit is contained in:
Mathis H (Avnyr) 2024-10-15 11:27:47 +02:00
parent e7830095b3
commit 8ee5410c91
Signed by: Mathis
GPG Key ID: DD9E0666A747D126
2 changed files with 17 additions and 13 deletions

View File

@ -1,6 +1,7 @@
import { IncomingMessage } from "node:http";
import {
BadRequestException, Body,
BadRequestException,
Body,
Controller,
DefaultValuePipe,
Delete,
@ -8,7 +9,8 @@ import {
HttpCode,
HttpStatus,
Param,
ParseIntPipe, ParseUUIDPipe,
ParseIntPipe,
ParseUUIDPipe,
Post,
Query,
Req,
@ -16,18 +18,18 @@ import {
Res,
Response,
StreamableFile,
UseGuards
} from '@nestjs/common';
UseGuards,
} from "@nestjs/common";
import { CreateFileTypeDto } from "apps/backend/src/app/files/files.dto";
import { AdminGuard, InsertAdminState } from "../auth/auth.guard";
import { FilesService } from "./files.service";
import { CreateFileTypeDto } from 'apps/backend/src/app/files/files.dto';
@Controller("files")
export class FilesController {
constructor(private readonly filesService: FilesService) {}
@UseGuards(InsertAdminState)
@HttpCode(HttpStatus.OK)
@UseGuards(InsertAdminState)
@Post("new")
async saveFile(@Req() req: IncomingMessage, @Res() res: Response) {
let fileBuffer: Buffer = Buffer.from([]);
@ -124,26 +126,28 @@ export class FilesController {
return await this.filesService.get(fileId);
}
@UseGuards(AdminGuard)
@HttpCode(HttpStatus.OK)
@UseGuards(AdminGuard)
@Delete(":fileId")
async deleteFile(@Param("fileId", ParseUUIDPipe) fileId: string) {
return await this.filesService.deleteFile(fileId);
}
@HttpCode(HttpStatus.OK)
@Get("types")
async getTypes() {
@HttpCode(HttpStatus.FOUND)
@Get("types")
async getTypes() {
//TODO
}
}
@UseGuards(AdminGuard)
@HttpCode(HttpStatus.CREATED)
@UseGuards(AdminGuard)
@Post("types/new")
async newType(@Body() body: CreateFileTypeDto) {
//TODO
}
@HttpCode(HttpStatus.ACCEPTED)
@UseGuards(AdminGuard)
@Delete("types/:typeId")
async delType(@Param(":typeId", ParseUUIDPipe) typeId: string) {
//TODO