u
This commit is contained in:
@@ -15,6 +15,7 @@ function quoteErrorStatus(error) {
|
||||
if (error.message === 'Quote 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 quote') 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 quote = 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')) {
|
||||
|
||||
Reference in New Issue
Block a user