/Ecommerce_API

Ecommerce_API

Primary LanguageJavaScript

Ecommerce API with Node.js

This is an API for an e-commerce platform built using Node.js and various libraries and frameworks. It provides endpoints for product and category management, user authentication, cart management, and order processing.

Getting Started

Follow these steps to set up and run the project:

Prerequisites

Make sure you have Node.js and npm installed on your machine.

Installation

  1. Clone the repository to your local machine:

    git clone <https://github.com/Ayush-kr-shanu/Ecommerce_API>
    cd Ecommerce_API
  2. Install the project dependencies: npm install

Environment Variables

DATABASE=data base name
USER=root
PASS=your_password
HOST=localhost
DILACT=mysql

JWT_CODE=your_secret_jwt_code

Replace your_password and your_secret_jwt_code with your actual database password and JWT secret code.

Running the Server

Run the server using the following command: npm run server

The API will start running on port 3001.

Endpoints

User Routes

Register a new user: POST /register

Log in as a user: POST /login

Category Routes

Get a list of categories: GET /category

Create a new category: POST /category

Update a category by ID: PUT /category/:categoryId

Delete a category by ID: DELETE /category/:categoryId

Product Routes

Get a list of products: GET /product

Get a product by ID: GET /product/:productId

Create a new product: POST /product

Update a product by ID: PUT /product/:productId

Delete a product by ID: DELETE /product/:productId

Cart Routes

View the user's cart: GET /cart

Add a product to the user's cart: POST /cart

Update a cart item by ID: PUT /cart/: cartItemId

Remove a cart item by ID: DELETE /cart/:cartItemId

Order Routes

Get the user's order history: GET /order

Place a new order with products from the user's cart: POST /order

Get order details by ID: GET /order/:orderId