add task solution#120
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great job! 🎉 Your server-side implementation meets all core requirements and is well-structured. The only minor issue is the use of HTTP 404 instead of 400 for input validation errors—this doesn't affect functionality, but keep REST conventions in mind for future projects. Keep up the good work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| const { text, userId } = req.body; | ||
|
|
||
| if (!roomId || !userId || !text) { | ||
| return res.sendStatus(404); |
There was a problem hiding this comment.
Issue: Returning status 404 for missing parameters is not correct. According to REST conventions, 404 is for 'Not Found' (i.e., resource does not exist), not for missing or invalid input. You should return status 400 (Bad Request) instead.
| const { title, userId, description } = req.body; | ||
|
|
||
| if (!title || !userId) { | ||
| return res.sendStatus(404); |
There was a problem hiding this comment.
Issue: Returning status 404 for missing 'title' or 'userId' is not correct. According to REST conventions, 404 is for 'Not Found' resources, not for invalid or missing input. Use status 400 (Bad Request) instead.
| const { title, description } = req.body; | ||
|
|
||
| if ((!title && !description) || !roomId) { | ||
| return res.sendStatus(404); |
There was a problem hiding this comment.
Issue: Returning status 404 for missing 'roomId' or both 'title' and 'description' is not correct. 404 is for missing resources, not invalid input. Use status 400 (Bad Request) for input validation errors.
| const isNameExist = await User.findOne({ where: { name } }); | ||
|
|
||
| if (!name) { | ||
| return res.sendStatus(404); |
There was a problem hiding this comment.
Issue: Returning status 404 for missing 'name' is not correct. 404 is for 'Not Found' resources, not for invalid or missing input. Use status 400 (Bad Request) instead.
No description provided.