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.
This commit is contained in:
parent
1c78912f99
commit
055c48dbf9
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user