Refactor response return statements in files controller

Reformat the return statements for better readability and consistency. The changes ensure that the status codes and response body are returned in a clearer and more maintainable format.
This commit is contained in:
Mathis H (Avnyr) 2024-10-08 13:26:32 +02:00
parent 392446fa06
commit fd1742e9dc
Signed by: Mathis
GPG Key ID: DD9E0666A747D126

View File

@ -77,24 +77,30 @@ export class FilesController {
} }
console.log("Executing save procedure..."); console.log("Executing save procedure...");
return res return (
// @ts-ignore res
.status(HttpStatus.CREATED) // @ts-ignore
.send(await this.filesService.save(fileBuffer, Params)); .status(HttpStatus.CREATED)
.send(await this.filesService.save(fileBuffer, Params))
);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
return res return (
// @ts-ignore res
.status(err.status || HttpStatus.INTERNAL_SERVER_ERROR) // @ts-ignore
.send(err); .status(err.status || HttpStatus.INTERNAL_SERVER_ERROR)
.send(err)
);
} }
}); });
req.on("error", (err) => { req.on("error", (err) => {
return res return (
// @ts-ignore res
.status(err.status || HttpStatus.INTERNAL_SERVER_ERROR) // @ts-ignore
.send(err); .status(err.status || HttpStatus.INTERNAL_SERVER_ERROR)
.send(err)
);
}); });
return; return;
@ -107,7 +113,7 @@ export class FilesController {
@Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number, @Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number,
@Query("search", new DefaultValuePipe("")) search: string, @Query("search", new DefaultValuePipe("")) search: string,
) { ) {
return this.filesService.search(limit, offset, search) return this.filesService.search(limit, offset, search);
} }
@HttpCode(HttpStatus.FOUND) @HttpCode(HttpStatus.FOUND)