-
Notifications
You must be signed in to change notification settings - Fork 496
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
Happy Thoughts API - Mai #478
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.
Well done and well documented project ⭐
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 that you broke this out 👍
}, | ||
}); | ||
|
||
export const Thought = mongoose.model("Thought", ThoughtSchema); |
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.
Best practice to always leave an empty line in the end of every JS file
handler: async (req, res) => { | ||
try { | ||
const thoughts = await Thought.find().sort({ createdAt: -1 }).limit(20); | ||
res.json(thoughts); |
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.
Would be nice with a status code here
const likedThought = await Thought.findByIdAndUpdate( | ||
thoughtId, | ||
{ $inc: { hearts: 1 } }, | ||
{ new: true } | ||
); |
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.
⭐
if (likedThought) { | ||
res.status(200).json(likedThought); | ||
} else { | ||
res.status(404).json({ message: "Thought not found " }); |
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.
👍
Netlify link
Backend: https://project-happy-thoughts-api-vya8.onrender.com
Frontend: https://project-happy-thoughts-maikanetaka.netlify.app/
Collaborators
solo