File size: 527 Bytes
f1445b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const { createClient } = require("redis");

const redisClient = () => {
  const pass = process.env.REDIS_PASSWORD;
  const url = process.env.REDIS_URL;
  const port = process.env.REDIS_PORT;

  if (!pass || !url || !port) return null;

  const client = createClient({
    url: `rediss://default:${pass}@${url}:${port}`,
    socket: {
      timeout: 10000,
    },
  });

  client.on("error", function (err) {
    console.log("Redis Client Error", err);
    return null;
  });

  return client;
};

module.exports = redisClient;