โ ํผ๋๋ก
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");
}**
Enter fullscreen mode Exit fullscreen mode
์ถ์ถ ๋ณธ๋ฌธ ยท ์ถ์ฒ: dev.to ยท https://dev.to/ali_hamza_589ec7b3eb6688d/day-167-of-learning-mern-stack-3d87
๋ต๊ธ ๋จ๊ธฐ๊ธฐ