26 lines
684 B
TypeScript
26 lines
684 B
TypeScript
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<void> {
|
|
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.`,
|
|
);
|
|
}
|
|
}
|