mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2025-12-06 08:14:07 +00:00
27 lines
634 B
TypeScript
27 lines
634 B
TypeScript
import { createClient } from "redis";
|
|
|
|
import { sleep } from "../utils/flake.ts";
|
|
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"],
|
|
});
|
|
|
|
// Check connection
|
|
(async () => {
|
|
try {
|
|
await redisClient.connect();
|
|
while (!redisClient.isReady) await sleep(100);
|
|
logger.info("Connected to Redis store");
|
|
} catch (error) {
|
|
logger.error("Redis connection error", { error });
|
|
throw error;
|
|
}
|
|
})();
|
|
|
|
export { redisClient };
|