This project is an implementation for Cart and Product APIs that can be used within an E-commerce backend, built with Node.js, Express, TypeScript, and MongoDB.
- Cart Management
- Product Management
- MongoDB Integration
- TypeScript Support
Defines the structure for shopping carts:
- Products: Array of items (product reference and quantity)
- Subtotal
- Total
Includes a pre-save middleware for automatic total calculations.
Defines the structure for products in the system.
Handles cart-related operations:
- Initiating a new cart
- Retrieving cart contents
- Adding products to the cart
Manages product-related operations:
- Creating new products
- Retrieving product details
- Updating product information
- Deleting products
- Listing all products
- POST api/cart - Create a new cart (intiateCart)
- GET api/cart/:cart_id - Retrieve cart details (showCart)
- POST api/cart/:cart_id/product/:product_id/:quantity - Add a product to the cart (addProductToCart)
- DELETE api/cart/:cart_id/product/:product_id/:amount - Remove a product from the cart
- DELETE api/cart/:cart_id - Clear the cart
- GET api/product - List all products
- GET api/product/:id - Get details of a specific product
- POST api/product - Create a new product
- PUT api/product/:id - Update a product
- DELETE api/product/:id - Delete a product
- Clone the repository
- Install dependencies:
npm install
- Configure MongoDB connection
- Start the server:
npm start
We welcome contributions! Feel free to submit pull requests or open issues for improvements.
This project is licensed under the MIT License.