Skip to content

alin00r/Node.js-Full-E-Commerce-RESTFul-Api-with-Payment

Repository files navigation

E-shtery-app

Node.js-Full-E-Commerce-RESTFul-API-with- Cash and Online Payment

Technologies

JavaScript NodeJS Express.js JWT Nodemon NPM MONGODB MONGOOSE stripe dotenv swagger eslint prettier


Key Features:

  • User Authentication: Secure user authentication endpoints using JWT tokens.
  • Category Management: Create, retrieve, update, and delete categories for organizing products.
  • Subcategory Management: Manage subcategories to further refine product classifications.
  • Brand Management: Maintain brands for product attribution and categorization.
  • Product Management: Comprehensive CRUD operations for products, including creation, retrieval, updating, and deletion.
  • User Management: Manage user accounts, including registration, authentication, and profile updates.
  • Review System: Enable users to leave reviews for products, with options for retrieval and moderation.
  • Wishlist Functionality: Allow users to create and manage wishlists for future purchases.
  • Address Management: Facilitate the management of user addresses for accurate shipping and billing information.
  • Coupon Management: Implement coupon functionality for discounts on products or orders.
  • Shopping Cart: Provide users with a shopping cart feature to collect and manage selected items before checkout.
  • Order Processing: Enable users to place and track orders, with functionalities for order creation, retrieval, and status updates.
  • Payment Integration: Support both online payment methods and cash on delivery options for seamless transaction processing.
  • API Documentation: Integrated Swagger UI for easy access to API documentation, enhancing development and collaboration processes.
  • Middleware Mounting: Modular function for mounting routes and middleware onto the Express application instance, ensuring proper registration and accessibility.
  • Scalability: Modular structure and organization of routes facilitate scalability, allowing for the addition of new features or endpoints in a structured and manageable manner.

Installation

  1. Clone the Repository: Use the git clone command to clone the GitHub repository to your local machine.

    git clone https://github.com/alin00r/Node.js-Full-E-Commerce-RESTFul-App-with-Payment
  2. Initialize a Package.json File (if not already done): If your project doesn't already have a package.json file, you can create one by running:

    npm init
    # or
    yarn init
  3. Install depends

       npm install
  4. Setting up env variables

    • Please first specifiy your database engine
    ## PORT
    PORT=YOUR PORT HERE
    
    ## MongoDB URI
    DB_URI= YOUR DATABASE URI
    
    ## JWT access token
    JWT_SECRET_KEY=YOUR JWT ACCESS TOKEN SECRET
    JWT_EXPIRE_TIME=YOUR JWT EXPIRE TIME
    
    ## GMAIL
    MAILER_APP_EMAIL=SENDER EMAIL
    MAILER_APP_PASSWORD=SENDER PASSWORD
    
    ## STRIPE
    STRIPE_SECRET=Your STRIPE SECRET KEY
    STRIPE_WEBHOOK_SECRET=Your STRIPE WEBHOOK SECRET KEY
    

Routes

Auth Routes

@access Public

Route Path Description Body Params
POST /api/v1/signup Create Account name,email password, passwordConfirm none
POST /api/v1/login Login with exist user email,password none
POST /api/v1/forgotPassword request code to reset your password email none
POST /api/v1/verifyResetCode verify Reset Code resetCode, none
PUT /api/v1/resetPassword Reset your new password email, newPassword none

Categories Routes

@access Admin

Route Path Description Body Params
POST /api/v1/categories Create Category name,image none
GET /api/v1/categories Get All Categories none none
GET /api/v1/categories/:id Get Category with id none Category Id
PATCH /api/v1/categories/:id Update Category with id none Category Id
DELETE /api/v1/categories/:id Delete Category with id none Category Id

SubCategories Routes

@access Admin

Route Path Description Body Params
POST /api/v1/Subcategories Create SubCategory name,image none
GET /api/v1/Subcategories Get All SubCategories none none
GET /api/v1/Subcategories/:id Get SubCategory with id none SubCategory Id
PATCH /api/v1/Subcategories/:id Update SubCategory with id none SubCategory Id
DELETE /api/v1/Subcategories/:id Delete SubCategory with id none SubCategory Id

Brands Routes

@access Admin

Route Path Description Body Params
POST /api/v1/brands Create brand name,image none
GET /api/v1/brands Get All brands none none
GET /api/v1/brands/:id Get brand with id none brand Id
PATCH /api/v1/brands/:id Update brand with id name,image brand Id
DELETE /api/v1/brands/:id Delete brand with id none brand Id

Categories/Subs

@access Admin

Route Path Description Body Params
GET /api/v1/categories/:categoryId/subcategories Get list of subcategories for specific category none categoryId
POST /api/v1/categories/:categoryId/subcategories Create subcategory on category name,image categoryId

Products Routes

@access Admin

Route Path Description Body Params
POST /api/v1/products Create Product title,slug,quantity, none
sold,price,priceAfterDiscount,
description,category,imageCover,
ratingsAverage,ratingsQuantity,subcategories
GET /api/v1/products/:id Get Product with id none Product Id
PATCH /api/v1/products/:id Update Product with id title,slug,quantity, Product Id
sold,price,priceAfterDiscount, none
description,category,imageCover,
ratingsAverage,ratingsQuantity,subcategories
DELETE /api/v1/products/:id Delete Product with id none Product Id
  • ENUMS
    This schema defines two enums:
  1. Role: Represents the role of a user with two possible values:
  • USER: Indicates a regular user.
  • ADMIN: Indicates an administrator user.
  • MANAGER: Indicates an administrator user but he can't delete anything on the server.

to browse all routes see Api Rutes on Swagger

Swagger Docs

https://app.swaggerhub.com/apis-docs/ALINOORSPAM/Eshtery/1.0.0

© Ali Nour