/e-commerce

Primary LanguageJavaScript

e-commerce

This is the backend project for an e-commerce application, built using Node.js and Express. It provides a set of RESTful API endpoints for managing products, categories, orders, users, and authentication.

Table of Contents

Technologies Used

  • Node.js
  • Express
  • MongoDB (or your preferred database)
  • JWT for authentication

Installation

Prerequisites

  • Node.js and npm installed
  • MongoDB installed and running

Steps

  1. Clone the repository:

    git clone https://github.com/MrNewbie-KH/e-commerce-api.git
    cd e-commerce-api
  2. Install the dependencies:

    npm install
  3. Set up environment variables: Create a .env file in the root directory and add the following:

    PORT=3000
    MONGODB_URI=mongodb://localhost:27017/e-commerce
    JWT_SECRET=your_jwt_secret
  4. Start the server:

    npm start

Usage

Once the server is running, you can interact with the API using tools like Postman.

API Endpoints

Authentication

  • POST /api/auth/register: Register a new user
  • POST /api/auth/login: Login a user

Users

  • GET /api/users: Get all users
  • GET /api/users/:id: Get a single user
  • PUT /api/users/:id: Update a user
  • DELETE /api/users/:id: Delete a user

Products

  • GET /api/products: Get all products
  • GET /api/products/:id: Get a single product
  • POST /api/products: Create a new product
  • PUT /api/products/:id: Update a product
  • DELETE /api/products/:id: Delete a product

Categories

  • GET /api/categories: Get all categories
  • GET /api/categories/:id: Get a single category
  • POST /api/categories: Create a new category
  • PUT /api/categories/:id: Update a category
  • DELETE /api/categories/:id: Delete a category

Orders

  • GET /api/orders: Get all orders
  • GET /api/orders/:id: Get a single order
  • POST /api/orders: Create a new order
  • PUT /api/orders/:id: Update an order
  • DELETE /api/orders/:id: Delete an order

Cart

  • GET /api/cart: Get the user's cart
  • POST /api/cart: Add item to cart
  • PUT /api/cart/:itemId: Update item in cart
  • DELETE /api/cart/:itemId: Remove item from cart

Payment

  • POST /api/payment: Process payment

File Upload

  • POST /api/upload: Upload a file

Reviews

  • GET /api/reviews/:productId: Get reviews for a product
  • POST /api/reviews/:productId: Add a review for a product
  • PUT /api/reviews/:reviewId: Update a review
  • DELETE /api/reviews/:reviewId: Delete a review

Wishlist

  • GET /api/wishlist: Get the user's wishlist
  • POST /api/wishlist: Add item to wishlist
  • DELETE /api/wishlist/:itemId: Remove item from wishlist

Coupons

  • GET /api/coupons: Get all coupons
  • GET /api/coupons/:code: Get a single coupon by code
  • POST /api/coupons: Create a new coupon
  • PUT /api/coupons/:id: Update a coupon
  • DELETE /api/coupons/:id: Delete a coupon

Configuration

Make sure to set up your .env file with the correct configuration for your environment.

Contribution

If you would like to contribute to this project, please follow these steps:

  1. Fork the repository.
  2. Create a new branch.
  3. Make your changes.
  4. Submit a pull request.

Feel free to modify this README file to better suit your project's needs.