Wire store-backed CRUD for goods receipts and suppliers, and teach the API doc generator to expand $ref/allOf/array samples so route markdown shows full JSON shapes.
1.2 KiB
1.2 KiB
POST /category/{id}/image
Protected. Requires a valid session cookie (credentials: 'include').
Add category image
Accepts a full-size AVIF body (Content-Type: image/avif).
Full: stored as-is when already AVIF and ≤1000×1000; otherwise scaled to max 1000×1000.
Thumb always scaled to max 200×200. Stores hash/thumbhash, links categorypic.
Auth like GET /category/tree — user must be authorized for the category's company.
Path parameters
| Param | Required | Type | Description |
|---|---|---|---|
id |
yes | integer | Category id |
Body
Raw binary (image/avif).
Signals
On success, emits SSE signal: category (see GET /events).
Response 201
Image stored and linked
{
"category": {
"id": 1,
"thumbW": 1,
"thumbH": 1,
"thumbHash": "…"
}
}
Errors
| Status | Description |
|---|---|
| 400 | Missing body or invalid image — {"error":"…"} |
| 401 | Unauthorized — {"error":"…"} |
| 403 | Not authorized — {"error":"…"} |
| 404 | Category not found — {"error":"…"} |
Generated from @openapi JSDoc. Do not edit by hand — run npm run docs:api.