Skip to content

Latest commit

 

History

History
65 lines (49 loc) · 1.71 KB

File metadata and controls

65 lines (49 loc) · 1.71 KB

E-commerce API

A RESTful E-commerce API built with Node.js, Express, Prisma ORM, and JWT authentication.
The API supports user authentication, role-based authorization, product management, and order processing with inventory control.


🚀 Features

  • User registration and login with JWT authentication
  • Role-based access control (ADMIN / CUSTOMER)
  • Product CRUD operations (Admin only)
  • Order creation with stock deduction
  • Secure password hashing using bcrypt
  • Input validation with Joi

🛠 Tech Stack

  • Node.js
  • Express.js
  • Prisma ORM
  • JWT (JSON Web Tokens)
  • bcrypt
  • Joi
  • PostgreSQL (via Prisma)

📌 API Endpoints

Authentication

Method Endpoint Description
POST /auth/signup Create a new user
POST /auth/login Login and receive JWT

Users

Method Endpoint Access Description
GET /users/:id ADMIN / CUSTOMER Retrieve user by ID

Products

Method Endpoint Access Description
GET /products Public Get all products
POST /products ADMIN Create a product
PATCH /products/:id ADMIN Update a product
DELETE /products/:id ADMIN Delete a product

Orders

Method Endpoint Access Description
POST /orders ADMIN / CUSTOMER Place an order
GET /orders/:id ADMIN / CUSTOMER Get order by ID

🔐 Authentication & Authorization

  • JWT is required for protected routes
  • Include token in request headers:
Authorization: Bearer <your_token>