From f65ab4223143b2be6a4655b48fb6d9f012b96038 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Fri, 10 Jan 2025 01:19:06 +0100 Subject: [PATCH] make redis host and port optional --- src/MutexLock.ts | 2 +- src/types.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MutexLock.ts b/src/MutexLock.ts index af97588..835abd1 100644 --- a/src/MutexLock.ts +++ b/src/MutexLock.ts @@ -19,7 +19,7 @@ export class MutexLock { static async create(options: MutexOptions) { const redisClient = await redis .createClient({ - url: `redis://${options.redis.host}:${options.redis.port}`, + url: `redis://${options.redis?.host ?? "127.0.0.1"}:${options.redis?.port ?? 6379}`, }) .connect(); diff --git a/src/types.ts b/src/types.ts index 1bb59eb..1429fae 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,7 +1,7 @@ export type MutexOptions = { - redis: { - host: string; - port: number; + redis?: { + host?: string; + port?: number; }; mutex?: { checkInterval?: number;