feat: return null if no image exist

This commit is contained in:
Methapon2001 2024-06-10 11:12:43 +07:00
parent 5492f9533a
commit 1dc0db7987

View file

@ -15,7 +15,7 @@ import {
} from "tsoa";
import { RequestWithUser } from "../interfaces/user";
import prisma from "../db";
import minio from "../services/minio";
import minio, { presignedGetObjectIfExist } from "../services/minio";
import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
@ -170,7 +170,11 @@ export class CustomerController extends Controller {
result: await Promise.all(
result.map(async (v) => ({
...v,
imageUrl: await minio.presignedGetObject(MINIO_BUCKET, imageLocation(v.id), 12 * 60 * 60),
imageUrl: await presignedGetObjectIfExist(
MINIO_BUCKET,
imageLocation(v.id),
12 * 60 * 60,
),
})),
),
page,
@ -450,7 +454,7 @@ export class CustomerController extends Controller {
});
return Object.assign(record, {
imageUrl: await minio.presignedGetObject(
imageUrl: await presignedGetObjectIfExist(
MINIO_BUCKET,
imageLocation(record.id),
12 * 60 * 60,