Tweak to constructor logic
parent
ba477cdbdb
commit
9863078fd9
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue