u
This commit is contained in:
10
README.md
10
README.md
@@ -147,8 +147,9 @@ Backend mapping:
|
||||
| `addImage` | `(googleAuthId, sku, imageBuffer)` | image result (see below) |
|
||||
| `deleteImage` | `(googleAuthId, sku, fullHash)` | `void` |
|
||||
| `orderImages` | `(googleAuthId, sku, { fullHashes })` | `{ fullHashes }` |
|
||||
| `delete` | `(googleAuthId, sku)` | `void` |
|
||||
|
||||
`addImage` accepts a full-size AVIF `Buffer`. Full image: if already AVIF and ≤1000×1000, stored as-is; otherwise scaled to max 1000×1000 (`pic.fullbinary`). Thumb always scaled to max 200×200 (`pic.thumbbinary`) via `sharp`. Computes `hash` / `thumbhash`, links `articlepic`. Auth like `getBySku`. Errors: `Article not found`, `Not authorized`.
|
||||
`addImage` accepts a full-size AVIF `Buffer`. Full image: if already AVIF and ≤1000×1000, stored as-is; otherwise scaled to max 1000×1000 (`pic.fullbinary`). Thumb always scaled to max 200×200 (`pic.thumbbinary`) via `sharp`. Assigns random `fullHash` (`pic.hash`, unique), computes `thumbhash`, links `articlepic`. Auth like `getBySku`. Errors: `Article not found`, `Not authorized`.
|
||||
|
||||
`addImage` returns:
|
||||
|
||||
@@ -158,7 +159,7 @@ Backend mapping:
|
||||
sort,
|
||||
full: { w, h, size }, // AVIF, max 1000×1000 (stored as-is when already AVIF and within bounds)
|
||||
thumb: { w, h }, // scaled AVIF, max 200×200 (fit inside)
|
||||
fullHash, // SHA-256 hex — use for GET /api/image/:fullHash and GET /api/thumb/:fullHash
|
||||
fullHash, // random 64-char hex id (pic.hash, unique)
|
||||
thumbHash, // base64 thumbhash of thumb preview
|
||||
}
|
||||
```
|
||||
@@ -192,11 +193,13 @@ Auth via the article's `categoryarticle` category + `resolveCategoryAccess`. Err
|
||||
|
||||
`orderImages` sets `articlepic.sort` to `0..n-1` in the given order. `fullHashes` must list every image of the article exactly once. Errors: `Article not found`, `Invalid image order`, `Not authorized`.
|
||||
|
||||
`delete` removes the article when it has no child articles (`fatherarticle_id` FK is `ON DELETE NO ACTION`). Cascades: `articlehistory`, `articleean`, `categoryarticle`, `price`, `articletext`, `articlelistarticle`, `optionslistarticle`, `articlepic`; deletes linked `pic` rows and owned `articlelist` / `optionslist`. `manifestarticle.article_id` is set to `NULL` and `comment` gets `article <name> deleted` appended. Errors: `Article not found`, `Article has children`, `Not authorized`.
|
||||
|
||||
---
|
||||
|
||||
## `pic`
|
||||
|
||||
Lookup by `pic.hash` (`fullHash` — SHA-256 hex from `addImage.fullHash`), not `thumbhash`.
|
||||
Lookup by `pic.hash` (`fullHash` from `addImage.fullHash`), not `thumbhash`. Random 64-char hex (`crypto.randomBytes(32)`), unique in DB.
|
||||
|
||||
| Method | Signature | Returns |
|
||||
| --- | --- | --- |
|
||||
@@ -234,6 +237,7 @@ res.set('Content-Type', thumb.contentType).send(thumb.buffer);
|
||||
| `POST /api/article` | `article.createUnderParent({ googleAuthId, parentId, name })` |
|
||||
| `GET /api/article/:sku` | `article.getBySku(googleAuthId, sku)` |
|
||||
| `PATCH /api/article/:sku` | `article.updateBySku(googleAuthId, sku, { name })` |
|
||||
| `DELETE /api/article/:sku` | `article.delete(googleAuthId, sku)` |
|
||||
| `POST /api/article/:sku/image` | `article.addImage(googleAuthId, sku, imageBuffer)` |
|
||||
| `DELETE /api/article/:sku/image/:fullHash` | `article.deleteImage(googleAuthId, sku, fullHash)` |
|
||||
| `PUT /api/article/:sku/images/order` | `article.orderImages(googleAuthId, sku, { fullHashes })` |
|
||||
|
||||
Reference in New Issue
Block a user