u
This commit is contained in:
@@ -62,6 +62,7 @@ function articleErrorStatus(error) {
|
|||||||
if (error.message === 'Brand not found') return 404;
|
if (error.message === 'Brand not found') return 404;
|
||||||
if (error.message === 'Invalid weight') return 400;
|
if (error.message === 'Invalid weight') return 400;
|
||||||
if (error.message === 'Invalid categoryIds') return 400;
|
if (error.message === 'Invalid categoryIds') return 400;
|
||||||
|
if (error.message?.includes('already exists') || error.code === 'SQLITE_CONSTRAINT_UNIQUE') return 409;
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,6 +133,12 @@ export function register(app, basePath = '') {
|
|||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: '#/components/schemas/Error'
|
* $ref: '#/components/schemas/Error'
|
||||||
|
* 409:
|
||||||
|
* description: SKU already exists
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* $ref: '#/components/schemas/Error'
|
||||||
*/
|
*/
|
||||||
app.post(`${basePath}/article`, async (req, res) => {
|
app.post(`${basePath}/article`, async (req, res) => {
|
||||||
const parent = parsePositiveInt(req.body?.parentId, 'parentId');
|
const parent = parsePositiveInt(req.body?.parentId, 'parentId');
|
||||||
|
|||||||
Reference in New Issue
Block a user