import { Redis } from "npm:ioredis"; const VALKEY_URL = Deno.env.get("VALKEY_URL") || "redis://auth-valkey:6379"; export const valkey = new Redis(VALKEY_URL, { enableOfflineQueue: false, }); export async function pingValkey(): Promise { try { const result = await valkey.ping(); if (result !== "PONG") { throw new Error(`Unexpected ping response: ${result}`); } } catch (error) { if (error instanceof Error) { throw new Error( `Fatal: Failed to connect to Valkey session cache. Halting boot. ${error.message}`, ); } throw new Error( `Fatal: Failed to connect to Valkey session cache. Halting boot.`, ); } }