1.0.6 • Published 1 year ago

direct-connect-chat v1.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

direct-connect-chat

Direct Connect Chat Package is a Node.js library that allows users to engage in one-on-one chats. It includes functionality to send chat requests, accept requests, and chat once connected. Additionally, the application uses Nodemailer to notify the receiver of a chat request. A cron job is implemented to delete messages older than 7 days. The application also features message encryption and decryption, as well as a block feature, and filter out messages with inappropriate language.

Installation

You can install the package using npm:

npm i direct-connect-chat

Usage

Environment Variables Configuration

To run this library, create a .env file in your project and configure the following environment variables:

API DOCS

Direct connect chat APIs

POST Send chat

  • URL: ${url}/api/send-chat
  • Request Headers: Content-Type: application/json
  • Body raw (json):
    {
        "sender_id": "321",
        "receiver_id": "123",
        "message": "Hello"
    }

POST Accept chat invitation

  • URL: ${url}/api/accept-invitation
  • Request Headers: Content-Type: application/json
  • Body raw (json):
    {
        "sender_id": "321",
        "receiver_id": "123"
    }

GET Get chats

  • URL: ${url}/api/get-chats?sender_id=321&receiver_id=123&is_accepted=false

POST Block user

  • URL: ${url}/api/block-user
  • Body raw (json):
    {
        "sender_id": "2",
        "receiver_id": "123"
    }

POST Generate Token

  • URL: ${url}/api/generate-token
  • Body raw (json):
    {
        "user_id": "10"
    }