cache-manager-express-mw
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "cache-manager-express-mw", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Middleware for Express that uses cache-manager to add a caching layer in front of your application.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -9,2 +9,6 @@ var _ = require("lodash"), | ||
var isProduction = function() { | ||
return process.env.NODE_ENV === "production"; | ||
}; | ||
var getMaxAge = function(res) { | ||
@@ -27,6 +31,7 @@ var cacheControlHeader = res.get("Cache-Control"); | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(result); | ||
if (!isProduction()) { | ||
console.warn("Error retrieving value from cache: " + err); | ||
} | ||
} | ||
resolve(result); | ||
}); | ||
@@ -43,6 +48,7 @@ }); | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(result); | ||
if (!isProduction()) { | ||
console.warn("Error retrieving ttl from cache: " + err); | ||
} | ||
} | ||
resolve(result); | ||
}); | ||
@@ -79,3 +85,7 @@ }); | ||
if (/^2/.test(res.statusCode)) { | ||
cache.set(key, { statusCode: res.statusCode, body: body }, { ttl: getMaxAge(res) }); | ||
cache.set(key, { statusCode: res.statusCode, body: body }, { ttl: getMaxAge(res) }, function(err) { | ||
if (!isProduction()) { | ||
console.warn("Error setting value in cache: " + err); | ||
} | ||
}); | ||
} | ||
@@ -105,2 +115,8 @@ | ||
} | ||
}) | ||
.catch(error => { | ||
if (!isProduction()) { | ||
console.warn("Error accessing cache: " + err); | ||
} | ||
next(); | ||
}); | ||
@@ -107,0 +123,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10751
151
1