Skip to content

πŸ”₯ E-Commerce Backend API in Node.js πŸ” JWT auth, role-based access, product browsing, and cart. πŸ’³ Cash & Stripe payments. βš™οΈ Advanced search, filtering, and pagination. πŸ”’ Security: validation, rate limiting, sanitization.

License

Notifications You must be signed in to change notification settings

Ahmad-Nour-Haidar/nodejs-ecommerce-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›οΈ E-Commerce Backend API πŸš€

This is a fully functional E-Commerce backend API built using Node.js, designed to handle a range of features such as user authentication, role-based access, product management, and order processing with cash and Stripe payment integration.

✨ Features

  • πŸ” User Authentication & Authorization:

    • JWT-based authentication.
    • Email verification using a verification code.
    • Role-based access control (Admin, Manager, User).
  • πŸ›οΈ Product & Category Browsing:

    • Browse products and categories without authentication.
    • Support for sub-categories.
  • πŸ›’ Shopping Cart:

    • Add products to the shopping cart for registered users.
  • πŸ“¦ Order Management:

    • Create and manage orders.
    • Support for discount coupons.
  • πŸ’³ Payment Integration:

    • Cash payments.
    • Stripe integration for card payments.
  • πŸ‘‘ Admin Features:

    • Manage users, products, categories, and orders.
    • Upload and manage product images.
  • πŸ”Ž Search & Filtering:

    • Advanced search functionality.
    • Filtering, sorting, pagination, and field limiting.
  • πŸ” Security:

    • Data validation.
    • Rate limiting to prevent abuse.
    • HTTP Parameter Pollution (HPP) protection.
    • Data sanitization against XSS and NoSQL injection.
  • ⚑ Performance Optimization:

    • Support for compression.
    • CORS enabled for cross-origin requests.

πŸ› οΈ Installation

  1. Clone the repository:

    git clone https://github.com/Ahmad-Nour-Haidar/nodejs-ecommerce-api.git
  2. Navigate to the project directory:

    cd nodejs-ecommerce-api
  3. Install dependencies:

    npm install
  4. Create a .env file in the root directory with the following:

    # Environment Variables
    
    # The port on which the server will run
    PORT=3000
    # Environment setting: 'development' or 'production'
    NODE_ENV=development
    #NODE_ENV=production
    
    # MongoDB credentials and connection details
    
    # Database username for MongoDB
    DB_USER=
    
    # Database password for MongoDB
    DB_PASSWORD=
    
    # Name of the database
    DB_NAME=nodejs-ecommerce-api
    
    # Base URL for the application
    BASE_URL=http://localhost:3000/
    
    # Local MongoDB connection URI
    MONGODB_URI=mongodb://127.0.0.1:27017/udemy-ecommerce
    
    # Remote MongoDB connection URI (Atlas Cluster)
    MONGODB_URI_REMOTE=
    
    # JWT (JSON Web Token) secret and expiration time
    
    # Secret key for signing JWTs
    JWT_SECRET_KEY=
    
    # Expiration time for JWTs
    JWT_EXPIRE_TIME=90d
    
    # Email Settings
    
    # Email used for sending emails
    EMAIL_USER=
    
    # Email account password (should be securely stored)
    EMAIL_PASSWORD=
    
    # "From" email address used when sending emails
    EMAIL=
    
    # SMTP host for sending emails
    EMAIL_HOST=smtp.gmail.com
    
    # SMTP port for secure email transmission
    EMAIL_PORT=465
    
    # Stripe Configuration
    
    # Stripe secret for payments
    STRIPE_SECRET=
    
    # Webhook secret for Stripe
    STRIPE_WEBHOOK_SECRET=
  5. Start the server:

    nodemon app.js

πŸŽ“ Course

This project is built as part of a training course on Udemy: E-Commerce Backend with Node.js

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

πŸ”₯ E-Commerce Backend API in Node.js πŸ” JWT auth, role-based access, product browsing, and cart. πŸ’³ Cash & Stripe payments. βš™οΈ Advanced search, filtering, and pagination. πŸ”’ Security: validation, rate limiting, sanitization.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published