From 7bf307b0c2e86284b93741e94e0e106261d2e638 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 3 Nov 2023 18:03:11 +0000 Subject: [PATCH] Further updates to typing. --- packages/backend-core/src/redis/utils.ts | 20 +++++++++++-------- .../server/src/api/routes/public/index.ts | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/backend-core/src/redis/utils.ts b/packages/backend-core/src/redis/utils.ts index e0bdcfcd20..5187fe13f8 100644 --- a/packages/backend-core/src/redis/utils.ts +++ b/packages/backend-core/src/redis/utils.ts @@ -59,7 +59,7 @@ export enum SelectableDatabase { UNUSED_14 = 15, } -export function getRedisOptions() { +export function getRedisConnectionDetails() { let password = env.REDIS_PASSWORD let url: string[] | string = env.REDIS_URL.split("//") // get rid of the protocol @@ -75,9 +75,18 @@ export function getRedisOptions() { } const [host, port] = url.split(":") + return { + host, + password, + port: parseInt(port), + } +} + +export function getRedisOptions() { + const { host, password, port } = getRedisConnectionDetails() let redisOpts: Redis.RedisOptions = { connectTimeout: CONNECT_TIMEOUT_MS, - port: parseInt(port), + port: port, host, password, } @@ -93,12 +102,7 @@ export function getRedisOptions() { dnsLookup: (address: string, callback: any) => callback(null, address), } as Redis.ClusterOptions } - return { - opts, - host, - password, - port: parseInt(port), - } + return opts } export function addDbPrefix(db: string, key: string) { diff --git a/packages/server/src/api/routes/public/index.ts b/packages/server/src/api/routes/public/index.ts index ab10b2ed74..b37ed931fc 100644 --- a/packages/server/src/api/routes/public/index.ts +++ b/packages/server/src/api/routes/public/index.ts @@ -39,7 +39,7 @@ function getApiLimitPerSecond(): number { let rateLimitStore: any = null if (!env.isTest()) { - const { password, host, port } = redis.utils.getRedisOptions() + const { password, host, port } = redis.utils.getRedisConnectionDetails() let options: KoaRateLimitOptions = { socket: { host: host,