This project provides a set of RESTful APIs for managing a simple ecommerce store. It supports operations such as adding items to a cart, checking out, generating discount codes, and retrieving purchase statistics.
- Node.js (version 18 or later recommended)
- Clone the repository:
git clone https://github.com/shubhambattoo/e-comm-api.git
- Navigate to the project directory:
cd e-comm-api
- Install dependencies:
npm install
- Configure environment variables:
- Copy the .env.example file to .env and fill in the necessary details (e.g., database connection, ports).
- Start the server:
npm run dev
This will start a dev server using ts-node
-
Add Item to Cart
- POST /api/cart/add
- Body: { "item_id": "12345", "quantity": 2 }
-
Checkout
- POST /api/cart/checkout
- Body: { "cart_id": "abc123", "discount_code": "DISCOUNT10" }
-
Generate Discount Code
- POST /api/discount/generate
-
List Purchase Statistics
- GET api/admin/stats