add api category brand and fix product

This commit is contained in:
2026-03-29 15:54:09 +03:00
parent 532f2ed8e8
commit 6b002edd34
10 changed files with 1450 additions and 32 deletions

View File

@@ -55,6 +55,7 @@ Query params:
- `attributes` as JSON string
- `tags` as JSON string array
- `featured`
- `sort`: `newest | oldest | price_asc | price_desc | popular | top_rated`
- `page`
- `limit`
@@ -65,12 +66,76 @@ Optional request header:
Example:
```http
GET /api/products?search=skf&featured=true&page=1&limit=20
GET /api/products?search=skf&featured=true&sort=price_asc&page=1&limit=20
x-product-type: Industrial
```
List response items are intentionally lightweight and include only fields needed for product cards / list pages. The `attributes` array is limited to the first 2 visible attributes, sorted by `displayOrder`.
### `GET /api/products/brands/:brandSlug`
Lists published products for one brand by brand slug.
Supports the same query params as `GET /api/products`:
- `search`
- `featured`
- `sort`
- `page`
- `limit`
Optional request header:
- `x-product-type`: `Industrial | Automotive`
### `GET /api/products/brands/:brandSlug/filters`
Returns available brand page filters relative to the selected brand and current query filters.
Response shape:
- `categories`: available categories with count
- `attributes`: available filterable attributes and their values with count
- `stock`: `inStock` and `outOfStock`
Optional request header:
- `x-product-type`: `Industrial | Automotive`
### `GET /api/products/categories/:categorySlug`
Lists published products for one category by category slug.
Supports the same query params as `GET /api/products`:
- `search`
- `featured`
- `sort`
- `page`
- `limit`
Optional request header:
- `x-product-type`: `Industrial | Automotive`
### `GET /api/products/categories/:categorySlug/filters`
Returns available category page filters relative to the selected category and current query filters.
Response shape:
- `brands`: available brands with count
- `attributes`: available filterable attributes and their values with count
- `stock`: `inStock` and `outOfStock`
Optional request header:
- `x-product-type`: `Industrial | Automotive`
### `GET /api/product/:slug`
Returns one published product by slug with category and up to 10 approved reviews.
### `GET /api/products/:id`
Returns one published product with category and up to 10 approved reviews.
@@ -117,6 +182,7 @@ Query params:
- `attributes` as JSON string
- `tags` as JSON string array
- `featured`
- `sort`: `newest | oldest | price_asc | price_desc | popular | top_rated`
- `page`
- `limit`