feat: return null if no image exist
This commit is contained in:
parent
1dc0db7987
commit
5f20d8b052
1 changed files with 3 additions and 3 deletions
|
|
@ -17,7 +17,7 @@ import { RequestWithUser } from "../interfaces/user";
|
|||
import prisma from "../db";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import minio from "../services/minio";
|
||||
import minio, { presignedGetObjectIfExist } from "../services/minio";
|
||||
|
||||
if (!process.env.MINIO_BUCKET) {
|
||||
throw Error("Require MinIO bucket.");
|
||||
|
|
@ -130,7 +130,7 @@ export class EmployeeController extends Controller {
|
|||
result: await Promise.all(
|
||||
result.map(async (v) => ({
|
||||
...v,
|
||||
profileImageUrl: await minio.presignedGetObject(
|
||||
profileImageUrl: await presignedGetObjectIfExist(
|
||||
MINIO_BUCKET,
|
||||
imageLocation(v.id),
|
||||
12 * 60 * 60,
|
||||
|
|
@ -243,7 +243,7 @@ export class EmployeeController extends Controller {
|
|||
this.setStatus(HttpStatus.CREATED);
|
||||
|
||||
return Object.assign(record, {
|
||||
profileImageUrl: await minio.presignedPutObject(
|
||||
profileImageUrl: await presignedGetObjectIfExist(
|
||||
MINIO_BUCKET,
|
||||
imageLocation(record.id),
|
||||
12 * 60 * 60,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue