LifeSports Application(ReactNative & Nest.js) - 25. message-service(1)

yellow_note·2021년 10월 26일
0

#1 message-service

message-service는 유저들끼리 채팅을 할 수 있는 서비스입니다. 예를 들어 user-a의 글을 본 user-b는 직접적으로 user-a에게 채팅을 하여 함께 운동을 하고싶다고 자신의 의사를 전달할 수 있죠.

대략적으로 위의 그림과 같이 UI를 구성해보고, 우선 message-service를 구현해보도록 하겠습니다.

message-service는 조금 복잡하기 때문에 케이스를 세워놓고 작성하도록 하겠습니다.

1) 게시글(첫 메시지): 게시글을 이용해 메시지를 보내는 경우에는 게시글 작성자 state인 writer를 MessageRoom 컴포넌트로 보내어 메시지를 작성할 수 있습니다. 해당 경우에는 initRoom 메서드를 이용하여 채팅방을 생성하도록 합니다.

2) 게시글(첫 메시지 이후): 게시글을 통해 메시지를 보내는 경우 유저 간의 채팅방이 존재하는 경우가 있습니다. 이와 같은 경우 기존 채팅방을 불러옵니다.

3) 메시지 메인 컴포넌트에서 채팅방으로 넘어가는 경우: 해당 경우에도 유저 간 채팅방이 존재하니 기존의 채팅방을 불러옵니다.

#2 프로젝트 생성

다음의 명령어로 message-service를 생성하도록 하겠습니다.

nest new message-service
cd message-service
nest generate module message
nest generate service message

컨트롤러를 작성하겠습니다.

  • ./src/app.controller.ts
import { Body, Controller, Delete, Get, HttpStatus, Param, Post } from "@nestjs/common";
import { Builder } from "builder-pattern";
import { statusConstants } from "./constants/status.constants";
import { MessageDto } from "./dto/message.dto";
import { RoomDto } from "./dto/room.dto";
import { MessageService } from "./message/message.service";
import { RequestCheckRoom } from "./vo/request.check.room";
import { RequestInitRoom } from "./vo/request.init.room";
import { RequestMessage } from "./vo/request.message";
import { ResponseRoom } from "./vo/response.room";

@Controller("message-service")
export class AppController{
    constructor(private readonly messageService: MessageService) {}

    @Post('room/init-room')
    public async initRoom(@Body() vo: RequestInitRoom): Promise<any> {
        try {
            if(!vo.user_a || !vo.user_b) {
                return await Object.assign({
                    status: HttpStatus.BAD_REQUEST,
                    payload: null,
                    message: "vo is null"
                });
            }

            const users: string[] = [];

            users.push(vo.user_a);
            users.push(vo.user_b);
            const dto: any = await this.messageService.initRoom(Builder(RoomDto).users(users)
                                                                                .build());
            
            if(dto.status === statusConstants.ERROR) {
                return await Object.assign({
                    status: HttpStatus.INTERNAL_SERVER_ERROR,
                    payload: null,
                    message: "Error message: " + dto.message
                });
            }

            if(!dto.payload) {
                return await Object.assign({
                    status: HttpStatus.NO_CONTENT,
                    payload: null,
                    message: dto.message
                });
            }

            return await Object.assign({
                status: HttpStatus.CREATED,
                payload: Builder(ResponseRoom).roomId(dto.payload.roomId)
                                              .users(dto.payload.users)
                                              .messages(dto.payload.messages)
                                              .createdAt(dto.payload.createdAt)
                                              .build(),
                message: "Successful make room",
            });
        } catch(err) {
            return await Object.assign({
                status: HttpStatus.BAD_REQUEST,
                payload: null,
                message: "Error message: " + err
            });
        }
    }

    @Post('message')
    public async create(@Body() requestMessage: RequestMessage): Promise<any> {
        try {
            const dto: any = await this.messageService.create(Builder(MessageDto).sender(requestMessage.sender)
                                                                                 .receiver(requestMessage.receiver)
                                                                                 .content(requestMessage.content)
                                                                                 .build());
            
            if(dto.status === statusConstants.ERROR) {
                return await Object.assign({
                    status: HttpStatus.INTERNAL_SERVER_ERROR,
                    payload: null,
                    message: "Error message: " + dto.message
                });
            }

            return await Object.assign({
                status: HttpStatus.CREATED,
                payload: true,
                message: "Successfully create message"
            });
        } catch(err) {
            return await Object.assign({
                status: HttpStatus.BAD_REQUEST,
                payload: null,
                message: "Error message: " + err
            });
        }
    }

    @Get(':roomId/room')
    public async getRoom(@Param('roomId') roomId: string): Promise<any> {
        try {
            const dto: any = await this.messageService.getRoom(roomId);

            if(dto.status === statusConstants.ERROR) {
                return await Object.assign({
                    status: HttpStatus.INTERNAL_SERVER_ERROR,
                    payload: null,
                    message: "Error message: " + dto.message
                });
            }

            return await Object.assign({
                status: HttpStatus.OK,
                payload: Builder(ResponseRoom).roomId(dto.payload.roomId)
                                              .users(dto.payload.users)
                                              .messages(dto.payload.messages)
                                              .createdAt(dto.payload.createdAt)
                                              .build(),
                message: "Get room data"                        
            });
        } catch(err) {
            return await Object.assign({
                status: HttpStatus.BAD_REQUEST,
                payload: null,
                message: "Error message: " + err
            });
        }
    }

    @Get(':nickname/rooms')
    public async getRooms(@Param('nickname') nickname: string): Promise<any> {
        try {
            const dtos: any = await this.messageService.getRooms(nickname);
            
            if(dtos.status === statusConstants.ERROR) {
                return await Object.assign({
                    status: HttpStatus.INTERNAL_SERVER_ERROR,
                    payload: null,
                    message: "Error message: " + dtos.message
                });
            }

            const responseRooms: Array<ResponseRoom> = [];

            for(const dto of dtos.payload) {
                responseRooms.push(Builder(ResponseRoom).roomId(dto.roomId)
                                                        .users(dto.users)
                                                        .messages(dto.messages)
                                                        .createdAt(dto.createdAt)
                                                        .build());
            }

            return await Object.assign({
                status: HttpStatus.OK,
                payload: responseRooms,
                message: "Successfully get rooms data"
            });
        } catch(err) {
            return await Object.assign({
                status: HttpStatus.BAD_REQUEST,
                payload: null,
                message: "Error message: " + err
            });
        }
    }

    @Get(':keyword/keyword/rooms')
    public async getRoomsByKeyword(@Param('keyword') keyword: string): Promise<any> {
        try {
            const dtos: any = await this.messageService.getRoomsByKeyword(keyword);

            if(dtos.status === statusConstants.ERROR) {
                return await Object.assign({
                    status: HttpStatus.INTERNAL_SERVER_ERROR,
                    payload: null,
                    message: "Error message: " + dtos.message
                });
            }

            const responseRooms: Array<ResponseRoom> = [];

            for(const dto of dtos.payload) {
                responseRooms.push(Builder(ResponseRoom).roomId(dto.roomId)
                                                        .users(dto.users)
                                                        .messages(dto.messages)
                                                        .createdAt(dto.createdAt)
                                                        .build());
            }

            return await Object.assign({
                status: HttpStatus.OK,
                payload: responseRooms,
                message: "Successfully get rooms data"
            });
        } catch(err) {
            return await Object.assign({
                status: HttpStatus.BAD_REQUEST,
                payload: null,
                message: "Error message: " + err
            });
        }
    }

    @Delete(':roomId/room')
    public async deleteRoom(@Param('roomId') roomId: string): Promise<any> {
        try {
            const result: any = await this.messageService.deleteRoom(roomId);

            if(result.status === statusConstants.ERROR) {
                return await Object.assign({
                    status: HttpStatus.INTERNAL_SERVER_ERROR,
                    payload: null,
                    message: "Error message: " + result.message
                });
            }

            return await Object.assign({
                status: HttpStatus.NO_CONTENT,
                payload: statusConstants.SUCCESS,
                message: "Delete room"
            });
        } catch(err) {
            return await Object.assign({
                status: HttpStatus.BAD_REQUEST,
                payload: null,
                message: "Error message: " + err
            });
        }
    }

    @Get('room/check') 
    public async checkRoom(@Body() vo: RequestCheckRoom): Promise<any> {
        try {
            const result: any = await this.messageService.checkRoom(
                vo.user_a,
                vo.user_b
            );
            
            if(result.status === statusConstants.ERROR) {
                return await Object.assign({
                    status: HttpStatus.INTERNAL_SERVER_ERROR,
                    payload: null,
                    message: "Error message: " + result.message
                });
            }

            return await Object.assign({
                status: HttpStatus.OK,
                payload: result.payload,
                message: result.message
            });
        } catch(err) {
            return await Object.assign({
                status: HttpStatus.BAD_REQUEST,
                payload: null,
                message: "Error message: " + err
            });
        }
    }
}

1) initRoom: 채팅방을 만드는 메서드입니다. 첫 메시지를 보낼 경우 유저 간의 채팅방이 존재하지 않기 때문에 해당 메서드로 채팅방을 만듭니다.

2) create: 메시지를 저장하는 메서드입니다. RequestMessage 형태로 온 vo 객체의 값을 MessageDto 형태로 변환시켜 MessageService 레이어로 보내줍니다. 그리고 반환받는 값은 RoomDto 형태로 반환받게 됩니다.

3) getRoom: 유저 간 메시지를 주고받는 하나의 room을 반환해주는 메서드입니다. roomId를 파라미터로 전달받고 이를 MessageService 레이어로 보내줍니다.

4) getRooms: nickname 즉, 현재 로그인한 사용자의 nickname을 전달받아 사용자와 관련된 모든 채팅방을 불러오는 메서드입니다.

5) getRoomsByKeyword: keyword를 매개로 하여 매칭되는 닉네임을 가진 모든 채팅방을 불러오는 메서드입니다.

6) deleteRoom: room을 삭제하는 메서드입니다. 파라미터로 받은 roomId를 MessageService레이어로 보내고, room을 삭제시켜줍니다.

7) checkRoom: RequestCheckRoom vo객체를 전달받아 유저들 간에 존재하는 채팅방이 있는지 체크해주는 메서드입니다.

컨트롤러를 작성했으니 다음의 라이브러리를 설치하도록 하겠습니다.

npm install --save class-validator class-transformer builder-pattern uuid

vo, dto, interface를 작성해보도록 하겠습니다.

  • ./src/vo/request.init.room.ts
import { IsString } from "class-validator";

export class RequestInitRoom {
    @IsString()
    user_a: string;

    @IsString()
    user_b: string;
}
  • ./src/vo/request.check.room.ts
import { IsString } from "class-validator";

export class RequestCheckRoom {
    @IsString()
    user_a: string;

    @IsString()
    user_b: string;
}
  • ./src/vo/request.message.ts
import { IsString } from "class-validator";

export class RequestMessage {
    @IsString()
    sender: string;

    @IsString()
    receiver: string;

    @IsString()
    content: string;
}
  • ./src/vo/response.room.ts
import { IsArray, IsDate, IsString } from "class-validator";
import { Message } from "src/interfaces/message.interface";

export class ResponseRoom {
    @IsString()
    roomId: string;

    @IsArray()
    users: string[];
    
    @IsArray()
    messages: Message[];

    @IsDate()
    createdAt: Date;
}
  • ./src/dto/message.dto.ts
import { IsDate, IsString } from "class-validator";

export class MessageDto {
    @IsString()
    roomId: string;

    @IsString()
    messageId: string;
    
    @IsString()
    sender: string;

    @IsString()
    receiver: string;

    @IsString()
    content: string;

    @IsDate()
    createdAt: Date;
}
  • ./src/dto/room.dto.ts
import { IsArray, IsDate, IsString } from "class-validator";
import { Message } from "src/interfaces/message.interface";

export class RoomDto {
    @IsString()
    roomId: string;

    @IsArray()
    users: string[];
    
    @IsArray()
    messages: Message[];

    @IsDate()
    createdAt: Date;
}
  • ./src/interfaces/message.interface.ts
export class Message {
    roomId: string;

    sender: string;

    receiver: string;

    content: string;

    createdAt: Date;
}

vo ~ interface까지 작성이 완료되면 컨트롤러에서는 service에 관한 메서드 총 4개의 에러만이 남습니다. 이어서 MessageService를 작성해보도록 하겠습니다.

#3 MessageService

mongodb 연결을 위해 다음의 라이브러리를 설치하도록 하겠습니다.

npm install --save mongoose @nestjs/mongoose
  • ./src/message/message.module.ts
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { Room, RoomSchema } from 'src/schema/room.schema';
import { MessageService } from './message.service';

