refactored server
This commit is contained in:
parent
6d470b8eba
commit
3fd2537311
36 changed files with 2944 additions and 792 deletions
21
server/storage/redis.js
Normal file
21
server/storage/redis.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
const promisify = require('util').promisify;
|
||||
|
||||
module.exports = function(config) {
|
||||
const redis_lib =
|
||||
config.env === 'development' && config.redis_host === 'localhost'
|
||||
? 'redis-mock'
|
||||
: 'redis';
|
||||
|
||||
//eslint-disable-next-line security/detect-non-literal-require
|
||||
const redis = require(redis_lib);
|
||||
const client = redis.createClient({
|
||||
host: config.redis_host,
|
||||
connect_timeout: 10000
|
||||
});
|
||||
|
||||
client.ttlAsync = promisify(client.ttl);
|
||||
client.hgetallAsync = promisify(client.hgetall);
|
||||
client.hgetAsync = promisify(client.hget);
|
||||
client.pingAsync = promisify(client.ping);
|
||||
return client;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue