[Cache | Trunk]: Resolved some warnings

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@58226 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2020-03-11 12:53:14 +00:00
parent b2b15b5d6c
commit 1fff0bd89e
1 changed files with 4 additions and 4 deletions

View File

@ -30,13 +30,13 @@ let cache = (duration) => {
return (req, res, next) => { return (req, res, next) => {
let key = '__express__' + req.originalUrl || req.url let key = '__express__' + req.originalUrl || req.url
console.log(req.originalUrl || req.url); console.log(req.originalUrl || req.url);
let cachedBody = mcache.get(key) let cachedBody = mcache.get(key);
if (cachedBody) { if (cachedBody) {
res.send(JSON.parse(cachedBody)) res.send(JSON.parse(cachedBody))
} else { } else {
res.sendResponse = res.send res.sendResponse = res.send;
res.send = (body) => { res.send = (body) => {
if (res.statusCode == 200) { if (res.statusCode === 200) {
mcache.put(key, body, duration * 1000); mcache.put(key, body, duration * 1000);
} }
res.sendResponse(body) res.sendResponse(body)
@ -45,7 +45,7 @@ let cache = (duration) => {
next(); next();
} }
}; };
} };
app.get('/metrics', (req, res) => { app.get('/metrics', (req, res) => {