Skip to content

Backend API built on a NoSQL database using MongoDB and Mongoose NPM dependency

Notifications You must be signed in to change notification settings

hazkeel27/social-network-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

social-network-api 📝

License: MIT

Description 📄

An API created with Express.js, MongoDB, and the Mongoose npm module. Users, Thoughts, and Reactions are the three main data models that the API is intended to help manage. Developers can conduct necessary CRUD (Create, Read, Update, Delete) actions on the data thanks to the extensive set of routes it provides.

Table of Contents

Key Features 🔑

Express.js Framework: By utilizing the strength of Express.js, this API offers quick and effective middleware and routing capabilities.

MongoDB Database: To store and retrieve data quickly, the API effortlessly connects with MongoDB, a dependable NoSQL database.

Mongoose npm Library: Mongoose streamlines interaction with MongoDB by making data modeling and validation easier.

User, Thought, Reaction Model: The API comes with User and Thought models that make it possible to create, retrieve, update, and delete user and thoughts data. The Reaction model provides a complete solution for handling reactions to thoughts and allows developers to interact with reactions.

HTTP Methods: The API offers developers a flexible and comprehensive set of HTTP methods, including GET, PUT, POST, and DELETE.

Installation 🛠️

To install the necessary dependencies, run the following command:

npm i
npm install express@4.17.1
npm install mongoose@7.0.2

Install DevDependency for developing purposes:

npm install nodemon@2.0.3

Usage 📘

  • Clone the repository to your local system.
  • Install dependencies to the project directory and typing npm install to get everything set up.
  • Make sure you have a MongoDB instance running locally or on a remote server before setting up MongoDB. Set up the connection information as necessary in your application code.
  • Run the application by using a process manager node server.js to start the Express.js server.
  • Explore the API: By sending HTTP queries to the specified routes, you can now explore the API.

Following are the API routes:

/api/users

  • GET all users
  • POST a new user:
// example data
{
  "username": "lernantino",
  "email": "lernantino@gmail.com"
}

/api/users/:userId

  • GET a single user by its _id and populated thought and friend data
  • PUT to update a user by its _id
  • DELETE to remove user by its _id

/api/users/:userId/friends/:friendId

  • POST to add a new friend to a user's friend list
  • DELETE to remove a friend from a user's friend list

/api/thoughts

  • GET to get all thoughts
  • POST to create a new thought
// example data
{
  "thoughtText": "Here's a cool thought...",
  "username": "lernantino",
}

/api/thoughts/:thoughtId

  • GET to get a single thought by its _id
  • PUT to update a thought by its _id
  • DELETE to remove a thought by its _id

/api/thoughts/:thoughtId/reactions

  • POST to create a reaction stored in a single thought's reactions array field

/api/thoughts/:thoughtId/reactions/:reactionId

  • DELETE to pull and remove a reaction by the reaction's reactionId value

Following is a video demonstrating how to run the application. 🎥

Video Demo

Contribution 🤝

Contributions to this API project are welcome. If you encounter issues, have suggestions for improvements, or would like to contribute, please open an issue or submit a pull request.

Tests 🧪

To run tests, users can install insomnia and run HTTP requests. Please refer to the usage section.

License 📜

This project is licensed under The MIT License. Here is the link to the license to access more information for your reference: https://opensource.org/licenses/MIT

Credits 🙏

I utilized the study material provided by the institution as a reference to complete my application.

Following are the documents I used to help me write code:

Questions ❓

If you have further questions, you are welcome to reach me through my email at hazkeel27@gmail.com.

You can view my projects by going through my GitHub profile at https://github.com/hazkeel27.

About

Backend API built on a NoSQL database using MongoDB and Mongoose NPM dependency

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published