Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
Modified order
Browse files Browse the repository at this point in the history
  • Loading branch information
Tolfx committed Nov 27, 2021
1 parent 14abb5f commit 675d6e7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Routes/v2/Orders/Orders.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class OrderRoute
OrderController.list
]);

this.router.post("/place", EnsureAuth, async (req, res) => {
this.router.post("/place", EnsureAuth(), async (req, res) => {
// @ts-ignore
const customer_id = req.customer.id;
const products = req.body.products as Array<{
Expand All @@ -70,14 +70,15 @@ export default class OrderRoute
}>;
const payment_method = req.body.payment_method as keyof IPayments;


if(!customer_id || !products || !payment_method)
return APIError("Missing in body")(res);

if(!payment_method.match(/manual|bank|paypal|credit_card|swish/g))
return APIError("payment_method invalid")(res);

if(products.every(e => typeof e === "object"))
return APIError("products invalid")(res);
// if(products.every(e => typeof e === "object"))
// return APIError("products invalid")(res);

if(products.every(e => e.quantity <= 0))
return APIError("quantity invalid")(res);
Expand Down

0 comments on commit 675d6e7

Please sign in to comment.