Skip to content

Commit

Permalink
🚨 - Hotfix Redis not connecting (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
planecore authored Dec 18, 2023
1 parent bee6ae7 commit 37cd9ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/data/redis.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createClient } from "redis"
import { RedisClientType } from "@redis/client"
import { compact, mapValues, omit } from "lodash"
import { compact, isEmpty, mapValues, omit } from "lodash"

import { redisUrl } from "./config"
import { Ride } from "../types/ride"
Expand All @@ -9,13 +9,16 @@ import { logNames, logger } from "../logs"
let client: RedisClientType

export const connectToRedis = async () => {
try {
client = createClient({ url: redisUrl })
await client.connect()
logger.info(logNames.redis.connect.success)
} catch (error) {
logger.error(logNames.redis.connect.failed, { error })
}
client = createClient({ url: redisUrl })

client.on("error", (error) => {
if (!isEmpty(error)) {
logger.error(logNames.redis.connect.failed, { error })
}
})

await client.connect()
logger.info(logNames.redis.connect.success)
}

export const addRide = async (ride: Ride): Promise<boolean> => {
Expand Down
1 change: 1 addition & 0 deletions src/logs/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const startLogger = () => {
db: mongoUrl,
dbName: "logs" + (railwayEnviroment === "production" ? "" : `-${railwayEnviroment}`),
format: serializeErrors(),
options: { poolSize: 2, useNewUrlParser: true, useUnifiedTopology: true },
}),
],
})
Expand Down

0 comments on commit 37cd9ad

Please sign in to comment.