Tweak to constructor logic

master
j 2024-03-23 01:11:56 -04:00
parent ba477cdbdb
commit 9863078fd9
1 changed files with 11 additions and 4 deletions

View File

@ -1,19 +1,26 @@
import Redis from 'ioredis';
import Redis, { RedisOptions } from 'ioredis';
import dotenv from 'dotenv';
dotenv.config();
interface RedisConfig extends RedisOptions {
host: string;
port: number;
password?: string;
}
class RedisSessionManager {
private static instance: RedisSessionManager;
public readonly client: Redis;
private constructor() {
this.client = new Redis({
host: process.env.REDIS_HOST,
const redisConfig: RedisConfig = {
host: process.env.REDIS_HOST!,
port: Number(process.env.REDIS_PORT),
password: process.env.REDIS_PASSWORD || undefined,
showFriendlyErrorStack: true,
});
};
this.client = new Redis(redisConfig);
}
public static getInstance(): RedisSessionManager {