This is a simple chat application built using Express.js and Socket.IO.
-
Make sure you have Node.js installed on your machine. You can download it from the official Node.js website: https://nodejs.org
-
Clone this repository or download the source code.
-
Open a terminal or command prompt and navigate to the project directory.
-
Install the required dependencies by running the following command:
npm install express socket.io
To start the server, run the following command:
node server.js
The server will start running and will be accessible at http://localhost:3000.
You can now open multiple browser windows or tabs and visit http://localhost:3000 to chat with other connected clients.
By default, the chat application allows only specific usernames to log in. To customize the whitelist and add or remove names, follow these steps:
-
Open the
server.js
file in a text editor. -
Locate the following line:
const authorizedUsers = ['user1', 'user2', 'user3']; // Add the authorized usernames here
-
Add or remove usernames as desired within the square brackets ([]). For example, to allow 'user4' to log in, modify the line as follows:
const authorizedUsers = ['user1', 'user2', 'user3', 'user4']; // Add the authorized usernames here
-
Save the server.js file.
-
Restart the server by running the following command:
node server.js