From 055c48dbf9d35d47f87dc7f99e742384cd498dc8 Mon Sep 17 00:00:00 2001 From: Mathis Date: Tue, 15 Oct 2024 11:23:04 +0200 Subject: [PATCH] Add endpoints for file types management Introduced new endpoints to handle file types: fetching all types, adding a new type, and deleting a type. These additions include necessary guards and parameter parsing for robust API functionality. --- .../backend/src/app/files/files.controller.ts | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/apps/backend/src/app/files/files.controller.ts b/apps/backend/src/app/files/files.controller.ts index 82f48f3..39b5a1a 100644 --- a/apps/backend/src/app/files/files.controller.ts +++ b/apps/backend/src/app/files/files.controller.ts @@ -1,6 +1,6 @@ import { IncomingMessage } from "node:http"; import { - BadRequestException, + BadRequestException, Body, Controller, DefaultValuePipe, Delete, @@ -8,7 +8,7 @@ import { HttpCode, HttpStatus, Param, - ParseIntPipe, + ParseIntPipe, ParseUUIDPipe, Post, Query, Req, @@ -16,10 +16,11 @@ import { Res, Response, StreamableFile, - UseGuards, -} from "@nestjs/common"; + UseGuards +} from '@nestjs/common'; 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 { @@ -126,7 +127,25 @@ export class FilesController { @UseGuards(AdminGuard) @HttpCode(HttpStatus.OK) @Delete(":fileId") - async deleteFile(@Param("fileId") fileId: string) { + async deleteFile(@Param("fileId", ParseUUIDPipe) fileId: string) { return await this.filesService.deleteFile(fileId); } + + @HttpCode(HttpStatus.OK) + @Get("types") + async getTypes() { + //TODO + } + + @UseGuards(AdminGuard) + @HttpCode(HttpStatus.CREATED) + @Post("types/new") + async newType(@Body() body: CreateFileTypeDto) { + //TODO + } + + @Delete("types/:typeId") + async delType(@Param(":typeId", ParseUUIDPipe) typeId: string) { + //TODO + } }