Skip to content

Conversation

@llindallarsson
Copy link

Please include your Render link: https://happy-thoughts-api-784k.onrender.com

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 with this project.

I'm missing a documentation of your API. Without reading all your code it is tricky to know what endpoints there is and methods. It is one of the requirements for the project.

Documentation of your API using e.g. Express List Endpoints

Also, I can't find the backend reflected in our frontend? Or did you create a new frontend to this project? I tried this one: https://happythoughtproject.netlify.app/
Take a look and ping me when it's done.

💪 🌷

Comment on lines 9 to 10
req.user = user; // Lägg till användaren på request-objektet
next(); // Gå vidare till nästa steg (ex. route handler)

Choose a reason for hiding this comment

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

stick to english comments, easier for the reviewer to understand

Comment on lines +22 to +24
type: mongoose.Schema.Types.ObjectId,
ref: "User",
required: true,

Choose a reason for hiding this comment

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

great linking here to the other collection

Copy link

@casalm26 casalm26 left a comment

Choose a reason for hiding this comment

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

Hi Linda!

Very well done. The code is neat and easy to navigate. i've just made a couple of suggestions of improvements that could be made in the future to make the API even more reliable. Not much else to comment on, great job!

Comment on lines +20 to +32
// get single post
router.get("/:id", async (req, res) => {
try {
const thought = await HappyThought.findById(req.params.id);
if (thought) {
res.json(thought);
} else {
res.status(404).json({ error: "Thought not found" });
}
} catch (error) {
res.status(400).json({ error: "Invalid ID format" });
}
});
Copy link

Choose a reason for hiding this comment

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

Is this used in the frontend?? It's a neat solution, just asking what the use of getting a single thought is here!

}
});

export default router;
Copy link

Choose a reason for hiding this comment

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

For future developments - maybe consider adding some rate limits on creation of posts? That way, a user can't flood the feed. :)

password: {
type: String,
required: true,
minlength: 5,
Copy link

Choose a reason for hiding this comment

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

Maybe add a maxLength here as well?

Comment on lines +34 to +49
// add new post
router.post("/", authenticateUser, async (req, res) => {
const { message } = req.body;

try {
const newThought = new HappyThought({
message,
createdBy: req.user._id, // lägg till användaren som skapar
});

const savedThought = await newThought.save();
res.status(201).json(savedThought);
} catch (error) {
res.status(400).json({ error: "Invalid input", details: error.errors });
}
});
Copy link

Choose a reason for hiding this comment

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

Possibly add input validation here as well?

@JennieDalgren
Copy link

Still can't fint the frontend that is hooked up to this backend?

@HIPPIEKICK
Copy link
Contributor

ping ☝️

@HIPPIEKICK
Copy link
Contributor

ping

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.

4 participants