diff --git a/server/redis.ts b/server/redis.ts index 7df6f7cb..fca0d460 100644 --- a/server/redis.ts +++ b/server/redis.ts @@ -10,6 +10,7 @@ const client = new Redis({ }); export default client; +export const redisHealthStatus = [ "connect", "ready" ]; export const key = { link: (address: string, domain_id?: number, user_id?: number) => diff --git a/server/routes/health.ts b/server/routes/health.ts index 7c640363..6a3070e0 100644 --- a/server/routes/health.ts +++ b/server/routes/health.ts @@ -1,11 +1,10 @@ import { Router } from "express"; -import client from "../redis"; +import client, { redisHealthStatus } from "../redis"; const router = Router(); - router.get("/", (_, res) => { const redisStatus = client.status; - const status = redisStatus !== "connect" ? 500 : 200; + const status = redisHealthStatus.includes(redisStatus) ? 200 : 500; res .status(status) .json({