Skip to content

Commit

Permalink
fix: init data 형식 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hoeeeeeh committed Dec 2, 2024
1 parent 299da5e commit 73c706e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions backend/chatServer/src/room/room.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,24 @@ export class RoomRepository {

private async lindex<T>(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<T>(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<T>(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) {
Expand Down

0 comments on commit 73c706e

Please sign in to comment.