Skip to content

Happy thoughts API #498

Open
FannyEste wants to merge 6 commits intoTechnigo:masterfrom
FannyEste:master
Open

Happy thoughts API #498
FannyEste wants to merge 6 commits intoTechnigo:masterfrom
FannyEste:master

Conversation

@FannyEste
Copy link

@HIPPIEKICK
Copy link
Contributor

Please share a link to your frontend as well so we can test it live 😊

@FannyEste
Copy link
Author

Please share a link to your frontend as well so we can test it live 😊

Hi Matilda! sure! I think is this one? I think that I accidentally posted the link to the PR and not the frontend, I hopw its correct now! :)

https://happy-thoughts-typescript-estefanny.netlify.app/

Copy link

@JennieDalgren JennieDalgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! The project is approved

Comment on lines +38 to +40
// Validate the message length
if (!message || message.length < 5 || message.length > 140) {
return res.status(400).json({ error: "Message must be between 5 and 140 characters" });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// GET /thoughts - Retrieve 20 most recent thoughts
app.get("/thoughts", async (req, res) => {
try {
const thoughts = await Thought.find().sort({ createdAt: -1 }).limit(20);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createdAt: "desc"

would be another way to sort the thoughts.

Comment on lines +56 to +61
try {
const updatedThought = await Thought.findByIdAndUpdate(
thoughtId,
{ $inc: { hearts: 1 } }, // Increment hearts count
{ new: true } // Return updated document
);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants