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