1.0.6 • Published 1 year ago
direct-connect-chat v1.0.6
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:
DATABASE_HOST
: Your database hostDATABASE_PORT
: Your database portDATABASE_NAME
: Your database nameDATABASE_USER
: Your database usernameDATABASE_PASSWORD
: Your database passwordCHAT_SECRET_KEY
: Your secret keyCRON_TIME
: 0 0 * * *NOTIFICATION_CRON_TIME
: 30 11,13,15 * * *EMAIL_HOST
: Your email hostEMAIL_PORT
: Your email portEMAIL_FROM
: Your email fromEMAIL_USER
: Your email usernameEMAIL_PASS
: Your email passwordNAVIGATE_URL
: Your navigate URLPORT
: 3000
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" }