Skip to content

Conversation

KidFromCalifornia
Copy link

BACKEND - https://js-project-api-k17p.onrender.com

FRONTEND - https://wehappy.netlify.app/

Happy Thoughts API

This is a RESTful API for a "Happy Thoughts" social app, built with Node.js, Express, and MongoDB (Mongoose). The API allows users to register, log in, and share positive thoughts. Authenticated users can create, update, delete, and like thoughts. Passwords are securely hashed with bcrypt. The API includes robust validation and error handling.

Features

  • User Authentication: Register and log in with encrypted passwords.
  • Thoughts CRUD: Create, read, update, and delete thoughts (authenticated).
  • Like Thoughts: Like any thought.
  • API Documentation: / endpoint lists all available routes.
  • Input Validation: Ensures unique emails/usernames and valid data.
  • Error Handling: Returns clear error messages and status codes.
  • CORS Enabled: Ready for frontend integration.
  • Deployed: Easily deployable to Render or similar platforms.

Endpoints Overview

  • GET / — API documentation
  • POST /register — Register a new user
  • POST /login — Log in a user
  • GET /thoughts — Get all thoughts
  • GET /thoughts/:id — Get a single thought
  • POST /thoughts — Create a thought (authenticated)
  • PATCH /thoughts/:id — Update a thought (authenticated)
  • DELETE /thoughts/:id — Delete a thought (authenticated)
  • POST /thoughts/:id/like — Like a thought

Tech Stack

  • Node.js
  • Express
  • MongoDB & Mongoose
  • bcrypt
  • dotenv
  • express-list-endpoints

… update Thought model definition and seed logic
@@ -1,22 +1,38 @@
import cors from "cors"
import express from "express"
import cors from "cors";
Copy link

Choose a reason for hiding this comment

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

Hi Jonny!

I've done a code review on your project. I was going to do it on Varia's work, but she hasn't finished yet.

Awesome work putting this API together! I do not have any suggestions for improvements or questions. I think you've done a really great job with the overall structure, and it looks super clean and organized.

Here's what I really liked and what makes this code easy to understand:

One Job, One File: You've got server.js doing the main setup, which is perfect – it just gets everything started.
Then, you have separate folders for models/ (your Mongoose schemas are super clear there!), routes/ (where all the API endpoints live, organized by users and thoughts), and middlewares/ (for reusable stuff like authentication).
It means if I want to check how users are handled, I know exactly where to look. It makes the code way less overwhelming.

Easy to Follow: Because you've split things up so well, tracing how a request comes in (from server.js), goes through a middleware (authenticationUser.js), and then hits a specific route (routes/thoughts.js), is much clearer. This makes debugging (which we're probably doing a lot of right now, haha) a lot easier.

You've really done a great job with the project structure, it's not just functional, but also super readable and ready for future growth!

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.

Wow!

I'm impressed with your work. Everything is clean and well structured in the backend and you have managed to implement all new features in a really nice way in the frontend too!

I like the extra things that you've put in, such as the cute error messages
image

Great work with your documentations as well as you commits. It's clear and easy to follow your progress with this project.

Looking forward to see you final project!
🚀

type: String,
required: true,
unique: true,
index: true, // Add index for optimization

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