Skip to content

Commit

Permalink
feat: add ready as health redis status
Browse files Browse the repository at this point in the history
  • Loading branch information
ImOverlord committed Dec 15, 2023
1 parent 7f913a8 commit 27bc266
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions server/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
5 changes: 2 additions & 3 deletions server/routes/health.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down

0 comments on commit 27bc266

Please sign in to comment.