mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2025-12-06 12:54:07 +00:00
25 lines
566 B
TypeScript
25 lines
566 B
TypeScript
import { createClient } from "redis";
|
|
|
|
import logger from "../utils/logger.ts";
|
|
|
|
if (!process.env["REDIS_URI"])
|
|
throw new TypeError("Redis connection URI not defined");
|
|
|
|
// Initialize
|
|
const redisClient: ReturnType<typeof createClient> = createClient({
|
|
url: process.env["REDIS_URI"],
|
|
socket: {
|
|
keepAlive: 25 * 1000, // 25s
|
|
connectTimeout: 15 * 1000,
|
|
},
|
|
});
|
|
redisClient.on("error", (error) => {
|
|
logger.error("redisClient", { error });
|
|
throw error;
|
|
});
|
|
|
|
await redisClient.connect();
|
|
logger.info("Connected to Redis store");
|
|
|
|
export { redisClient };
|