Add HTTP status and implement file fetching

Included HTTP status code for the getFilesForMachine method. Implemented the service call to fetch files associated with a machine.
This commit is contained in:
Mathis H (Avnyr) 2024-10-08 14:00:04 +02:00
parent 3844153340
commit 64f9cd497f
Signed by: Mathis
GPG Key ID: DD9E0666A747D126

View File

@ -3,6 +3,8 @@ import {
DefaultValuePipe, DefaultValuePipe,
Delete, Delete,
Get, Get,
HttpCode,
HttpStatus,
Param, Param,
ParseBoolPipe, ParseBoolPipe,
ParseIntPipe, ParseIntPipe,
@ -37,11 +39,19 @@ export class MachinesController {
//TODO CRUD fileType associated to machine //TODO CRUD fileType associated to machine
@HttpCode(HttpStatus.OK)
@Get("files/:machineId") @Get("files/:machineId")
async getFilesForMachine( async getFilesForMachine(
@Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number, @Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number,
@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,
@Param("machineId") machineId: string, @Param("machineId") machineId: string,
) {} ) {
return this.machineService.findFilesForMachine(
limit,
offset,
search,
machineId,
);
}
} }