Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ export const database = {

createOrder({ spotId, userId, items }) {
const parsedItems = items.map((item) => {
if ('name' in item || 'unitPrice' in item || 'total' in item) {
throw new Error('Do not provide name, unitPrice, or total. These are derived from catalog. ')
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
const quantity = Number(item.quantity || 0);
if (!item.productId || !Number.isInteger(quantity) || quantity <= 0) {
throw new Error('Each order item must include productId and a positive integer quantity');
Expand Down