Skip to content

Created a simple chat between clients using the framework Nest.js with protocol gRPC

Notifications You must be signed in to change notification settings

gb21oc/nestjs-grpc-chat

Repository files navigation

Alt text

classDiagram
    ChatService <|-- ChatServiceDomain: Inheritance
    ChatController <.. ChatService: Dependency
    ChatController <|-- ChatControllerDomain: Inheritance

    class ChatController{
        +ChatService _chatService
        constructor(_chatService: ChatService)
        +createUser(data: IChat.CreateUser, _metadata: Metadata, call: ServerUnaryCall<IChat.CreateUser, IChat.ResponseCreateUser>, ):IChat.ResponseCreateUser
        +getAllUsers():IChat.ResponseGetAll
        +sendMessageToUser(data: Observable<IChat.SendToUser>)
    }
    class ChatService{
        +IChat.User[] users
        +IChat.AttempsMsg[] attempsMsg
        +createUser(payload: IChat.CreateUser, call: ServerUnaryCall<IChat.CreateUser, IChat.ResponseCreateUser>, )
        +getAllUsers():IChat.ResponseGetAll
        +joinChat(payload: Observable<IChat.SendToUser>):Observable<IChat.ReceiveMsg>
    }
Loading

Configuration

  • Port: 50051
  • Proto files:
    • /proto/chat.proto
  • Transport: gRPC
  • PRD: Build Status
  • DEV: Build Status

Micro Service information

  • Endpoints
    • CreateUser
      • Interface: IChat.CreateUser
      • Stream: No
      • Body:
      {
        "user": "gb"
      }
      • Response:
      {
        "error": "",
        "userCreated": true
      }
    • GetAllUsers
      • Interface: N/A
      • Stream: No
      • Body: No
      • Response:
      {
        "users": [
            {
                "id": 1,
                "user": "gb"
            },
            {
                "id": 2,
                "user": "gbOutroUsuario"
            }
        ]
      }
    • SendMessageToUser
      • Interface: IChat.SendToUser
      • Stream: yes
        • Bidirecional: yes
      • Body:
      {
        "from": "gb",
        "toID": 2,
        "msg": "Olá amigo!"
      }