Hello Dev Community! 👋
It is officially Day 167 of my full-stack development journey! Today, I shifted focus to the backend of QuickChat, engineering the user authentication, verification middleware, and profile update endpoints using Node.js, Express, MongoDB, and Cloudinary! ⚙️🔑
Here is the breakdown of the backend architecture developed today.
🛠️ Technical Breakdown: Authentication & Profile Controllers
As shown in my implementation snapshots (Screenshots 407 to 410):
1. Express Routing & Protection Middleware
- Encapsulated routing under
userRouter.jsand protected endpoints using customprotectRouteJWT middleware:
javascript
userRouter.post('/signup', signup);
userRouter.post('/login', Login);
userRouter.put('/update-profile', protectRuote, updateProfile);
userRouter.put('/check', protectRuote, checkAuth);
**if (!profilePic) {
updatedUser = await user.findByIdAndUpdate(userId, { bio, fullName }, { new: true });
} else {
const upload = await cloudinary.uploader.upload(profilePic);
updatedUser = await user.findByIdAndUpdate(
userId,
{ profilePic: upload.secure_url, bio, fullName },
{ new: true }
).select("-password");
}**
Top comments (0)