Skip to content

Latest commit

 

History

History
88 lines (63 loc) · 2.37 KB

README.md

File metadata and controls

88 lines (63 loc) · 2.37 KB

E-Cart Backend

This is the backend server for the E-Cart e-commerce application. It provides the API endpoints and handles database operations for the application.

Table of Contents

Getting Started

Follow these steps to set up the backend server locally on your machine.

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js and npm (Node Package Manager) or yarn
  • MongoDB (Make sure it's running locally or adjust the MONGODB_URI in the .env file accordingly)

Installation

  1. Clone the repository:

    git clone https://github.com/sailesh307/e-cart.git
  2. Navigate to the backend directory:

    cd backend
  3. Install the dependencies:

    yarn install
  4. Create a .env file in the root directory and add the following environment variables:

    MONGODB_URI=<your-mongodb-uri>
    JWT_SECRET=<your-jwt-secret>

    example:

     MONGODB_URI=mongodb://localhost:27017/e-cart
     JWT_SECRET=secret

    Note: The JWT_SECRET can be any string of your choice.

  5. Start the server:

     yarn start

    The server should now be running on http://localhost:5000.

API Endpoints

  • api/users : User-related endpoints

    • POST /api/users/register: Register a new user
    • POST /api/users/login: Login an existing user
    • GET /api/users/profile: Get the profile of the currently logged in user
  • api/products : Product-related endpoints

    • GET /api/products: Get all products on search
    • GET /api/products/id/:id: Get a product detail by id
    • POST /api/products: Create new products
    • PUT /api/products/id/:id: Update a product by id
    • DELETE /api/products/id/:id: Delete a product by id
  • api/cart : Cart-related endpoints

    • GET /api/cart: Get the cart of the currently logged in user
    • DELETE /api/cart/:id: Delete an item from the cart
    • PUT /api/cart/:id: Update an item in cart of the currently logged in user

Contributing

Contributions are welcome! Feel free to open issues or pull requests for any improvements or features you'd like to add.

License