Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/barcodehub/chat-node-mongodb
https://github.com/barcodehub/chat-node-mongodb
chat-application command-line messaging socket-io user-authentication
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/barcodehub/chat-node-mongodb
- Owner: Barcodehub
- Created: 2024-07-29T04:25:14.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-07-29T16:20:14.000Z (7 months ago)
- Last Synced: 2024-12-19T01:15:49.196Z (about 2 months ago)
- Topics: chat-application, command-line, messaging, socket-io, user-authentication
- Language: JavaScript
- Homepage:
- Size: 3.82 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Real-Time Chat with Node.js
## Description
This project is a real-time chat application built with Node.js and Socket.IO. It allows users to send and receive instant messages through a simple command-line interface.## Features
- Real-time communication between users
- Easy-to-use command-line interface
- User identification through unique IDs
- Direct messaging between users## Technologies Used
- Node.js
- Socket.IO
- Express.js# Install dependencies:
```
npm install
```# Usage
Start the server:
```
npm start
```
# Set up environment variables:
- Create a `.env` file in the root directory
- Add the following variables:
```
PORT=3000
MONGODB_URI=mongodb://localhost:27017/chatapp
JWT_SECRET=your_jwt_secret
```
- Adjust the values according to your setup## Environment Variables
- `PORT`: The port on which the server will run (default: 3000)
- `MONGODB_URI`: The connection string for your MongoDB database# Follow the on-screen instructions:
- Register some users at `http://localhost:3000/api/auth/login`
- Open the terminal and type `node server.js`
- Enter your user ID (username)
- Open another terminal and repeat with a different user ID.
- Enter the ID(username) of the user you want to send messages to
- Type your messages and press Enter to send
- Type "exit" to end the session## Project Structure
- `server.js`: Main server configuration
- `socket/chatHandler.js`: Socket.IO event handling
- `test-client.js`: Test client for command-line interface