- README
- MongoDB Atlas Integration Guide
- Post Collection Schema
- Chat Collection Schema
- User Collection Schema
- Activity Collection Schema
This project is a social media backend built using Node.js and Express. It includes RESTful APIs for user management, posts, comments, and more. The project is designed to support a dynamic social media application with essential backend features such as user authentication, media uploads, and role-based access.
- User Authentication: Registration, login, and JWT-based authentication.
- Posts & Comments: Users can create, read, update, and delete posts and comments.
- Middleware: Custom middleware for authentication, error handling, and request logging.
- Logging: Logs are maintained for server activities.
- Content Moderation: Integrated Google Vision API and Cloudinary WebPurify for detecting and preventing uploads of inappropriate content.
- API Documentation: Well-documented API endpoints for easy integration.
api/- Contains route definitions for users, posts, and other features.config/- Configuration files for database connections and environment variables.middlewares/- Middleware logic for authentication, error handling, etc.services/- Business logic abstracted into services.data/- Placeholder for data-related operations.logs/- Server log files.public/- Static assets.server.js- The main server file to start the Express app.
-
Clone the repository:
git clone https://github.com/shlomiNugarker/social-media-node-express.git
-
Navigate to the project directory:
cd social-media-node-express-main -
Install dependencies:
npm install
-
Create a
.envfile in the root directory and provide the following environment variables:DB_URI=your_mongodb_uri_here REACT_APP_GOOGLE_MAP_KEY= TOKEN_SECRET=your_jwt_secret CLOUD_NAME=your_cloud_name CLOUD_API_KEY=your_api_key CLOUD_API_SECRET=your_api_secret GOOGLE_PRIVATE_KEY= GOOGLE_CLIENT_EMAIL= GOOGLE_PROJECT_ID=
To start the server in development mode:
npm run devTo start the server in production mode:
npm start- GET / - Fetch all activities
- POST / - Add a new activity
- PUT /:id - Update an activity by ID
- GET /length - Get the number of activities
- POST /login - User login
- POST /signup - User signup
- POST /logout - User logout
- GET / - Fetch all chats
- GET /:id - Fetch a chat by ID
- POST / - Create a new chat
- PUT /:id - Update a chat by ID
- DELETE /:id - Delete a chat by ID
- GET / - Fetch all comments
- GET /:id - Fetch a comment by ID
- POST / - Add a new comment
- PUT /:id - Update a comment by ID
- DELETE /:id - Delete a comment by ID
- GET / - Fetch all posts
- GET /length - Fetch the number of posts
- GET /:id - Fetch a post by ID
- POST / - Create a new post
- PUT /:id - Update a post by ID
- DELETE /:id - Delete a post by ID
- GET / - Fetch all users
- GET /:id - Fetch a user by ID
- POST / - Add a new user
- PUT /:id - Update a user by ID
- DELETE /:id - Delete a user by ID
The frontend for this project can be found at here.
Feel free to submit pull requests for new features, bug fixes, or improvements. Please ensure all tests pass before submitting.
This project is licensed under the MIT License.