Cache:update dependencies

Upload service moved to utils-services



git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@56738 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2019-07-24 08:17:05 +00:00
parent 128b4a8492
commit 962446ba06
8 changed files with 15 additions and 62 deletions

View File

@ -1,33 +1,31 @@
'use strict'
'use strict';
var express = require('express');
var app = express();
var mcache = require('memory-cache');
let express = require('express');
let app = express();
let mcache = require('memory-cache');
const request = require('superagent');
var cors = require('cors')
let cors = require('cors')
app.use(cors())
var cache = (duration) => {
let cache = (duration) => {
return (req, res, next) => {
let key = '__express__' + req.originalUrl || req.url
let cachedBody = mcache.get(key)
if (cachedBody) {
res.send(JSON.parse(cachedBody))
return
} else {
res.sendResponse = res.send
res.send = (body) => {
mcache.put(key, body, duration * 1000);
res.sendResponse(body)
}
next()
}
};
next();
}
}
};
app.get('/get',cache(20), cors(), (req, res) => {
@ -55,12 +53,12 @@ app.get('/get',cache(20), cors(), (req, res) => {
});
app.use((req, res) => {
res.status(404).send(getResponse(404,"Not Found " +url)) //not found
})
res.status(404).send(getResponse(404,"Not Found " +url)); //not found
});
app.listen((process.env.PORT)?process.env.PORT:3000, function () {
console.log(`Example app listening on port ${process.env.PORT}!`)
})
});
function getResponse(code, message){
var response ={};

View File

@ -1,45 +0,0 @@
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@4.1.2
3 info using node@v7.6.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle memcache-cache@1.0.0~prestart: memcache-cache@1.0.0
6 silly lifecycle memcache-cache@1.0.0~prestart: no script for prestart, continuing
7 info lifecycle memcache-cache@1.0.0~start: memcache-cache@1.0.0
8 verbose lifecycle memcache-cache@1.0.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle memcache-cache@1.0.0~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/argirok/projects/openaire/uoa-services-portal/trunk/services/cache/mecache/node_modules/.bin:/home/argirok/bin:/home/argirok/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
10 verbose lifecycle memcache-cache@1.0.0~start: CWD: /home/argirok/projects/openaire/uoa-services-portal/trunk/services/cache/mecache
11 silly lifecycle memcache-cache@1.0.0~start: Args: [ '-c', 'PORT=3200 node cache.js' ]
12 silly lifecycle memcache-cache@1.0.0~start: Returned: code: 1 signal: null
13 info lifecycle memcache-cache@1.0.0~start: Failed to exec start script
14 verbose stack Error: memcache-cache@1.0.0 start: `PORT=3200 node cache.js`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:192:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:192:7)
14 verbose stack at maybeClose (internal/child_process.js:890:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid memcache-cache@1.0.0
16 verbose cwd /home/argirok/projects/openaire/uoa-services-portal/trunk/services/cache/mecache
17 error Linux 4.4.0-104-generic
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
19 error node v7.6.0
20 error npm v4.1.2
21 error code ELIFECYCLE
22 error memcache-cache@1.0.0 start: `PORT=3200 node cache.js`
22 error Exit status 1
23 error Failed at the memcache-cache@1.0.0 start script 'PORT=3200 node cache.js'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the memcache-cache package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error PORT=3200 node cache.js
23 error You can get information on how to open an issue for this project with:
23 error npm bugs memcache-cache
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls memcache-cache
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

View File

@ -7,10 +7,10 @@
"start": "PORT=3200 node cache.js"
},
"dependencies": {
"cors": "^2.8.4",
"express": "^4.15.3",
"cors": "^2.8.5",
"express": "^4.17.1",
"memory-cache": "^0.2.0",
"superagent": "^3.8.0"
"superagent": "^5.0.5"
},
"engines": {
"node": "8.1.x"