π E-Commerce API
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
- Clone the repository
git clone https://github.com/Glory42/E-Commerce-API.git
cd E-Commerce-API
- Install Dependencies
npm install
- 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
| Method | Endpoint | Description |
|---|---|---|
POST | /api/auth/register | Register a new user |
POST | /api/auth/login | Login and receive JWT |
GET | /api/products | Fetch all products |
GET | /api/products/:id | Fetch single product details |
POST | /api/cart | Add item to cart |
GET | /api/cart | View user cart |
POST | /api/orders | Place 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.
