A RESTful API for a social network web application where users can share their thoughts, react to friends' thoughts, and create a friend list. This application uses Express.js for routing, MongoDB as the NoSQL database, and the Mongoose ODM.
- Create, read, update, and delete users
- Add and remove friends from a user's friend list
- Create, read, update, and delete thoughts (posts)
- Create and delete reactions to thoughts
- Mongoose models with schema settings as specified in the requirements
- Formatted timestamps using custom methods
- Node.js
- Express.js
- MongoDB
- Mongoose ODM
- JavaScript
-
Clone the repository to your local machine:
git clone <repository-url> -
Navigate to the project directory:
cd Social-Network-API -
Install the required dependencies:
npm install -
Ensure MongoDB is installed and running on your local machine.
-
Start the server:
npm start -
The server will start and the Mongoose models will be synced to the MongoDB database.
-
Use an API client like Insomnia or Postman to test the API routes.
- GET /api/users - Get all users
- GET /api/users/:userId - Get a single user by ID
- POST /api/users - Create a new user
{ "username": "johndoe", "email": "johndoe@gmail.com" } - PUT /api/users/:userId - Update a user by ID
- DELETE /api/users/:userId - Delete a user by ID (Also removes user's associated thoughts)
- POST /api/users/:userId/friends/:friendId - Add a friend to a user's friend list
- DELETE /api/users/:userId/friends/:friendId - Remove a friend from a user's friend list
- GET /api/thoughts - Get all thoughts
- GET /api/thoughts/:thoughtId - Get a single thought by ID
- POST /api/thoughts - Create a new thought
{ "thoughtText": "Here's a cool thought...", "username": "johndoe", "userId": "12345678990" } - PUT /api/thoughts/:thoughtId - Update a thought by ID
- DELETE /api/thoughts/:thoughtId - Delete a thought by ID
- POST /api/thoughts/:thoughtId/reactions - Create a reaction for a thought
{ "reactionBody": "Wow, great thought!", "username": "janedoe" } - DELETE /api/thoughts/:thoughtId/reactions/:reactionId - Remove a reaction from a thought
https://www.youtube.com/watch?v=qHjWBDSs45I
This project is licensed under the MIT License.
If you have any questions about this project, please feel free to contact me:
- GitHub: https://github.com/Martin-rojo
- Email: Martin.rojo101@gmail.com