Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
feat: add a new endpoint that exclude imageData due to perf issue on app
Browse files Browse the repository at this point in the history
  • Loading branch information
yehezkieldio committed Feb 17, 2024
1 parent 8be0f07 commit 5649b40
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions apps/api/src/model/report/report.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,35 @@ export class ReportController
}
}

@Get("no-image")
public async findAllButNotWithImage(): Promise<ResponseFormatInterface<Omit<ReportModel, "imageData">[]>> {
try {
const data: ReportModel[] = await this.modelService.find();

const simplifiedReportModels = data.map((report) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { imageData, ...simplifiedReport } = report;
return simplifiedReport;
});

const response: ResponseFormatInterface<Omit<ReportModel, "imageData">[]> = formatResponse<
Omit<ReportModel, "imageData">[]
>(true, 200, "Found", simplifiedReportModels);

this.loggerService.log(`Find All But Not With Image: ${JSON.stringify(response)}`);

return response;
} catch (error) {
if (error instanceof NotFoundException) {
this.loggerService.error(`Find All But Not With Image: ${error.message}`);
return formatResponse<null>(false, 404, error.message, null);
}

this.loggerService.error(`Find All But Not With Image: ${error.message}`);
return formatResponse<null>(false, 500, error.message, null);
}
}

@Override
public async change(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down

0 comments on commit 5649b40

Please sign in to comment.