https://github.com/himanshuraj98/speak-chat-app
A real-time chat application built using Node.js, Express.js, and Socket.io on the server-side, and HTML, JavaScript, and the Socket.io client library on the client-side.
https://github.com/himanshuraj98/speak-chat-app
cors express-js nodejs reactjs socket-io
Last synced: 3 months ago
JSON representation
A real-time chat application built using Node.js, Express.js, and Socket.io on the server-side, and HTML, JavaScript, and the Socket.io client library on the client-side.
- Host: GitHub
- URL: https://github.com/himanshuraj98/speak-chat-app
- Owner: HimanshuRaj98
- Created: 2023-09-10T22:33:33.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-14T20:10:14.000Z (almost 3 years ago)
- Last Synced: 2025-01-22T19:48:57.555Z (over 1 year ago)
- Topics: cors, express-js, nodejs, reactjs, socket-io
- Language: JavaScript
- Homepage:
- Size: 83 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Speak-Chat-App
## Real-Time Chat Application
This is a simple real-time chat application using Node.js, Express, and Socket.io. It includes both server-side and client-side code.
## Server-side
### Technologies Used
- Node.js
- Express.js
- Socket.io
- CORS (Cross-Origin Resource Sharing)
### Getting Started
1. Clone this repository to your local machine.
2. Install the required Node.js packages:
3. Run the server:
```javascript
const express = require("express");
const app = express();
const http = require("http");
const cors = require("cors");
const { Server } = require("socket.io");
const PORT = 5000;
app.use(cors());
const server = http.createServer(app);
const io = new Server(server, {
cors: {
origin: "http://localhost:5173",
methods: ["GET", "POST"],
},
});
io.on("connection", (socket) => {
console.log(`A user connected: ${socket.id}`);
socket.on("send-message", (messages) => {
console.log(messages);
io.emit("group-message", messages);
});
socket.on("disconnect", () => {
console.log("User Disconnected");
});
});
server.listen(PORT, () => {
console.log(`Server Running At Port ${PORT}`);
});
```
## Client-side
**Technologies Used**
- HTML
- JavaScript
- Socket.io client library