Expose getHistoryBySku as GET /article/:sku/history, and document mutation-emitted company signals via GET /events.
2.0 KiB
GET /events
Protected. Requires a valid session cookie (credentials: 'include').
Subscribe to update signals (SSE)
Opens a Server-Sent Events stream for the authenticated user's selected company. Clients receive named signals when another request successfully mutates shared data for that company (including the same browser's other tabs).
Use EventSource with credentials so the session cookie is sent:
const es = new EventSource('https://…/api/events', { withCredentials: true });
es.addEventListener('category', () => { refetchCategoryTree(); });
es.addEventListener('articles', () => { refetchArticleIndex(); });
es.addEventListener('article-42000045', () => { refetchArticle('42000045'); });
Keep-alive comments (: keepalive) are sent roughly every 25s.
Reconnect after changing the selected company (the stream is bound
to the company at connect time).
Signals
| Signal | Emitted after successful |
|---|---|
category |
POST /category, PATCH /category/{id}, PUT /category/order, DELETE /category/{id}, POST /category/{id}/image, DELETE /category/{id}/image |
articles |
POST /article, PATCH /article/{sku}, DELETE /article/{sku} |
article-<sku> |
PUT /article/{sku}/weight, PUT /article/{sku}/prices, PUT /article/{sku}/eans, PUT /article/{sku}/categories, PUT /article/{sku}/brand, PUT /article/{sku}/images/order, POST /article/{sku}/image, DELETE /article/{sku}/image/{fullHash} |
Signals are only sent when the mutation actually succeeds (2xx).
Failed or no-op validation errors do not emit. The article-<sku>
event name uses the concrete SKU (e.g. article-42000045).
Response 200
SSE stream (text/event-stream). Each signal is an SSE event
whose name is the signal id and whose data is {}.
Errors
| Status | Description |
|---|---|
| 400 | No company selected — {"error":"…"} |
| 401 | Unauthorized — {"error":"…"} |
Generated from @openapi JSDoc. Do not edit by hand — run npm run docs:api.