@Module({
  imports: [
    MongooseModule.forFeature([{
      name: Room.name,
      schema: RoomSchema,
    }]),
  ],
  providers: [MessageService],
  exports: [MessageService]
})
export class MessageModule {}
  • ./src/app.module.ts
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { MessageModule } from './message/message.module';

@Module({
  imports: [
    MongooseModule.forRoot("mongodb://localhost:27017/MESSAGESERVICE?readPreference=primary&appname=MongoDB%20Compass&directConnection=true&ssl=false"),
    MessageModule
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
  • ./src/schema/room.schema.ts
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Message } from "src/interfaces/message.interface";

export type RoomDocument = Room & Document;

@Schema()
export class Room {
    @Prop({ required: true })
    roomId: string;
    
    @Prop({ required: true })
    users: string[];
    
    @Prop({ required: true })
    messages: Message[];
    
    @Prop({ required: true })
    createdAt: Date;
}

export const RoomSchema = SchemaFactory.createForClass(Room);

schema까지 작성을 했으니 service 클래스를 작성하도록 하겠습니다.

  • ./src/messages/message.service.ts
import { Injectable } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose';
import { Builder } from 'builder-pattern';
import { Model } from 'mongoose';
import { statusConstants } from 'src/constants/status.constants';
import { MessageDto } from 'src/dto/message.dto';
import { RoomDto } from 'src/dto/room.dto';
import { Message } from 'src/interfaces/message.interface';
import { Room, RoomDocument } from 'src/schema/room.schema';
import { v4 as uuid } from 'uuid';

@Injectable()
export class MessageService {
    constructor(@InjectModel(Room.name) private roomModel: Model<RoomDocument>) {}

    public async initRoom(dto: RoomDto): Promise<any> {
        try {
            const entity: any = await new this.roomModel(Builder(Room).roomId(uuid())
                                                                      .users([dto.users[0], dto.users[1]])
                                                                      .messages([])
                                                                      .createdAt(new Date())
                                                                      .build())
                                                                      .save();

            if(!entity) {
                return await Object.assign({
                    status: statusConstants.ERROR,
                    payload: null,
                    message: "message-service: database error"
                });
            }

            return await Object.assign({
                status: statusConstants.SUCCESS,
                payload: Builder(RoomDto).roomId(entity.roomId)
                                         .users(entity.users)
                                         .messages(entity.messages)
                                         .createdAt(entity.createdAt)
                                         .build(),
                message: "Successful transaction"
            });
        } catch(err) {
            return await Object.assign({
                status: statusConstants.ERROR,
                payload: null,
                message: "message-service: " + err
            });
        }
    }

    public async create(dto: MessageDto): Promise<any> {
        try {
            const result: any = await this.checkRoom(dto.sender, dto.receiver);
            const roomId = result.payload;

            await this.roomModel.updateOne(
                { roomId: roomId },
                { $push: {
                        messages: Builder(Message).sender(dto.sender)
                                                  .receiver(dto.receiver)
                                                  .content(dto.content)
                                                  .createdAt(new Date())
                                                  .build()
                }}
            )

            const entity = await this.roomModel.findOne({ roomId: roomId });
            
            if(!entity) {
                return await Object.assign({
                    status: statusConstants.ERROR,
                    payload: null,
                    message: "message-service: database error"
                });
            }

            return await Object.assign({
                status: statusConstants.SUCCESS,
                payload: Builder(RoomDto).roomId(entity.roomId)
                                         .users(entity.users)
                                         .messages(entity.messages)
                                         .createdAt(entity.createdAt)
                                         .build(),
                message: "Successful transaction"                        
            });
        } catch(err) {
            return await Object.assign({
                status: statusConstants.ERROR,
                payload: null,
                message: "message-service: " + err
            });
        }
    }

    public async getRoom(roomId: string): Promise<any> {
        try {
            const entity: any = await this.roomModel.findOne({ roomId: roomId });

            if(!entity) {
                return await Object.assign({
                    status: statusConstants.SUCCESS,
                    payload: null,
                    message: "Not exist room"
                });
            }

            return await Object.assign({
                status: statusConstants.SUCCESS,
                payload: Builder(Room).roomId(entity.roomId)
                                      .users(entity.users)
                                      .messages(entity.messages)
                                      .createdAt(entity.createdAt)
                                      .build(),
                message: "Successful transaction"
            });
        } catch(err) {
            return await Object.assign({
                status: statusConstants.ERROR,
                payload: null,
                message: "message-service: " + err
            });
        }
    }

    public async getRooms(nickname: string): Promise<any> {
        try {
            const entities: any = await this.roomModel.find({
                users: {
                    $in: [nickname]
                }
            });

            if(!entities) {
                return await Object.assign({
                    status: statusConstants.SUCCESS,
                    payload: null,
                    message: "Not exist rooms data"
                });
            }

            const dtos: Array<RoomDto> = [];

            for(const entity of entities) {
                dtos.push(Builder(RoomDto).roomId(entity.roomId)
                                          .users(entity.users)
                                          .messages(entity.messages)
                                          .createdAt(entity.createdAt)
                                          .build());
            }

            return await Object.assign({
                status: statusConstants.SUCCESS,
                payload: dtos,
                message: "Successful transaction"
            })
        } catch(err) {
            return await Object.assign({
                status: statusConstants.ERROR,
                payload: null,
                message: "message-service: " + err
            });
        }
    }

    public async getRoomsByKeyword(keyword: string): Promise<any> {
        try {
            const entities: any = await this.roomModel.find({
                users: {
                    $in: [keyword]
                }
            });

            if(!entities) {
                return await Object.assign({
                    status: statusConstants.SUCCESS,
                    payload: null,
                    message: "Not exist rooms data"
                });
            }

            const dtos: Array<RoomDto> = [];

            for(const entity of entities) {
                dtos.push(Builder(RoomDto).roomId(entity.roomId)
                                          .users(entity.users)
                                          .messages(entity.messages)
                                          .createdAt(entity.createdAt)
                                          .build());
            }

            return await Object.assign({
                status: statusConstants.SUCCESS,
                payload: dtos,
                message: "Successful transaction"
            })
        } catch(err) {
            return await Object.assign({
                status: statusConstants.ERROR,
                payload: null,
                message: "message-service: " + err
            });
        }
    }

    public async deleteRoom(roomId: string) {
        try {
            const result: any = await this.roomModel.deleteOne({ roomId: roomId });
        
            if(!result) {
                return await Object.assign({
                    status: statusConstants.SUCCESS,
                    payload: null,
                    message: "Not exist room"
                });
            }

            return await Object.assign({
                status: statusConstants.SUCCESS,
                payload: true,
                message: "Successful delete room"
            });
        } catch(err) {
            return await Object.assign({
                status: statusConstants.ERROR,
                payload: null,
                message: "message-service: " + err
            });
        }
    }

    public async checkRoom(
        user_a: string,
        user_b: string
    ): Promise<any> {
        try {
            const check: any = await this.roomModel.findOne({
                users: {
                    $all: [user_a, user_b]
                }
            });

            if(!check) {
                return await Object.assign({
                    status: statusConstants.SUCCESS,
                    payload: null,
                    message: "Not exist room"
                });
            }

            return await Object.assign({
                status: statusConstants.SUCCESS,
                payload: check.roomId,
                message: "Exist room"
            });
        } catch(err) {
            return await Object.assign({
                status: statusConstants.ERROR,
                payload: null,
                message: "message-service: " + err
            });
        }
    }
}

순서대로 메서드를 살펴보겠습니다.

1) initRoom: 유저들 간의 채팅방을 만드는 메서드입니다. dto객체로 전달받은 user들을 users라는 속성 값에 넣어 어떤 유저들 간 채팅을 하고 있는 것인지 알 수 있습니다.

2) create: 하나의 채팅을 채팅방에 넣어주는 메서드입니다. 컨트롤러에서 전달받은 dto 객체를 기반으로 우선 checkRoom 메서드를 호출하여 roomId를 가져옵니다. 그리고 이 roomId 값을 기반으로 채팅방을 찾아 $push 옵션을 사용하여 업데이트해줍니다.

