diff --git a/backend/chatServer/src/room/room.repository.ts b/backend/chatServer/src/room/room.repository.ts index 3289d2d0..5549272a 100644 --- a/backend/chatServer/src/room/room.repository.ts +++ b/backend/chatServer/src/room/room.repository.ts @@ -39,19 +39,24 @@ export class RoomRepository { private async lindex(key: string, index: number){ const result = await this.redisClient.lindex(key, index); - if(result) return JSON.parse(result) as T; - return undefined; + if(!result) return undefined; + + const l = typeof result === 'string' ? result : JSON.parse(result); + return l as T; } private async lrange(key: string, start: number, end: number){ const result = await this.redisClient.lrange(key, start, end); - return result as T; + if(!result) return undefined; + const arrayT = result.map((r) => typeof r === 'string' ? r : JSON.parse(r)); + return arrayT as T; } private async getData(key: string) { const result = await this.redisClient.get(key); - if(result) return typeof result === 'string' ? result as T : JSON.parse(result) as T; - return undefined; + if(!result) return undefined; + const data = result === 'string' ? result : JSON.parse(result); + return data as T; } async isRoomExisted(roomId: string) {