We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 33b563b commit e39ee68Copy full SHA for e39ee68
src/config/redis.ts
@@ -1,14 +1,20 @@
1
-import redis from 'redis'
+import { isEmpty } from 'lodash'
2
+import redis, { ClientOpts } from 'redis'
3
4
require('dotenv').config()
5
6
const { REDIS_HOST, REDIS_PORT, REDIS_PASSWORD } = process.env
7
-const client = redis.createClient({
8
+const optionConfigs: ClientOpts = {
9
host: REDIS_HOST,
10
port: Number(REDIS_PORT),
- password: REDIS_PASSWORD,
11
-})
+}
12
+
13
+if (!isEmpty(REDIS_PASSWORD)) {
14
+ optionConfigs.password = REDIS_PASSWORD
15
16
17
+const client = redis.createClient(optionConfigs)
18
19
client.on('connect', function () {
20
console.log('Redis client connected')
0 commit comments