3) getRoom: 채팅방 카드를 선택하면 요청되는 메서드입니다. roomId값을 바탕으로 room 객체를 가져와 사용자에게 반환합니다.

4) getRooms: 채팅창 메인 화면을 위해서 로그인한 사용자인 nickname값을 $in 옵션을 이용하여 사용자와 관련된 모든 채팅방들에 대한 데이터를 가져오는 메서드입니다.

5) getRoomsByKeyword: keyword를 통해 users에 존재하는 값들과 매칭시켜 해당하는 채팅방들에 대한 데이터를 가져옵니다.

6) deleteRoom: dto 객체를 통해 받은 roomId값을 이용하여 채팅방을 삭제합니다.

7) checkRoom: user_a, user_b를 전달받아 users 배열에 존재하는 값들과 전부 매칭시켜 user_a, user_b가 존재해야만 roomId를 반환하고, 그렇지 않다면 null값을 반환합니다.

MessageService 클래스까지 완료가 되었으니 테스트를 진행해보도록 하겠습니다.

#4 테스트

  • main.ts에서 port번호를 7500번으로 설정한 후 실행하도록 하겠습니다.

1) 메시지 전송(첫 메시지)

다음의 순서를 따라가도록 하겠습니다.

i) checkRoom을 통해 유저 간의 채팅방이 있는지 확인

