|
|
|
@@ -1,6 +1,7 @@
|
|
|
|
import { IncomingMessage } from "node:http";
|
|
|
|
import { IncomingMessage } from "node:http";
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
BadRequestException,
|
|
|
|
BadRequestException,
|
|
|
|
|
|
|
|
Body,
|
|
|
|
Controller,
|
|
|
|
Controller,
|
|
|
|
DefaultValuePipe,
|
|
|
|
DefaultValuePipe,
|
|
|
|
Delete,
|
|
|
|
Delete,
|
|
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
|
HttpStatus,
|
|
|
|
HttpStatus,
|
|
|
|
Param,
|
|
|
|
Param,
|
|
|
|
ParseIntPipe,
|
|
|
|
ParseIntPipe,
|
|
|
|
|
|
|
|
ParseUUIDPipe,
|
|
|
|
Post,
|
|
|
|
Post,
|
|
|
|
Query,
|
|
|
|
Query,
|
|
|
|
Req,
|
|
|
|
Req,
|
|
|
|
@@ -18,6 +20,7 @@ import {
|
|
|
|
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";
|
|
|
|
|
|
|
|
|
|
|
|
@@ -25,8 +28,8 @@ import { FilesService } from "./files.service";
|
|
|
|
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([]);
|
|
|
|
@@ -123,10 +126,30 @@ 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") fileId: string) {
|
|
|
|
async deleteFile(@Param("fileId", ParseUUIDPipe) fileId: string) {
|
|
|
|
return await this.filesService.deleteFile(fileId);
|
|
|
|
return await this.filesService.deleteFile(fileId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@HttpCode(HttpStatus.FOUND)
|
|
|
|
|
|
|
|
@Get("types")
|
|
|
|
|
|
|
|
async getTypes() {
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|