sending the profile image in presigned url

This commit is contained in:
2025-11-28 17:47:43 +05:30
parent 6147b0f476
commit 6cac8fb163
3 changed files with 23 additions and 8 deletions

View File

@@ -125,6 +125,13 @@ export class HostService {
}
}
}
if (host.user) {
const key = host.user.profileImage.startsWith("http")
? host.user.profileImage.split(".com/")[1]
: host.user.profileImage;
host.user.profileImage = await getPresignedUrl(bucket, key);
}
if (host.logoPath) {
const key = host.logoPath.startsWith('http')

View File

@@ -15,22 +15,22 @@ export const handler = safeHandler(async (
): Promise<APIGatewayProxyResult> => {
// Get host ID from path parameters
const token = event.headers['x-auth-token'] || event.headers['X-Auth-Token']
if(!token) {
if (!token) {
throw new ApiError(400, 'This is a protected route. Please provide a valid token.');
}
await verifyMinglarAdminToken(token);
const host_xid = event.pathParameters?.host_xid;
if (!host_xid) {
throw new ApiError(
400,
'Host ID is required in path parameters.',
);
}
if (!host_xid) {
throw new ApiError(
400,
'Host ID is required in path parameters.',
);
}
const hostDetails = await minglarService.getHostDetailsById(host_xid);
const hostDetails = await minglarService.getHostDetailsById(Number(host_xid));
if (!hostDetails) {
throw new ApiError(404, 'Host not found');

View File

@@ -1389,6 +1389,14 @@ export class MinglarService {
host.logoPath = await getPresignedUrl(bucket, key);
}
if (host.user) {
const key = host.user.profileImage.startsWith("http")
? host.user.profileImage.split(".com/")[1]
: host.user.profileImage;
host.user.profileImage = await getPresignedUrl(bucket, key);
}
if (host.hostParent?.length) {
const parent = host.hostParent[0]; // since you allow only 1 parent