mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 22:27:16 +01:00
Refactored permissions check. Updated redis lib.
This commit is contained in:
parent
1a7369e1f6
commit
a4e80ca3e5
5 changed files with 58 additions and 15 deletions
10
lib/redis.js
10
lib/redis.js
|
|
@ -3,16 +3,18 @@ import debug from 'debug';
|
|||
|
||||
const log = debug('umami:redis');
|
||||
const REDIS = Symbol();
|
||||
const DELETED = 'DELETED';
|
||||
|
||||
let redis;
|
||||
const enabled = Boolean(process.env.REDIS_URL);
|
||||
const url = process.env.REDIS_URL;
|
||||
const enabled = Boolean(url);
|
||||
|
||||
async function getClient() {
|
||||
if (!process.env.REDIS_URL) {
|
||||
if (!enabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const client = createClient({ url: process.env.REDIS_URL });
|
||||
const client = createClient({ url });
|
||||
client.on('error', err => log(err));
|
||||
await client.connect();
|
||||
|
||||
|
|
@ -59,4 +61,4 @@ async function connect() {
|
|||
return redis;
|
||||
}
|
||||
|
||||
export default { enabled, client: redis, log, connect, get, set, del };
|
||||
export default { enabled, client: redis, log, connect, get, set, del, DELETED };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue