iceshrimp/packages/backend/src/db/redis.ts
ThatOneCalculator 83089e49d8 refactor: 🔧 allow redis user to be configured
Follow up #10366, 3df3c97deb284ecbf3363b90a45c6501957d1e98
2023-06-26 15:02:54 -07:00

23 lines
569 B
TypeScript

import Redis from "ioredis";
import config from "@/config/index.js";
export function createConnection() {
return new Redis({
port: config.redis.port,
host: config.redis.host,
family: config.redis.family ?? 0,
password: config.redis.pass,
username: config.redis.user ?? "default",
keyPrefix: `${config.redis.prefix}:`,
db: config.redis.db || 0,
tls: {
rejectUnauthorized: false,
host: config.redis.host,
},
});
}
export const subscriber = createConnection();
subscriber.subscribe(config.host);
export const redisClient = createConnection();