Skip to content

Latest commit

 

History

History
397 lines (273 loc) · 12.1 KB

README.md

File metadata and controls

397 lines (273 loc) · 12.1 KB

Chest.js

GitHub Workflow Status (with event) License Version TypeScript

Chestjs is a platform made with nestjs and mongodb for online chat. You can use it with REST API and WebSocket.

Possibilities

Possibilities of this repo with REST API:

  1. Create/Update/Get/Delete User
  2. Create/Update/Get/Delete Channel
  3. Create/Update/Get/Delete Group
  4. Create/Update/Get/Delete Private chat
  5. Create/Update/Get/Delete Chats

Possibilities of this repo with WebSocket:

  1. Send and recive message in realtime

You can see examples of usage with postman example in here: https://postman.com/scorpio-team/workspace/chest-js

First clone repo: git clone https://github.com/scorpio-demon/Chest.js.git

Go to the installed folder: cd Chest.js

Install all deps: npm i

Run app: npm run start


REST API

Main URL: http://localhost:3000/api

You can use in this method to handle data between client and database. You must send data with JSON method to the api.

User

Create a User

Path: /user Method: POST

Field Type Minimum Length Maximum Length Required
custom_id String 3 characters 30 characters No
username String 3 characters 30 characters Yes
name String 3 characters 30 characters Yes

Update a User

Path: /user Method: PUT

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes
username String 3 characters 30 characters No
name String 3 characters 30 characters No
chats_id_list Array - - No

Get a User

Path: /user/[custom_id] Method: GET

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes

Delete a User

Path: /user/[custom_id] Method: DELETE

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes


Channel

Create a Channel

Path: /channel Method: POST

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters No
name String 3 characters 30 characters Yes
admins Array 1 item 100 items Yes
members Array 1 item 10,000 items Yes

Update a Channel

Path: /channel Method: PUT

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes
name String 3 characters 30 characters No
admins Array 1 item 100 items No
members Array 1 item 1,000 items No

Get a Channel

Path: /channel/[custom_id] Method: GET

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes

Delete a Channel

Path: /channel/[custom_id] Method: DELETE

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes


Group

Create a group

Path: /group Method: POST

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters No
name String 3 characters 30 characters Yes
admins Array 1 item 100 items Yes
members Array 1 item 10,000 items Yes


Update a group

Path: /group Method: PUT

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes
name String 3 characters 30 characters No
admins Array 1 item 100 items No
members Array 1 item 10,000 items No

Get a group

Path: /group/[custom_id] Method: GET

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes

Delete a group

Path: /group/[custom_id] Method: DELETE

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes


Private chat

Create a private chat

Path: /private_chat Method: POST

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters No
persons Array 2 items 2 items Yes

Get a private chat

Path: /private_chat/[custom_id] Method: GET

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes

Delete a private chat

Path: /private_chat/[custom_id] Method: DELETE

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes


Chat

Create a chat

Path: /chat Method: POST

Field Type Minimum Length Maximum Length Required
sender_custom_id String 3 characters 30 characters Yes
reciver_custom_id String 3 characters 30 characters Yes
chat_room_id String 3 characters 30 characters Yes
mentioned_person_custom_id String 11 characters 30 characters No
message String 1 character 300 characters Yes

Update a chat

Path: /chat Method: PUT

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes
message String 1 character 300 characters No
is_read Boolean - - No
is_notified Boolean - - No
is_mentioned Boolean - - No
mentioned_person_custom_id String 11 characters 30 characters No
time_stamp String 8 characters 14 characters No

Get a chat

Path: /chat/[custom_id] Method: GET

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes

Delete a chat

Path: /chat/[custom_id] Method: DELETE

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes

WebSocket

Socket URL: http://localhost:3000

Sending and reciving message is aviliable with socket. You have to send data in JSON like REST API in here too. Just connect to the server and use listeners in way you want :)

Sending message

Listener: sendMessage

Field Type Minimum Length Maximum Length Required
sender_custom_id String 3 characters 30 characters Yes
reciver_custom_id String 3 characters 30 characters Yes
chat_room_id String 3 characters 30 characters Yes
mentioned_person_custom_id String 11 characters 30 characters No
message String 1 character 300 characters Yes

Reciving message

Listener: reciveAllMessages

Eplanation: Get all messages in first connection

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes

Listener: stopGettingMessageNotification

Eplanation: Stop getting new message notification

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes

Listener: getMessageNotification

Eplanation: Start to get new message notification

Field Type Minimum Length Maximum Length Required
custom_id String 12 characters 30 characters Yes



License

This project is licensed under the MIT License - see the LICENSE file for details.

The MIT License is a permissive open-source license that allows you to freely use, modify, distribute, and sublicense this software for both commercial and non-commercial purposes. You can find the full text of the MIT License in the LICENSE file included with this project.

Feel free to fork this project and use it in your own work, but please make sure to give proper attribution and include the original license text.