This Node.js application is a real-time server that manages user connections, rooms, tables, and cursor movements. It uses Express.js for the web server, Socket.IO for real-time communication, and MongoDB for data persistence.
- Installation
- Configuration
- Main Components
- API Routes
- Socket Events
- Database Models
- Authentication
- Error Handling
- Deployment
- Contributing
- Clone the repository:
git clone [repository-url]
- Install dependencies:
npm install
- Set up environment variables (see Configuration)
- Start the server:
npm start
Create a .env
file in the root directory with the following variables:
PORT=3000
MONGODB_URI=your_mongodb_connection_string
- Server Setup (index.js): Configures Express, Socket.IO, and handles real-time events.
- User Routes (user.routes.js): Defines API routes for user operations.
- Cursor Image Routes (cursorImage.routes.js): Defines API routes for cursor image operations.
- User Controller (user.controller.js): Handles user-related logic and database interactions.
- Cursor Image Controller (cursorImage.controller.js): Manages cursor image operations.
- POST
/users/auth/signup
: Register a new user - POST
/users/auth/login
: User login - POST
/users/update
: Update user information - POST
/users
: Get user information
- POST
/cursors/upload
: Upload a cursor image - POST
/cursors/get
: Get cursor images - POST
/cursors/delete
: Delete a cursor image
join-room
: User joins a roomjoin-table
: User joins a tablecursor-move
: Broadcasts cursor movementleave-room
: User leaves a roomleave-table
: User leaves a tableaudioStream
: Broadcasts audio streams within a tablemessage-global
: Broadcasts global messagesemoji
: Broadcasts emoji changes
- User
- CursorImage
The application uses bcrypt for password hashing and comparison.
Controllers include basic error handling and input validation. Errors are logged to the console and appropriate HTTP status codes are returned.
The application listens on the port specified in the environment variables or defaults to port 3000.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
[MIT]
[Gaurav Ghodinde] - [[email protected]] [karan Agarwal] - [[email protected]]
Project Link: https://github.com/gauravghodinde/cursorXone-backend