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 host]DATABASE_PORT
: [Your database port]DATABASE_NAME
: [Your database name]DATABASE_USER
: [Your database username]DATABASE_PASSWORD
: [Your database password]CHAT_SECRET_KEY
: [Your secret key]CRON_TIME
: 0 0 * * *NOTIFICATION_CRON_TIME
: 30 11,13,15 * * *EMAIL_HOST
: [Your email host]EMAIL_PORT
: [Your email port]EMAIL_FROM
: [Your email from]EMAIL_USER
: [Your email username]EMAIL_PASS
: [Your email password]NAVIGATE_URL
: [Your navigate URL]PORT
: 3000
API DOCS
Direct connect chat APIs
POST Send chat
POST Accept chat invitation
GET Get chats
- URL:
${url}/api/get-chats?sender_id=321&receiver_id=123&is_accepted=false
POST Block user
POST Generate Token
- URL:
${url}/api/generate-token
- Body raw (json):
{
"user_id": "10"
}