u
This commit is contained in:
64
docs/api/routes/category/_id/image/generate.md
Normal file
64
docs/api/routes/category/_id/image/generate.md
Normal file
@@ -0,0 +1,64 @@
|
||||
# `POST /category/{id}/image/generate`
|
||||
|
||||
Protected. Requires a valid session cookie (`credentials: 'include'`).
|
||||
|
||||
Generate category mosaic image from contents
|
||||
|
||||
Generates a 2x2, 3x3, or 4x4 mosaic image from the category's and its subcategories'
|
||||
articles (grouped by subcategory) and sets it as the new main picture for the category.
|
||||
If size is not specified, defaults to 3 (3x3), falling back to 2 (2x2) if fewer than 7 images are available.
|
||||
|
||||
|
||||
## Path parameters
|
||||
|
||||
| Param | Required | Type | Description |
|
||||
|-------|----------|------|-------------|
|
||||
| `id` | yes | integer | Category id |
|
||||
|
||||
## Body (JSON) — _optional_
|
||||
|
||||
| Field | Required | Type | Description |
|
||||
|-------|----------|------|-------------|
|
||||
| `size` | no | integer | Mosaic grid size (2 for 2x2, 3 for 3x3, 4 for 4x4). Defaults to 3x3 (or 2x2 if < 7 images). |
|
||||
|
||||
```json
|
||||
{
|
||||
"size": 1
|
||||
}
|
||||
```
|
||||
|
||||
## Signals
|
||||
|
||||
On success, emits SSE signal: `category` (see [`GET /events`](../events.md)).
|
||||
|
||||
## Response `200`
|
||||
|
||||
Mosaic image generated and linked as category main picture
|
||||
|
||||
```json
|
||||
{
|
||||
"category": {
|
||||
"id": 1,
|
||||
"fullHash": "…",
|
||||
"thumbW": 1,
|
||||
"thumbH": 1,
|
||||
"thumbHash": "…",
|
||||
"size": 1,
|
||||
"grid": "…",
|
||||
"articleCount": 1
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Errors
|
||||
|
||||
| Status | Description |
|
||||
|--------|-------------|
|
||||
| 400 | Invalid category ID or size — `{"error":"…"}` |
|
||||
| 401 | Unauthorized — `{"error":"…"}` |
|
||||
| 403 | Not authorized — `{"error":"…"}` |
|
||||
| 404 | Category not found or no article images found — `{"error":"…"}` |
|
||||
|
||||
---
|
||||
|
||||
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._
|
||||
Reference in New Issue
Block a user