Skip to content

Commit 192fcf1

Browse files
Merge pull request #12 from InternetMaximalism/tls-support
push redis
2 parents 4faf850 + a076d2e commit 192fcf1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/shared/src/lib/redis.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export class RedisClient {
1111
return;
1212
}
1313

14-
this.client = new Redis(config.REDIS_URL, {
14+
const redisUrl = this.getRedisURL();
15+
16+
this.client = new Redis(redisUrl, {
1517
reconnectOnError: (err) => {
1618
const targetError = "READONLY";
1719
if (err.message.includes(targetError)) {
@@ -30,6 +32,16 @@ export class RedisClient {
3032
});
3133
}
3234

35+
private getRedisURL(): string {
36+
const hasQueryParams = config.REDIS_URL.includes("?");
37+
38+
if (config.REDIS_URL.includes("rediss")) {
39+
return hasQueryParams ? `${config.REDIS_URL}&tls=true` : `${config.REDIS_URL}?tls=true`;
40+
}
41+
42+
return config.REDIS_URL;
43+
}
44+
3345
public static getInstance(): RedisClient {
3446
if (!RedisClient.instance) {
3547
RedisClient.instance = new RedisClient();

0 commit comments

Comments
 (0)