ii) null값이 반환되면 initRoom메서드를 통해 채팅방 생성

iii) initRoom의 반환값을 바탕으로 메시지 전송

2) 메시지 전송(방이 생성된 이후 메시지)

i) checkRoom을 통해 유저 간의 채팅방이 있는지 확인

ii) roomId값이 반환되면 getRoom 메서드를 통해 채팅방 호출

iii) 메시지 전송

3) 채팅방 데이터 가져오기

i) getRooms를 통해 채팅방들 가져오기

  • json 전문
{
    "status": 200,
    "payload": [
        {
            "roomId": "5144d5d8-a1e5-493d-9f54-b9e5234e9177",
            "users": [
                "asd",
                "biuea"
            ],
            "messages": [
                {
                    "sender": "asd",
                    "receiver": "biuea",
                    "content": "sad",
                    "createdAt": "2021-10-28T02:16:23.247Z"
                },
                {
                    "sender": "biuea",
                    "receiver": "asd",
                    "content": "test-001 message that is send by biuea to asd",
                    "createdAt": "2021-10-28T02:20:43.951Z"
                }
            ],
            "createdAt": "2021-10-28T02:15:31.704Z"
        },
        {
            "roomId": "b01c9085-5a09-4d9f-aafb-8960ba730a31",
            "users": [
                "biuea",
                "test"
            ],
            "messages": [
                {
                    "sender": "biuea",
                    "receiver": "test",
                    "content": "test-001 message that is send by biuea to test",
                    "createdAt": "2021-10-28T02:24:45.395Z"
                }
            ],
            "createdAt": "2021-10-28T02:24:12.067Z"
        }
    ],
    "message": "Successfully get rooms data"
}

ii) 채팅방들 중 원하는 roomId 값을 이용하여 getRoom 호출

4) 채팅방 삭제

i) getRooms를 통해 채팅방들 가져오기

  • json 전문
{
    "status": 200,
    "payload": [
        {
            "roomId": "5144d5d8-a1e5-493d-9f54-b9e5234e9177",
            "users": [
                "asd",
                "biuea"
            ],
            "messages": [
                {
                    "sender": "asd",
                    "receiver": "biuea",
                    "content": "sad",
                    "createdAt": "2021-10-28T02:16:23.247Z"
                },
                {
                    "sender": "biuea",
                    "receiver": "asd",
                    "content": "test-001 message that is send by biuea to asd",
                    "createdAt": "2021-10-28T02:20:43.951Z"
                }
            ],
            "createdAt": "2021-10-28T02:15:31.704Z"
        },
        {
            "roomId": "b01c9085-5a09-4d9f-aafb-8960ba730a31",
            "users": [
                "biuea",
                "test"
            ],
            "messages": [
                {
                    "sender": "biuea",
                    "receiver": "test",
                    "content": "test-001 message that is send by biuea to test",
                    "createdAt": "2021-10-28T02:24:45.395Z"
                }
            ],
            "createdAt": "2021-10-28T02:24:12.067Z"
        }
    ],
    "message": "Successfully get rooms data"
}

ii) 채팅방들 중 원하는 roomId 값을 이용하여 deleteRoom 호출

1) ~ 4)까지의 REST 요청이 전부 정상적으로 처리됨을 볼 수 있습니다. 다음 포스트에서는 message-service를 위한 UI를 만들어보도록 하겠습니다.

0개의 댓글

관련 채용 정보