diff --git a/src/api/routes/article.js b/src/api/routes/article.js index dfe04cf..8900406 100644 --- a/src/api/routes/article.js +++ b/src/api/routes/article.js @@ -62,6 +62,7 @@ function articleErrorStatus(error) { if (error.message === 'Brand not found') return 404; if (error.message === 'Invalid weight') return 400; if (error.message === 'Invalid categoryIds') return 400; + if (error.message?.includes('already exists') || error.code === 'SQLITE_CONSTRAINT_UNIQUE') return 409; return 500; } @@ -132,6 +133,12 @@ export function register(app, basePath = '') { * application/json: * schema: * $ref: '#/components/schemas/Error' + * 409: + * description: SKU already exists + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/Error' */ app.post(`${basePath}/article`, async (req, res) => { const parent = parsePositiveInt(req.body?.parentId, 'parentId');