Skip to content

LEO20Debugger/ecommerce-api

Repository files navigation

Ecommerce API

NestJS-based ecommerce API with authentication and role-based access control.

Features

  • JWT Authentication
  • Role-based access (Admin, Seller, Buyer)
  • MySQL database with Drizzle ORM
  • Zod validation
  • Password hashing with bcrypt

Setup

  1. Install dependencies:
npm install
  1. Set up environment variables:
cp .env.example .env

Edit .env with your database credentials.

  1. Generate and run database migrations:
npm run db:generate
npm run db:migrate
  1. Start the development server:
npm run start:dev

API Endpoints

Authentication

  • POST /auth/register - Register new user
  • POST /auth/login - Login user
  • GET /auth/profile - Get user profile (protected)
  • GET /auth/admin-only - Admin only endpoint
  • GET /auth/seller-access - Seller/Admin endpoint

Example Requests

Register:

{
  "email": "user@example.com",
  "password": "password123",
  "firstName": "John",
  "lastName": "Doe",
  "role": "buyer"
}

Login:

{
  "email": "user@example.com",
  "password": "password123"
}

User Roles

  • admin - Full access
  • seller - Can manage products (future feature)
  • buyer - Can purchase products (future feature)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published