Skip to content

Empower your e-commerce platform with this API, meticulously crafted using Node.js and Express.js, and powered by Supabase for seamless data management.

Notifications You must be signed in to change notification settings

usama739/Ecommerce-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is an e-commerce API built with Node.js and Express.js, utilizing Supabase for data storage. The API supports product management, cart management, order placement, and user authentication.

Table of Contents

Documentation

API documentation is available at /api-docs.

Installation

  1. Clone the repository:
    git clone https://github.com/usama739/Ecommerce-API.git
    cd ecommerce-api
  2. Install dependencies:
    npm install
  3. Create a .env file in the root directory and add your environment variables:
    SUPABASE_URL=your_supabase_url
    SUPABASE_KEY=your_supabase_key
  4. Start the server:
    npx nodemon server.js
    

Once the server is running, you can use tools like Postman to interact with the API endpoints.

Endpoints

Authentication

  1. Register a New User

    URL: POST /api/auth/register

    Description: Registers a new user.

    1_User Registration

  2. Login

    URL: POST /api/auth/login

    Description: Logs in a user.

    2_User Login

Product Management

  1. Create a New Product

    URL: POST /api/products

    Description: Creates a new product.

    3_Creating New Product

  2. Retrieve or Filter Products by Category

    URL: GET /api/products?category=CategoryName

    Description: Retrieves products filtered by category.

    4_Filtering Products by Category

  3. Update a Product

    URL: PUT /api/products/:id

    Description: Updates the details of an existing product.

    5_Updating Product

  4. Delete a Product

    URL: DELETE /api/products/:id

    Description: Deletes a product.

    6_Deleting Product

Cart Management

Note: Only authenticated users can access and modify their cart information.

  1. Create a New Cart

    URL: POST /api/cart

    Description: Creates a new cart for a user.

    7_Create Cart

  2. Add Product to Cart

    URL: POST /api/cart/add

    Description: Adds a product to the user's cart with a specified quantity.

    8_Adding Product to cart

  3. Remove Product from Cart

    URL: POST /api/cart/remove

    Description: Removes a product from the user's cart.

    It will generate an error if the user is not authenticated.

    9_Remove from cart (Incorrect Authentication)

    Product will be removed if authenticated user makes a request

    10_Remove from cart

  4. Get Cart Contents

    URL: GET /api/cart/:userId

    Description: Retrieves the contents of the user's cart.

    11_Get cart content

Order Placement

Note: Only authenticated users can access and modify their order information.

  1. Place an Order

    URL: POST /api/orders

    Description: Places an order by converting the contents of the user's cart into an order.

    12_Order Placed

  2. Get Order Details

    URL: GET /api/orders/:id

    Description: Retrieves order details by order ID.

    14_Get Order Content

About

Empower your e-commerce platform with this API, meticulously crafted using Node.js and Express.js, and powered by Supabase for seamless data management.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages