We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 80a8a10 commit f209d86Copy full SHA for f209d86
ams-express-shopping/service/orders.js
@@ -53,6 +53,11 @@ const createOrder = (req, res) => {
53
*/
54
55
const { productId, quantity } = req.body;
56
+ if (!Number.isInteger(productId) || productId < 0 ||
57
+ !Number.isInteger(quantity) || quantity <= 0) {
58
+ return res.status(400).json({ message: 'Invalid productId or quantity' });
59
+ }
60
+
61
const product = db.products.find(p => p.id === productId);
62
if (!product) {
63
return res.status(404).json({ message: 'Product not found' });
0 commit comments