Giter Club home page Giter Club logo

onlinemarket's Introduction

Backend API of an Online Marketplace

Set up

  1. Set up local mysql server
  2. Using MySQL cli, run $mysql> source \this_repo\db\db.sql;
  3. Modify MySQL credentials to app.js on line 27
  4. Run npm install on repo directory
  5. Run node app.js
  6. Server should now be running on localhost:8000/

API Usage

GET /store

  • store frontpage, fetches all products

GET /store/details/{productId}

  • fetches details of a product with id of productId

GET /store/add_to_cart/{productId}

  • adds the product once to the cart

Note: If quantity of the product in the cart is equal to the inventory_count, adding that product again will no longer increment the quantity in the cart.

GET /store/remove_from_cart/{productId}

  • removes the product once from the cart

GET /store/cart

  • displays details of the cart

Example Cart format:

{
    "items": {
        "1": {
            "title": "New Toy",
            "price": 35.12,
            "quantity": 11,
            "itemPriceTotal": 386.32
        },
        "2": {
            "title": "New New Toy",
            "price": 35.11,
            "quantity": 1,
            "itemPriceTotal": 35.11
        }
    },
    "totalPrice": "421.43"
}

GET /store/submit_cart

  • submits the current cart and updates the database accordingly

POST /authenticate

  • Receives a JWT token for making requests to protected routes

POST Data Format:

{
  "username": "testaccount",
  "password": "password123"
}

The following routes require JWT token validation


POST /store/add_product

  • Adds a new product to the store

Example POST Data Format:

{
  "title": "Awesome Crazy Toy",
  "price": 23.99,
  "inventory_count": 50
}

POST /store/add_product_inventory

  • Increase the product inventory_count by a given amount

Example POST Data Format:

{
  "title": "Awesome Crazy Toy",
  "add_amount": 10
}

onlinemarket's People

Contributors

williamdee avatar

Watchers

 avatar

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.