Chestjs is a platform made with nestjs and mongodb for online chat. You can use it with REST API and WebSocket.
Possibilities of this repo with REST API:
- Create/Update/Get/Delete User
- Create/Update/Get/Delete Channel
- Create/Update/Get/Delete Group
- Create/Update/Get/Delete Private chat
- Create/Update/Get/Delete Chats
Possibilities of this repo with WebSocket:
- 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
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.
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 |
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 |
Path: /user/[custom_id]
Method: GET
Field | Type | Minimum Length | Maximum Length | Required |
---|---|---|---|---|
custom_id | String | 12 characters | 30 characters | Yes |
Path: /user/[custom_id]
Method: DELETE
Field | Type | Minimum Length | Maximum Length | Required |
---|---|---|---|---|
custom_id | String | 12 characters | 30 characters | Yes |
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 |
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 |
Path: /channel/[custom_id]
Method: GET
Field | Type | Minimum Length | Maximum Length | Required |
---|---|---|---|---|
custom_id | String | 12 characters | 30 characters | Yes |
Path: /channel/[custom_id]
Method: DELETE
Field | Type | Minimum Length | Maximum Length | Required |
---|---|---|---|---|
custom_id | String | 12 characters | 30 characters | Yes |
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 |
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 |
Path: /group/[custom_id]
Method: GET
Field | Type | Minimum Length | Maximum Length | Required |
---|---|---|---|---|
custom_id | String | 12 characters | 30 characters | Yes |
Path: /group/[custom_id]
Method: DELETE
Field | Type | Minimum Length | Maximum Length | Required |
---|---|---|---|---|
custom_id | String | 12 characters | 30 characters | Yes |
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 |
Path: /private_chat/[custom_id]
Method: GET
Field | Type | Minimum Length | Maximum Length | Required |
---|---|---|---|---|
custom_id | String | 12 characters | 30 characters | Yes |
Path: /private_chat/[custom_id]
Method: DELETE
Field | Type | Minimum Length | Maximum Length | Required |
---|---|---|---|---|
custom_id | String | 12 characters | 30 characters | Yes |
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 |
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 |
Path: /chat/[custom_id]
Method: GET
Field | Type | Minimum Length | Maximum Length | Required |
---|---|---|---|---|
custom_id | String | 12 characters | 30 characters | Yes |
Path: /chat/[custom_id]
Method: DELETE
Field | Type | Minimum Length | Maximum Length | Required |
---|---|---|---|---|
custom_id | String | 12 characters | 30 characters | Yes |
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 :)
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 |
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 |
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.