Wrap Prisma and IORedis in a try/catch with logging

This commit is contained in:
Kyle Killion
2024-08-15 23:22:24 -07:00
parent 9f26b402cf
commit a4ad9b7cb0
2 changed files with 19 additions and 2 deletions
+10 -1
View File
@@ -1,7 +1,16 @@
import Redis from 'ioredis';
import {REDIS_URL} from '../app/constants';
import signale from "signale";
export const redis = new Redis(REDIS_URL);
let redis: Redis;
try {
redis = new Redis(REDIS_URL);
const infoString = redis.info();
signale.info('Redis initialized: ', infoString);
} catch (error) {
signale.error('Failed to initialize Redis: ', error);
}
export {redis};
export const REDIS_ONE_MINUTE = 60;
export const REDIS_DEFAULT_EXPIRY = REDIS_ONE_MINUTE / 60;