A simple real-time chat application built with nodejs with socket.io.
- Real-time Messaging: Users can send and receive messages in real-time.
- User Authentication: Users can create accounts and log in securely.
- Multiple Chat Rooms: Users can join different chat rooms and engage in discussions.
- Message History: Chat rooms retain message history for users who join later.
Before you begin, ensure you have met the following requirements:
- Node.js installed
- npm (Node Package Manager) installed
- MongoDB installed and running
-
Clone the repository:
git clone https://github.com/your-username/chat-api.git
-
Navigate to the project directory:
cd chat-api
-
Install dependencies:
npm install
-
Set up your MongoDB database:
- Create a MongoDB database and note the connection URI.
- Update the
config/default.json
file with your MongoDB connection URI.
-
Start the server:
npm start
The API will be running at http://localhost:3000.
- Endpoint:
GET /messages
- Description: Get a list of all messages.
-
Endpoint:
POST /messages
-
Description: Send a new message.
-
Request Body:
{ "user": "John Doe", "message": "Hello, world!" }
- Endpoint:
GET /messages/:room
- Description: Get messages in a specific room.
-
Endpoint:
POST /rooms
-
Description: Create a new chat room.
-
Request Body:
{ "name": "General" }
Update the configuration in config/default.json
as needed.
MONGO_URI
: MongoDB connection URI.
If you'd like to contribute, please fork the repository and make changes as you see fit. Pull requests are warmly welcome.
This project is licensed under the MIT License - see the LICENSE file for details.