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.
This commit is contained in:
Mathis H (Avnyr) 2024-10-15 13:51:53 +02:00
parent 6bb9510356
commit 877e13043d
Signed by: Mathis
GPG Key ID: DD9E0666A747D126
2 changed files with 6 additions and 5 deletions

View File

@ -136,14 +136,14 @@ export class FilesController {
@HttpCode(HttpStatus.FOUND) @HttpCode(HttpStatus.FOUND)
@Get("types") @Get("types")
async getTypes() { async getTypes() {
//TODO return await this.filesService.getAllFilesTypes();
} }
@HttpCode(HttpStatus.CREATED) @HttpCode(HttpStatus.CREATED)
@UseGuards(AdminGuard) @UseGuards(AdminGuard)
@Post("types/new") @Post("types/new")
async newType(@Body() body: CreateFileTypeDto) { 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) @HttpCode(HttpStatus.ACCEPTED)

View File

@ -285,12 +285,13 @@ export class FilesService {
* *
* @return {Promise<Array>} Promise that resolves to an array of file types. * @return {Promise<Array>} Promise that resolves to an array of file types.
*/ */
public async getAllFilesTypes() { public async getAllFilesTypes(): Promise<Array<object>> {
return await this.database.use() return await this.database
.use()
.select() .select()
.from(FilesTypesTable) .from(FilesTypesTable)
.prepare("getAllFilesTypes") .prepare("getAllFilesTypes")
.execute() .execute();
} }
public async removeFileType() { public async removeFileType() {