This project is a chat server built with Node.js, Express, MongoDB, and Socket.IO. Each tab serves as a chat room where users can provide a username and start chatting with other connected users.
- Node.js (v20.13.1 or later)
- npm (v10.5.2 or later)
- MongoDB (running locally or accessible via URI)
-
Clone the repository:
git clone https://github.com/fercastroud/super-duper-octo-rotary-challenge.git cd super-duper-octo-rotary-challenge -
Install the dependencies (server and client folders):
cd super-duper-octo-rotary-challenge/server npm installcd super-duper-octo-rotary-challenge/client npm install -
Create a
.envfile in the root of theserverdirectory with the following content:PORT=3000 MONGO_URI=mongodb://localhost:27017/chatApp
-
Create a
.envfile in the root of theclientdirectory with the following content:VITE_API_URL=http://localhost:3000
-
Start the server:
npm start
-
You should see output indicating that the server is running and connected to the database:
Server running on port 3000 MongoDB connected successfully
-
The server is now running on
http://localhost:3000.
-
Start the client:
npm run dev
-
The server is now running on
http://localhost:5173/.
- Method: POST
- URL:
/api/users - Headers:
Content-Type: application/json
- Body:
{
"name": "Ferca"
}- Method: POST
- URL:
/api/chat/messages - Headers:
Content-Type: application/json
- Body:
{
"userId": "6654d8471ab6b918d36492c7",
"message": "Hello, this is a test message!"
}- Method: GET
- URL:
/api/chat/messages - Headers:
Content-Type: application/json
- Response:
[
{
"id": "string",
"userId": "string",
"message": "string",
"timestamp": "string"
}
]