make redis client conditional

This commit is contained in:
Maidul Islam
2023-09-15 17:55:43 -04:00
parent 5494bc6c3c
commit 859cec49d1
2 changed files with 12 additions and 3 deletions
+10 -1
View File
@@ -1,3 +1,12 @@
import { Redis } from "ioredis"
export const redisClient = new Redis(process.env.REDIS_URL as string);
let redisClient: Redis | null;
if (process.env.REDIS_URL) {
redisClient = new Redis(process.env.REDIS_URL as string);
} else {
console.warn("Redis URL not set, skipping Redis initialization.");
redisClient = null
}
export { redisClient }