This Social Network API is a backend application that allows users to share their thoughts, react to friends' thoughts, and create a friend list. It's built using Node.js, Express.js, MongoDB, and Mongoose ODM, providing a robust platform for social media interactions.
- Create, read, update, and delete users and thoughts.
- Add and remove friends for each user.
- Add and remove reactions to thoughts.
To install this project, follow these steps:
- Clone the repository to your local machine:
git clone https://github.com/romeocd/mongodb-socialnetwork-api - Navigate to the project directory:
cd mongodb-socialnetwork-api - Install the necessary dependencies:
npm install
To start the server, run the following command in your terminal:
npm start
Once the server is running, you can use API testing tools like Postman or Insomnia to interact with the API.
GET /api/users: Fetch all users.GET /api/users/:id: Fetch a single user by ID.POST /api/users: Create a new user.PUT /api/users/:id: Update a user by ID.DELETE /api/users/:id: Delete a user by ID.POST /api/users/:userId/friends/:friendId: Add a friend.DELETE /api/users/:userId/friends/:friendId: Remove a friend.GET /api/thoughts: Fetch all thoughts.GET /api/thoughts/:id: Fetch a single thought by ID.POST /api/thoughts: Create a new thought.PUT /api/thoughts/:id: Update a thought by ID.DELETE /api/thoughts/:id: Delete a thought by ID.POST /api/thoughts/:thoughtId/reactions: Add a reaction to a thought.DELETE /api/thoughts/:thoughtId/reactions/:reactionId: Remove a reaction from a thought.
User: Includes username, email, thoughts, friends, and a virtual for friend count.Thought: Includes thought text, creation date, username, reactions, and a virtual for reaction count.Reaction: A subdocument schema in the Thought model, used for reactions.
- Node.js
- Express.js
- MongoDB
- Mongoose ODM
Please contact me at: GitHub:romeocd Email: rdumlao07@gmail.com
Part 1: https://drive.google.com/file/d/19kFymwLpdFuwoUrVw3VY48iDOlfBuQeJ/view Part 2: https://drive.google.com/file/d/18zq2_dPhRNJqqYAXqGtJsVHWc0S1KKT6/view