https://github.com/cobbyelsonfx/lets-talk
This is a real-time chat application built using Socket.io, Node.js, and Express.
https://github.com/cobbyelsonfx/lets-talk
express expressjs nodejs socket-io
Last synced: 7 days ago
JSON representation
This is a real-time chat application built using Socket.io, Node.js, and Express.
- Host: GitHub
- URL: https://github.com/cobbyelsonfx/lets-talk
- Owner: CobbyElsonfx
- Created: 2023-04-06T13:03:17.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-08-06T10:37:39.000Z (almost 2 years ago)
- Last Synced: 2025-02-18T01:30:43.449Z (3 months ago)
- Topics: express, expressjs, nodejs, socket-io
- Language: JavaScript
- Homepage:
- Size: 2.25 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Chat App with Socket.io

## This is a real-time chat application built using Socket.io, Node.js, and Express.
## Live Project: https://letstalk-dvk9.onrender.com
## Installation### To run the application locally, clone this repository and run the following command to install the necessary dependencies:
npm install
## Usage
To start the server, run the following command:
npm start
This will start the server on http://localhost:3000.
Once the server is running, open your web browser and navigate to http://localhost:3000 to access the chat application.
FeaturesReal-time messaging using Socket.io
Displays active users in the chat room
Displays when a user joins or leaves the chat room
Option to choose a username## Technologies Used
Node.js
Express
Socket.io
HTML/CSS## Things I learnt during this tutorial
1. Setting up a connection with Socket.io
a. Set up a normal express server.
i. Require the express module and save it the variable express
`
const express = require("express")`
ii. Create an instance of the express called app
`
const express = require("express")
const app = express()
`
iii. require the file module which will enable you to read static files(public directory )`
const express = require("express")
const app = express()const path = require("path")
`
iv. Set up a port you can listen as your server on your local maching
NB:The process.env.PORT checks if there is any PORT availbale in the env file if not is uses the default port set for it
`
const express = require("express")
const app = express()
const path = require("path")const port = process.env.PORT || 3000
app.use(express.static(path(_dirname,"public")))
`
v. Start the server
`app.listen(port, ()=>{
console.log(`server started on Port ${port}`)
})
`
b. In oder to set up a bidirectional connection with socket.io which is built on top of websocket
i. Require the node module http for setting up http connection
ii. Require and create a websocket function called io`
const server = http.createServer(app)
const io = socketio(server)
`
c. the qs cdn library can can be used to grab the contents of a url
## Credits
This project was created following the tutorial from Traversy Media on YouTube.
LicenseThis project is licensed under the MIT License - see the LICENSE file for details.
AuthorAndoh Francis