From 877e13043db702665b68017dd908fd6a5175d01a Mon Sep 17 00:00:00 2001 From: Mathis Date: Tue, 15 Oct 2024 13:51:53 +0200 Subject: [PATCH] Implement getAllFilesTypes in files controller Added return statement to getTypes endpoint in files controller, utilizing the newly updated getAllFilesTypes method from the files service. Also fixed minor formatting issues. --- apps/backend/src/app/files/files.controller.ts | 4 ++-- apps/backend/src/app/files/files.service.ts | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/backend/src/app/files/files.controller.ts b/apps/backend/src/app/files/files.controller.ts index f1c0c39..525ad67 100644 --- a/apps/backend/src/app/files/files.controller.ts +++ b/apps/backend/src/app/files/files.controller.ts @@ -136,14 +136,14 @@ export class FilesController { @HttpCode(HttpStatus.FOUND) @Get("types") async getTypes() { - //TODO + return await this.filesService.getAllFilesTypes(); } @HttpCode(HttpStatus.CREATED) @UseGuards(AdminGuard) @Post("types/new") async newType(@Body() body: CreateFileTypeDto) { - return await this.filesService.createFileType(body.name, body.mime) + return await this.filesService.createFileType(body.name, body.mime); } @HttpCode(HttpStatus.ACCEPTED) diff --git a/apps/backend/src/app/files/files.service.ts b/apps/backend/src/app/files/files.service.ts index e3378cd..68aa367 100644 --- a/apps/backend/src/app/files/files.service.ts +++ b/apps/backend/src/app/files/files.service.ts @@ -285,12 +285,13 @@ export class FilesService { * * @return {Promise} Promise that resolves to an array of file types. */ - public async getAllFilesTypes() { - return await this.database.use() + public async getAllFilesTypes(): Promise> { + return await this.database + .use() .select() .from(FilesTypesTable) .prepare("getAllFilesTypes") - .execute() + .execute(); } public async removeFileType() {