Day 167 of Learning MERN Stack

์ž‘์„ฑ์ž

์นดํ…Œ๊ณ ๋ฆฌ:

โ† ํ”ผ๋“œ๋กœ
DEV Community ยท Ali Hamza ยท 2026-08-01 ๊ฐœ๋ฐœ(SW)

Ali Hamza

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.js and protected endpoints using custom protectRoute JWT 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

์ฝ”๋ฉ˜ํŠธ

๋‹ต๊ธ€ ๋‚จ๊ธฐ๊ธฐ

์ด๋ฉ”์ผ ์ฃผ์†Œ๋Š” ๊ณต๊ฐœ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ํ•„์ˆ˜ ํ•„๋“œ๋Š” *๋กœ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค