Skip to content

Commit

Permalink
Connect to redis before executing requests
Browse files Browse the repository at this point in the history
  • Loading branch information
TSRBerry committed Jun 9, 2023
1 parent 7a43c31 commit 155d08a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { redisClient } from "./app";
const router = Router();

router.get("/", async (req, res, next) => {

Check warning on line 6 in src/api.ts

View workflow job for this annotation

GitHub Actions / lint

'next' is defined but never used

Check warning on line 6 in src/api.ts

View workflow job for this annotation

GitHub Actions / lint

'next' is defined but never used
if (!redisClient.isOpen) {
await redisClient.connect();
}

const result = await redisClient.json.get("ldn");

if (result == null || typeof result != "object") {
Expand All @@ -20,6 +24,10 @@ router.get("/public_games", async (req, res, next) => {
gameFilter = req.query.titleid as string;
}

if (!redisClient.isOpen) {
await redisClient.connect();
}

const results = await redisClient.json.get("games");

if (results == null || typeof results != "object") {
Expand Down

0 comments on commit 155d08a

Please sign in to comment.