feat: implement user profile picture upload with Cloudinary integration#298
feat: implement user profile picture upload with Cloudinary integration#298yusuftomilola merged 5 commits intoDistinctCodes:mainfrom
Conversation
|
@Jayking40 is attempting to deploy a commit to the naijabuz's projects Team on Vercel. A member of the Team first needs to authorize it. |
| } | ||
|
|
||
| @Get(':id') | ||
| @UseGuards(JwtAuthGuard) |
There was a problem hiding this comment.
The JwtAuthGuard is already been applied globally in the app module.
Also, move this logic of the findOne into the usersService and so the controller calls it from here.
| @UseGuards(JwtAuthGuard) | ||
| @UseInterceptors(FileInterceptor('file')) | ||
| @HttpCode(HttpStatus.OK) | ||
| async uploadProfilePicture( |
There was a problem hiding this comment.
create a dedicated provider and move the logic of the uploadProfilePicture into that provider, then add the provider to the usersService. So the controller remains clean and just calls that provider instead from the usersService. You can look through the existing architecture of the codebase and see the pattern.
No need to manually add the JwtAuthguard as it is implemented in the appmodule.
🎨 Profile Picture Upload Feature
📋 Overview
This PR implements a complete profile picture upload system with Cloudinary integration, allowing users to upload, update, and manage their profile pictures with automatic image optimization and cleanup.
OnlyDust Wave #3 Contribution 🌟
✨ What's New
🔧 Core Implementation
POST /users/:id/profile-picturefor uploading profile picturesGET /users/:idnow includesprofilePictureURL in responseprofilePicturecolumn to User entity (nullable, varchar(500))🛡️ Security & Validation
🚀 Features
📦 New Files Created
src/
├── cloudinary/
│ ├── cloudinary.module.ts # Cloudinary module configuration
│ └── cloudinary.service.ts # Upload/delete service with transformations
├── common/
│ └── pipes/
│ └── file-validation.pipe.ts # File type & size validation
├── config/
│ └── cloudinary.config.ts # Cloudinary provider setup
└── users/
└── dto/
└── update-user-profile-picture.dto.ts
🔄 Modified Files
src/
├── users/
│ ├── entities/user.entity.ts # Added profilePicture column
│ ├── users.controller.ts # New upload endpoint + updated GET
│ ├── users.service.ts # Profile picture update logic
│ └── users.module.ts # Import CloudinaryModule
🧪 Testing Completed
✅ Happy Path
✅ Validation & Security
✅ Edge Cases
🔥 Related Issue: #193