A robust backend API for a Twitter-like social media platform, built with Node.js, Express, and MongoDB. This API provides functionality for user management, posts (tweets), messaging, and file uploads using AWS S3.
- User Authentication & Authorization
- JWT-based authentication
- Google OAuth integration
- Twitter OAuth integration
- Social Features
- Create, read, update, and delete posts
- Like and comment on posts
- Follow/unfollow users
- Messaging System
- Direct messaging between users
- Conversation management
- File Upload
- AWS S3 integration for media uploads
- Secure signed URLs for file uploads
- Runtime Environment: Node.js
- Framework: Express.js
- Database: MongoDB with Mongoose
- Authentication:
- JWT (JSON Web Tokens)
- Passport.js
- Google OAuth 2.0
- Twitter OAuth
- File Storage: AWS S3
- Security:
- Helmet.js for security headers
- CORS enabled
- Morgan for HTTP request logging
- bcrypt for password hashing
- Node.js (v14 or higher)
- MongoDB
- AWS Account (for S3 storage)
- Google OAuth credentials
- Twitter API credentials
Create a .env file in the root directory with the following variables:
DB_CONNECTION=your_mongodb_connection_string
AWS_BUCKET_REGION=your_aws_region
AWS_BUCKET=your_s3_bucket_name
AWS_ACCESS_KEY=your_aws_access_key
AWS_SECRET_KEY=your_aws_secret_key
JWT_SECRET=your_jwt_secret
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
TWITTER_CONSUMER_KEY=your_twitter_consumer_key
TWITTER_CONSUMER_SECRET=your_twitter_consumer_secret- Clone the repository:
git clone https://github.com/yourusername/bluebird-api.git
cd bluebird-api- Install dependencies:
npm install-
Set up your environment variables in
.env -
Start the server:
# Development mode with nodemon
npm run dev
# Production mode
npm startPOST /api/auth/register- Register a new userPOST /api/auth/login- Login userPOST /api/auth/logout- Logout user
GET /api/user/:id- Get user profilePUT /api/user/:id- Update user profileDELETE /api/user/:id- Delete user accountPUT /api/user/:id/follow- Follow a userPUT /api/user/:id/unfollow- Unfollow a user
POST /api/post- Create a new postGET /api/post/:id- Get a specific postPUT /api/post/:id- Update a postDELETE /api/post/:id- Delete a postPUT /api/post/:id/like- Like/unlike a postPOST /api/post/:id/comment- Comment on a post
POST /api/message- Send a messageGET /api/message/:conversationId- Get messages for a conversation
GET /api/conversation- Get user's conversationsPOST /api/conversation- Create a new conversation
GET /api/s3url- Get a signed URL for S3 upload
- JWT-based authentication
- Password hashing with bcrypt
- Secure headers with Helmet.js
- CORS protection
- Rate limiting
- Input validation
- XSS protection
The API implements comprehensive error handling for:
- Authentication errors
- Database errors
- File upload errors
- Invalid input validation
- Route not found errors
- 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
For support, please open an issue in the GitHub repository or contact the maintainers.