fix: address code review issues — nutriscore field name, cache write isolation, missing rate limiter, dead props

This commit is contained in:
Antoni Nuñez Romeu
2026-07-13 15:46:47 +02:00
parent 83920ae57c
commit 981f3bd3db
4 changed files with 15 additions and 14 deletions
+12 -4
View File
@@ -69,8 +69,12 @@ export async function searchBabyProducts(query) {
.map(transformOFFProduct)
.filter(Boolean);
await redisClient.setEx(cacheKey, CACHE_TTL, JSON.stringify(products));
console.log(`Cached ${products.length} OFF products for: ${searchTerm}`);
try {
await redisClient.setEx(cacheKey, CACHE_TTL, JSON.stringify(products));
console.log(`Cached ${products.length} OFF products for: ${searchTerm}`);
} catch (cacheErr) {
// cache write failed, still return the data
}
return products;
}
@@ -104,8 +108,12 @@ export async function getBabyProductDetails(barcode) {
const product = transformOFFProduct(response.data.product);
if (product) {
await redisClient.setEx(cacheKey, CACHE_TTL, JSON.stringify(product));
console.log(`Cached OFF product: ${barcode}`);
try {
await redisClient.setEx(cacheKey, CACHE_TTL, JSON.stringify(product));
console.log(`Cached OFF product: ${barcode}`);
} catch (cacheErr) {
// cache write failed, still return the data
}
return product;
}
}