API Docs

Base URL:

Auth

POST/api/auth/register
Headers
Content-Type: application/json
Body
{
  "name": "Ahmed",
  "email": "ahmed@test.com",
  "password": "123456"
}
Response
{
  "token": "eyJhbGciOi...",
  "user": { "id": "a438...", "name": "Ahmed", "email": "ahmed@test.com", "createdAt": "..." }
}
POST/api/auth/login
Headers
Content-Type: application/json
Body
{
  "email": "ahmed@test.com",
  "password": "123456"
}
Response
{
  "token": "eyJhbGciOi...",
  "user": { "id": "a438...", "name": "Ahmed", "email": "ahmed@test.com", "createdAt": "..." }
}

User

GET/api/users/me
Headers
Authorization: Bearer TOKEN
Response
{ "id": "a438...", "name": "Ahmed", "email": "ahmed@test.com", "createdAt": "..." }

Products

GET/api/products
Response
[
  {
    "id": "c1b1...",
    "title": "Phone",
    "price": 500,
    "description": "...",
    "image": "https://...",
    "category": "mobiles",
    "createdAt": "..."
  }
]
GET/api/products/:id
Response
{ "id": "c1b1...", "title": "Phone", "price": 500, "description": "...", "image": "...", "category": "mobiles", ... }
POST/api/products
Headers
Content-Type: application/json
Body
{
  "title": "Phone",          // required
  "price": 500,              // required
  "description": "...",
  "image": "https://...",
  "category": "mobiles"
}
Response
{ "id": "c1b1...", "title": "Phone", "price": 500, ... }
PUT/api/products/:id
Headers
Content-Type: application/json
Body
{
  "title": "Phone",
  "price": 450
}
Response
{ "id": "c1b1...", "title": "Phone", "price": 450, ..., "updatedAt": "..." }
DELETE/api/products/:id
Response
{ "message": "تم الحذف", "product": { ... } }