Create Product
Create a new product with image upload support. Requires admin authentication.Authentication
Requires Clerk authentication with admin role. All admin routes are protected byprotectRoute and adminOnly middleware.
Request
Content-Type:multipart/form-data
Product name
Product description
Product price (must be >= 0)
Available stock quantity (must be >= 0)
Product category
Product images (1-3 files). Uploaded to Cloudinary in the
products folder.Response
Success message
The created product object
MongoDB ObjectId
Product name
Product description
Product price
Available stock
Product category
Array of Cloudinary image URLs
Average rating (0-5, default: 0)
Total number of reviews (default: 0)
ISO 8601 timestamp
ISO 8601 timestamp
Get All Products
Retrieve all products sorted by creation date (newest first). Requires admin authentication.Authentication
Requires Clerk authentication with admin role.Response
Array of product objects sorted by
createdAt descendingUpdate Product
Update an existing product. All fields are optional. Supports image upload.Authentication
Requires Clerk authentication with admin role.Path Parameters
MongoDB ObjectId of the product to update
Request
Content-Type:multipart/form-data
Updated product name
Updated product description
Updated product price
Updated stock quantity
Updated product category
New product images (1-3 files). If provided, replaces all existing images.
Response
Success message
The updated product object
Delete Product
Delete a product and remove its images from Cloudinary.Authentication
Requires Clerk authentication with admin role.Path Parameters
MongoDB ObjectId of the product to delete
Response
Success message