Skip to content

Conversation

simfrisk
Copy link

Here is my project!

I want to clean up the code a bit but I don't know if I will be able to do it before the review. I got a bit unsure of naming stadards mid project for folders. Are they suppose to be camel case or with hyphens? So there might be a bit of a mix. Anyways, I learned a ton this project and I am excited for the final project!

Netlify:
https://happy-thought2.netlify.app/

Render link:
https://happy-thoughts-zcsh.onrender.com/

Frontend Github:
https://github.com/simfrisk/Happy-thouhts

Copy link

@tildetilde tildetilde left a comment

Choose a reason for hiding this comment

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

🧠 Code Review 🧠

Hey! I’ve gone through your backend code and just wanted to say: awesome job! You’ve clearly put thought into structure, security, and functionality. 🙌 Here’s some feedback that might help you polish it even more:

What’s working really well:
💡 Clear and RESTful structure
Your routes are well-organized. It’s easy to follow the logic and understand what each route is doing.

🔐 Authentication & user validation
It all looks very neat and tidy! I noticed that you're comparing the createdBy field with req.user._id in both patchThought.js and deleteThought.js to ensure that users can only edit or delete their own thoughts, it's cool how you structured this. It’s also nice that unauthorized attempts return clear 403 responses.

🧼 Clean code and separation of concerns
Nice job splitting your logic into endpoints/, models/, and utils/. The code is modular and easy to read. Helpers like getFilteredThoughts, getPages, and getSortedThoughts make things tidy.

🌱 Seeding setup
I appreciate that you’ve included a way to reset and seed the database; I also liked how you import thoughtData from a JSON file and loop through it to repopulate the database in resetDatabase.js. That setup is simple but effective, and it’s easy to extend later if you want to include user seeding or other mock data.

🛠 Suggestions & small improvements

Minor thing: there are some leftover comments and old code (e.g., in getThoughtById.js). Also there are still some console.log()s in there, perhaps clean them out before final deployment.

📉 Status codes
A few of your catch blocks return status 400 even when I think it is a server issue. There might be a good idea to change those to 500 to better reflect what’s going on.

🧪 Frontend feedback
I tested your frontend too and noticed a few things that might be worth looking at:
👉The textarea can be resized, which sometimes messes with the layout – maybe add resize: none or set a max height?
👉No error messages show up if login/signup fails. It would be super helpful for users if you displayed something like “wrong password” or “missing email.”
👉When I post a thought, it shows up at the top of every page in pagination – I wasn’t sure if that was intended?
👉Lighthouse gave a few warnings:
Buttons without accessible names
Low contrast between text and background

I know these are frontend things, but since the project connects both sides, I figured it might be useful to mention.

Overall, it all looks and works really well. You’ve clearly taken the time to think through how your API should function!! And it shows, from the structure of your folders to how you’ve handled user logic. It’s clean, secure, and pleasant to read, which is no small feat in a fullstack project.

Great work 💥
/Tilde

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.

Really good job with this project. You are approved with a VG.

Very well structured code base. Nice implementation of all the "new" features like editing, deleting and authentication.
Also really good job with the sidebar to sort and filter. There are some tiny things to fix styling wise there, but not a biggie and not in the scope of this project anyways.

Remember to clean up some files where you have left code out-commented if you dont keep them for a reason.

Looking forward to see you final project!

💪

Comment on lines +28 to +41
// export const authenticateUser = async (req, res, next) => {
// const user = await User.findOne({
// accessToken: req.header("Authorization")
// })

// if (user) {
// req.user = user
// next()
// } else {
// res.status(401).json({
// loggedOut: true
// })
// }
// } No newline at end of file

Choose a reason for hiding this comment

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

this could be removed if you don't want it here. Maybe you kept it for a reason? If so, add that as a comment

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