GithubHelp home page GithubHelp logo

madhavkhoslaa / e-commerce-api Goto Github PK

View Code? Open in Web Editor NEW
19.0 1.0 8.0 3.04 MB

A Restful API for an E-Commerce website.

Home Page: https://madhav-ecommerce.herokuapp.com/

License: GNU General Public License v3.0

JavaScript 93.06% Shell 6.94%
ecommerce-api express expressjs mongodb mongoose backend rest-api buyer stripe-api payments

e-commerce-api's Introduction

E-Commerce-API

Build Status

Usage

  • clone
  • install packages
  • change .env file with port and mongourl for your database
  • deploy

This API has been made for a small scale e commerce businesses.

Made with:

  • Node.js
  • MongoDB and Mongoose
  • Express
  • Stripe API for payments(to be added)

Description:

There are endpoints for Sellers, Buyers and their interaction with Products.

Features to be added:

  • Standard error messages and HTTP codes
  • Support for transportation
  • Payments through stripe API
  • A better relationship between databases
  • Cart feature for buyers

Endpoints:

Buyer Related:

Endpoint HTTP Method Usage Returns Requires Auth Development Status
/buyer/register POST Accepts the name, email, password and address of the user. JSON data of the user details and a JWT token. No Works
/buyer/me GET Call the API with required bearer JWT token in header. Returns the entire buyer details except private details like passwords. Yes Works
/buyer/me PATCH Call the API with required bearer JWT token in header and the details that are to be changed. Returns the entire buyer details except private details like passwords. Yes Works
/buyer/me DELETE Call the API with required bearer JWT token in header. Returns the entire buyer details except private details like passwords and Deletes the data from the collection Yes Works
/buyer/login POST Call the API with email and password Returns the entire buyer details except private details like passwords and JWT token for accessing enndpoints that require authentication. No Works
/buyer/logout POST Call the API with required bearer JWT token in header. Deletes the provided token in the header from the JWT token array. Yes Works
/buyer/buy/:id POST Call the API with required bearer JWT token in header and the ID(mongo db _id) of the product. Removes the seller as owner from the product database and sets owner to the buyer after the payment is completed. Yes In Progress

Seller Related:

Endpoint HTTP Method Usage Returns Requires Auth Development Status
/seller/register POST Accepts the name, email, password and address of the seller. JSON data of the user details and a JWT token. No Works
/seller/me GET Call the API with required bearer JWT token in header. Returns the entire buyer details except private details like passwords. Yes Works
/seller/me PATCH Call the API with required bearer JWT token in header and the details that are to be changed. Returns the entire buyer details except private details like passwords. Yes Works
/buyer/me DELETE Call the API with required bearer JWT token in header. Returns the entire buyer details except private details like passwords and Deletes the data from the collection Yes Works
/seller/login POST Call the API with email and password Returns the entire buyer details except private details like passwords and JWT token for accessing enndpoints that require authentication. No Works
/seller/logout POST Call the API with required bearer JWT token in header. Deletes the provided token in the header from the JWT token array. Yes Works
/seller/product/add POST Requires a JSON of prodict details and JWT token in the header Returns the JSON of the product that has been sent and stores in the database. Yes Works
/seller/product/edit/:id POST Requires a JSON of prodict details that are needed to be changed and JWT token in the header Returns the new data of the product that has been updated. Yes Works
/seller/product/delete/:id POST Requires the ID(mongo db id) of the product that is needed to be deleted and JWT token Returns the JSON product whose ID was given and deleted it from the database. Yes Works
/seller/products GET Required JWT token in the header Returns the products that are posted by the seller. Yes Works

Product Related:

Endpoint HTTP Method Usage Returns Requires Auth Development Status
/seller/product/edit/:id POST Requires a JSON of prodict details that are needed to be changed and JWT token in the header Returns the new data of the product that has been updated. Yes Works
/seller/product/delete/:id POST Requires the ID(mongo db id) of the product that is needed to be deleted and JWT token Returns the JSON product whose ID was given and deleted it from the database. Yes Works
/seller/products GET Required JWT token in the header Returns the products that are posted by the seller. Yes Works
/seller/product/add POST Requires a JSON of prodict details and JWT token in the header Returns the JSON of the product that has been sent and stores in the database. Yes Works
/buyer/buy/:id POST Call the API with required bearer JWT token in header and the ID(mongo db _id) of the product. Removes the seller as owner from the product database and sets owner to the buyer after the payment is completed. Yes Works but Stripe API payments to be added

Database Schemas

Product:

Name Type
_id mongoose.Schema.Types.ObjectId
item_name String
description String
category String
price Number
Owner mongoose.Schema.Types.ObjectId

Seller:

Name Type
_id mongoose.Schema.Types.ObjectId
name String
email String
password String
tokens Array of strings

Buyer:

Name Type
_id mongoose.Schema.Types.ObjectId
name String
email String
password String
Address String
tokens Array of strings

Transactions:

Name Type
_id mongoose.Schema.Types.ObjectId
seller_id mongoose.Schema.Types.ObjectId
Product_id mongoose.Schema.Types.ObjectId
buyer_id mongoose.Schema.Types.ObjectId

e-commerce-api's People

Contributors

dependabot[bot] avatar madhavbaaz avatar madhavkhoslaa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

e-commerce-api's Issues

Fix delete method for products posted by sellers

SellerRouter.delete('/seller/product/:id', Auth, async(req, res) => {
    try {
        const product = await Product.deleteOne({ _id: req.params.id, owner: req.seller._id })
        if (!product) return res.status(404).send({ message: "unable to delete" })
        res.status(200).send({ message: "product deleted", product })
        console.log(product)
    } catch (e) {
        res.status(500).send()
        console.log(e)
    }
})

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.