E-Commerce API - Admin Only Documentation
E-Commerce API - Admin Only Documentation
Documentation
Overview
This document provides details on the admin-only endpoints available in the E-Commerce API.
These routes allow administrators to manage users, products, and orders within the platform. All
admin routes require authentication and authorization using a JWT token with admin privileges.
1. User Management
GET /api/users/all
Response:
[
{ /* user data */ },
{ /* user data */ }
]
PUT /api/users/:id/role
Request Body:
{
"role": "admin"
}
Response:
{
"message": "User role updated",
"user": { /* updated user data */ }
}
2. Product Management
POST /api/products
Request Body:
{
"name": "Product Name",
"price": 100,
"description": "Product Description"
}
Response:
{
"id": 1,
"name": "Product Name",
"price": 100,
"description": "Product Description"
}
PUT /api/products/:id
Request Body:
{
"name": "Updated Product Name",
"price": 120,
"description": "Updated Description"
}
Response:
{
"id": 1,
"name": "Updated Product Name",
"price": 120,
"description": "Updated Description"
}
DELETE /api/products/:id
Description: Deletes a product from the platform.
Response:
{
"message": "Product deleted"
}
3. Order Management
GET /api/orders
Response:
[
{ /* order data */ },
{ /* order data */ }
]
PUT /api/orders/:id
Request Body:
{
"status": "shipped"
}
Response:
{
"id": 1,
"userId": 1,
"totalAmount": 200,
"status": "shipped"
}
Middleware Used:
This document serves as a reference for administrators managing the e-commerce platform.
Ensure all API calls include the appropriate authentication headers.