- Added Sentry integration for error tracking across various components, including error boundaries and user actions. - Updated global error handling to capture exceptions and provide detailed feedback to users. - Enhanced user notifications with toast messages for actions such as credit management, image generation, and canvas exports. - Improved user experience by displaying relevant messages during interactions, ensuring better visibility of system states and errors.
30 lines
773 B
TypeScript
30 lines
773 B
TypeScript
import Redis from "ioredis";
|
|
|
|
function createRedis(): Redis {
|
|
const url = process.env.REDIS_URL?.trim();
|
|
if (url) {
|
|
return new Redis(url, {
|
|
retryStrategy: (times) => Math.min(times * 100, 3000),
|
|
});
|
|
}
|
|
|
|
return new Redis({
|
|
host: process.env.REDIS_HOST ?? "127.0.0.1",
|
|
port: Number.parseInt(process.env.REDIS_PORT ?? "6379", 10),
|
|
password: process.env.REDIS_PASSWORD || undefined,
|
|
retryStrategy: (times) => Math.min(times * 100, 3000),
|
|
});
|
|
}
|
|
|
|
const globalForRedis = globalThis as unknown as { redis?: Redis };
|
|
|
|
export const redis = globalForRedis.redis ?? createRedis();
|
|
|
|
redis.on("error", (err) => {
|
|
console.error("[Redis] Connection error:", err);
|
|
});
|
|
|
|
if (process.env.NODE_ENV !== "production") {
|
|
globalForRedis.redis = redis;
|
|
}
|