This commit is contained in:
seb
2026-09-30 22:37:34 +02:00
parent 71c92e0718
commit 120e59631e
16 changed files with 137 additions and 35 deletions

View File

@@ -15,6 +15,7 @@ function orderErrorStatus(error) {
if (error.message === 'Order not found') return 404;
if (error.message === 'Entity not found') return 404;
if (error.message === 'Article not found') return 404;
if (error.message === 'Invalid entityId') return 400;
if (error.message === 'Invalid order') return 400;
if (error.message === 'Invalid lines') return 400;
return 500;
@@ -176,6 +177,9 @@ export function register(app, basePath = '') {
}
const { number, date, createdAt, entityId, lines } = req.body ?? {};
if (entityId !== undefined && entityId !== null && (typeof entityId !== 'number' || !Number.isInteger(entityId) || entityId <= 0)) {
return res.status(400).json({ error: 'Invalid entityId' });
}
try {
const order = await db.create(req.user.id, {
@@ -401,6 +405,9 @@ export function register(app, basePath = '') {
patch.createdAt = body.createdAt;
}
if (Object.prototype.hasOwnProperty.call(body, 'entityId')) {
if (body.entityId !== null && (typeof body.entityId !== 'number' || !Number.isInteger(body.entityId) || body.entityId <= 0)) {
return res.status(400).json({ error: 'Invalid entityId' });
}
patch.entityId = body.entityId;
}
if (Object.prototype.hasOwnProperty.call(body, 'lines')) {