feat: return null if no image exist
This commit is contained in:
parent
5492f9533a
commit
1dc0db7987
1 changed files with 7 additions and 3 deletions
|
|
@ -15,7 +15,7 @@ import {
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import { RequestWithUser } from "../interfaces/user";
|
import { RequestWithUser } from "../interfaces/user";
|
||||||
import prisma from "../db";
|
import prisma from "../db";
|
||||||
import minio from "../services/minio";
|
import minio, { presignedGetObjectIfExist } from "../services/minio";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
|
|
||||||
|
|
@ -170,7 +170,11 @@ export class CustomerController extends Controller {
|
||||||
result: await Promise.all(
|
result: await Promise.all(
|
||||||
result.map(async (v) => ({
|
result.map(async (v) => ({
|
||||||
...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,
|
page,
|
||||||
|
|
@ -450,7 +454,7 @@ export class CustomerController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
return Object.assign(record, {
|
return Object.assign(record, {
|
||||||
imageUrl: await minio.presignedGetObject(
|
imageUrl: await presignedGetObjectIfExist(
|
||||||
MINIO_BUCKET,
|
MINIO_BUCKET,
|
||||||
imageLocation(record.id),
|
imageLocation(record.id),
|
||||||
12 * 60 * 60,
|
12 * 60 * 60,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue