Giter Site home page Giter Site logo

jofiel-nguyen / socialnetworkapi Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.09 MB

An API for a social network web application

Home Page: https://github.com/your-username/social-network-api

License: MIT License

JavaScript 100.00%
api-rest javascript

socialnetworkapi's Introduction

Social Network API

This is an API for a social network web application built using MongoDB, Express.js, and Mongoose. It allows users to share their thoughts, react to friends' thoughts, and create a friend list.

Installation

To run this project locally, follow these steps:

  1. Clone the repository to your local machine.

    git clone https://github.com/your-username/social-network-api.git
  2. Install the dependencies using the command:

    npm install
  3. Configure the MongoDB database connection in the .env file. You can use a local or remote MongoDB instance.

  4. Start the server using the command:

    npm start

Usage

Once the server is running, you can use a tool like Insomnia or Postman to interact with the API. The API routes available are as follows:

Users

  • GET /api/users: Get all users.
  • GET /api/users/:userId: Get a single user by their _id and populate their thought and friend data.
  • POST /api/users: Create a new user. Provide the following data in the request body:
    {
      "username": "example",
      "email": "[email protected]"
    }
  • PUT /api/users/:userId: Update a user by their _id. Provide the updated user data in the request body.
  • DELETE /api/users/:userId: Delete a user by their _id.
  • POST /api/users/:userId/friends/:friendId: Add a new friend to a user's friend list. Provide the userId and friendId in the URL parameters.
  • DELETE /api/users/:userId/friends/:friendId: Remove a friend from a user's friend list. Provide the userId and friendId in the URL parameters.

Thoughts

  • GET /api/thoughts: Get all thoughts.
  • GET /api/thoughts/:thoughtId: Get a single thought by its _id.
  • POST /api/thoughts: Create a new thought. Provide the following data in the request body:
    {
      "thoughtText": "Here's a cool thought...",
      "username": "example",
      "userId": "5edff358a0fcb779aa7b118b"
    }
  • PUT /api/thoughts/:thoughtId: Update a thought by its _id. Provide the updated thought data in the request body.
  • DELETE /api/thoughts/:thoughtId: Delete a thought by its _id.
  • POST /api/thoughts/:thoughtId/reactions: Create a reaction stored in a single thought's reactions array field. Provide the thoughtId in the URL parameter and the reaction data in the request body.
  • DELETE /api/thoughts/:thoughtId/reactions: Remove a reaction by its reactionId from a single thought's reactions array field. Provide the thoughtId and reactionId in the URL parameters.

Walkthrough Video

Watch a walkthrough video of this API in action: Walkthrough Video

Links

Credits

License

This project is licensed under the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.