-
Notifications
You must be signed in to change notification settings - Fork 30
PR for review & submission of the happy thoughts API (will also open a PR for the frontend) #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job on a clean-cut app and UI 🥳 it seems super close on getting all the requirements. Just a few error messages to tell the user what's missing in register form, and connecting the authentication for edit/delete messages. I see now that when I logout and come back in, the liked messages do populate at the bottom so that is there 🙌 I know this was a behemoth of a project, so great job on it!
"category": "project", | ||
"hearts": 3, | ||
"createdAt": "2024-06-01T10:30:00Z", | ||
"likedBy": ["user123"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool feature that you can store user likes on each post 🙌
res.status(201).json({ success: true, message: "User created", token }); | ||
} catch (error) { | ||
res | ||
.status(500) | ||
.json({ success: false, message: "Error creating user", error }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could suggest adding more specific error messages/handling. It was hard to tell why I couldn't register at first. I needed 6 password characters and I was only doing 5. And the email field didnt show any user errors when registering, (it did in the login form). Its possible to use mongoose named errors to get more info; something in this direction:
if (error.name === "ValidationError") {
return res.status(400).json({
success: false,
errors: error.errors,
message: "Validation failed",
})
}
res.status(500).json({
success: false,
error: error.message,
message: "Server error - try again later."
})
}
); | ||
} | ||
|
||
// Sort by date |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nice that you started with these stretch goals for sorting and pagination. Maybe a quick copy from the school json to load a bunch more posts will help display this feature, without too much extra work on you. ✨
// GET LIKED THOUGHTS FOR A USER | ||
app.get("/thoughts/liked/:clientId", async (req, res) => { | ||
try { | ||
const { clientId } = req.params; | ||
const likedThoughts = await Thought.find({ likedBy: clientId }); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think clientId is not in the Schemas, so possibly why it doesn't load liked messages at the bottom of the page while logged in. The like button is registering a like/unlike though, so nice job!
const newThought = await new Thought({ message, category }).save(); | ||
|
||
res.status(200).json({ | ||
success: true, | ||
response: newThought, | ||
message: "Thought created successfully.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could it be that clientId or wherever the token is called, needs to be added here so a user can get authorization to edit/delete their own thought?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job with this project.
There are a few things that doesnt work. For example when trying to edit a thought I get this error message
The same goes for deleting a thought.
I can see that you are using the middlewere in the endpoints but maybe not fully implemented... Have a look.
When liking a thought i had to refresh the page, and then login again for that thought to be added to the section of my liked thoughts.
Have a look at the bug with editing and deleting and also make sure that you have met all requirements.
Double check so that the error handling is working on all your endpoints.
Great job so far! 💪
Hi! Thanks to you both for your comments! Everything should be fixed now with errors on delete/update, adding validation properly, and the liked thoughts popping up at the bottom without needing a reload as well as making sure that liked thoughts are drawn from the userid instead of just based on localstorage. I also went through the requirements again and that seems ok too? Please let me know if I missed something :) |
Render link: https://api-project-ns11.onrender.com
Netlify link: https://happy-thoughts-messaging-app.netlify.app/
Frontend PR: Technigo/js-project-happy-thoughts#9