Skip to content

Commit

Permalink
Merge pull request #257 from boostcampwm-2024/feature-be-#250-ban_user
Browse files Browse the repository at this point in the history
[FIX]: init data 형식 수정
  • Loading branch information
hoeeeeeh authored Dec 2, 2024
2 parents e875777 + 73c706e commit e2ab360
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 e2ab360

Please sign in to comment.