Git Product home page Git Product logo

chest.js's Introduction

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.

chest.js's People

Contributors

yahya-aghdam avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar

chest.js's Issues

game server

hello, how are you going to implement the game server?
is that a core? or an app?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.