2
0
Files
bot/packages/lib/redis.ts
Baptiste Arnaud 043f0054b0 ⬆️ Upgrade AI SDK (#1641)
2024-07-15 14:32:42 +02:00

17 lines
412 B
TypeScript

import { env } from '@typebot.io/env'
import { Redis } from 'ioredis'
declare const global: { redis: Redis | undefined }
let redis: Redis | undefined
if (env.NODE_ENV === 'production' && !process.versions.bun && env.REDIS_URL) {
redis = new Redis(env.REDIS_URL)
} else if (env.REDIS_URL) {
if (!global.redis) {
global.redis = new Redis(env.REDIS_URL)
}
redis = global.redis
}
export default redis