Background

πŸš€ E-Commerce API

TypeScript Express.js Supabase Node.js License

A robust backend REST API for online stores, built with Express.js and TypeScript. This system leverages Supabase for database management and handles secure authentication via JWT, product inventory, shopping carts, and order processing.

Note: Payment integration is currently a work in progress.


πŸ“‘ Table of Contents


✨ Features

  • πŸ” Authentication: Secure user registration and login using JWT (JSON Web Tokens).
  • 🏷️ Product Management: CRUD operations for managing inventory and product details.
  • πŸ›’ Shopping Cart: Add, remove, and view items in the user's cart.
  • πŸ“¦ Order Processing: Create and manage customer orders.
  • πŸ’³ Payment Integration: [In Progress] Integration for handling transactions.
  • πŸ›‘οΈ Middleware Protection: Role-based access control and input validation.

πŸ›  Tech Stack

  • Runtime: Node.js
  • Framework: Express.js
  • Language: TypeScript
  • Database: Supabase (PostgreSQL)
  • Authentication: JWT & Supabase Auth

πŸ“‚ Folder Structure

E-Commerce-API/
β”œβ”€β”€ config/         # Database and environment configuration
β”œβ”€β”€ controllers/    # Request handlers for the API routes
β”œβ”€β”€ middlewares/    # Auth and validation middlewares
β”œβ”€β”€ models/         # Data models and schemas
β”œβ”€β”€ routes/         # API route definitions
β”œβ”€β”€ types/          # TypeScript type definitions
β”œβ”€β”€ utils/          # Helper functions and utilities
β”œβ”€β”€ server.ts       # Entry point of the application
└── ...

Getting Started

Prerequisites

Installation

  1. Clone the repository
    git clone https://github.com/Glory42/E-Commerce-API.git
    cd E-Commerce-API
  1. Install Dependencies
    npm install
  1. Run the server
    # Development mode
    npm run dev

    # Build and start
    npm run build
    npm start

Environment Variables

Create a .env file in the root directory and add the following variables:

PORT=3000
SUPABASE_URL=your_supabase_project_url
SUPABASE_KEY=your_supabase_anon_key
JWT_SECRET=your_jwt_secret_key

API Endpoints

MethodEndpointDescription
POST/api/auth/registerRegister a new user
POST/api/auth/loginLogin and receive JWT
GET/api/productsFetch all products
GET/api/products/:idFetch single product details
POST/api/cartAdd item to cart
GET/api/cartView user cart
POST/api/ordersPlace a new order

License

This project is licensed under the MIT License.
See the LICENSE file for more information.

Contact

If you have any questions, feel free to reach out to me at me@gorkemkaryol.dev.