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 { IncomingMessage } from "node:http";
|
||||||
import {
|
import {
|
||||||
BadRequestException,
|
BadRequestException, Body,
|
||||||
Controller,
|
Controller,
|
||||||
DefaultValuePipe,
|
DefaultValuePipe,
|
||||||
Delete,
|
Delete,
|
||||||
@ -8,7 +8,7 @@ import {
|
|||||||
HttpCode,
|
HttpCode,
|
||||||
HttpStatus,
|
HttpStatus,
|
||||||
Param,
|
Param,
|
||||||
ParseIntPipe,
|
ParseIntPipe, ParseUUIDPipe,
|
||||||
Post,
|
Post,
|
||||||
Query,
|
Query,
|
||||||
Req,
|
Req,
|
||||||
@ -16,10 +16,11 @@ import {
|
|||||||
Res,
|
Res,
|
||||||
Response,
|
Response,
|
||||||
StreamableFile,
|
StreamableFile,
|
||||||
UseGuards,
|
UseGuards
|
||||||
} from "@nestjs/common";
|
} from '@nestjs/common';
|
||||||
import { AdminGuard, InsertAdminState } from "../auth/auth.guard";
|
import { AdminGuard, InsertAdminState } from "../auth/auth.guard";
|
||||||
import { FilesService } from "./files.service";
|
import { FilesService } from "./files.service";
|
||||||
|
import { CreateFileTypeDto } from 'apps/backend/src/app/files/files.dto';
|
||||||
|
|
||||||
@Controller("files")
|
@Controller("files")
|
||||||
export class FilesController {
|
export class FilesController {
|
||||||
@ -126,7 +127,25 @@ export class FilesController {
|
|||||||
@UseGuards(AdminGuard)
|
@UseGuards(AdminGuard)
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@Delete(":fileId")
|
@Delete(":fileId")
|
||||||
async deleteFile(@Param("fileId") fileId: string) {
|
async deleteFile(@Param("fileId", ParseUUIDPipe) fileId: string) {
|
||||||
return await this.filesService.deleteFile(fileId);
|
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