async function replaceWithSignedUrls(obj, storage, bucketName) {
for (const key in obj) {
if (typeof obj[key] === 'object') {
await replaceWithSignedUrls(obj[key], storage, bucketName);
} else if (key.includes('img') || key.includes('image')) {
const [url] = await storage
.bucket(bucketName)
.file(obj[key])
.getSignedUrl({
version: 'v4',
action: 'read',
expires: Date.now() + 15 * 60 * 1000, // 15 minutes
});
obj[key] = url;
}
}
}