This repository contains a fully functional Social Media REST API built with Node.js, Express.js, and MongoDB. It supports core social media functionalities, from basic CRUD operations to advanced features like user authentication, story uploads, messaging, and more.
- User Authentication: Secure user login/signup using JWT.
- CRUD Operations: Create, Read, Update, and Delete posts, comments, and other entities.
- Image & Story Uploads: Users can upload images and stories with file handling.
- Messaging System: Real-time messaging functionality for user interaction.
- Likes & Comments: Like and comment on posts seamlessly.
- Blocking Functionality: Block/unblock users to maintain user privacy.
- Secure Routes: Token-based authentication for protected API routes.
- Backend: Node.js, Express.js
- Database: MongoDB (NoSQL)
- Authentication: JSON Web Tokens (JWT)
- File Handling: Multer
- Other Tools: dotenv, bcrypt, and more.
- Clone the Repository
git clone https://github.com/yourusername/social-media-rest-api.git cd social-media-rest-api
- Install Dependencies
npm install
Create a .env
file in the root directory and configure the following:
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
npm start
The server will run on http://localhost:5000
.
Method | Endpoint | Description |
---|---|---|
POST | /api/auth/register |
Register a new user |
POST | /api/auth/login |
Login an existing user |
Method | Endpoint | Description |
---|---|---|
GET | /api/users/:id |
Fetch user details |
PUT | /api/users/:id |
Update user profile |
DELETE | /api/users/:id |
Delete user account |
Method | Endpoint | Description |
---|---|---|
POST | /api/posts |
Create a new post |
GET | /api/posts/:id |
Fetch a specific post |
DELETE | /api/posts/:id |
Delete a post |
Method | Endpoint | Description |
---|---|---|
POST | /api/comments |
Add a comment to a post |
DELETE | /api/comments/:id |
Delete a comment |
Method | Endpoint | Description |
---|---|---|
POST | /api/messages |
Send a message |
GET | /api/messages |
Fetch messages |
Method | Endpoint | Description |
---|---|---|
POST | /api/upload/story |
Upload a story |
POST | /api/upload/image |
Upload an image |
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE
file for details.