feat: return null if no image exist

This commit is contained in:
Methapon2001 2024-06-10 11:03:40 +07:00
parent 43b97be4f1
commit 5492f9533a

View file

@ -15,7 +15,7 @@ import {
import { Prisma, Status, UserType } from "@prisma/client";
import prisma from "../db";
import minio from "../services/minio";
import minio, { presignedGetObjectIfExist } from "../services/minio";
import { RequestWithUser } from "../interfaces/user";
import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
@ -185,7 +185,7 @@ export class UserController extends Controller {
result.map(async (v) => ({
...v,
branch: includeBranch ? v.branch.map((a) => a.branch) : undefined,
profileImageUrl: await minio.presignedGetObject(
profileImageUrl: await presignedGetObjectIfExist(
MINIO_BUCKET,
imageLocation(v.id),
12 * 60 * 60,