We will implement an API to get orders for a specific shop, so authenticated sellers can view orders for each of their shops. The request for this API will be received at '/api/orders/shop/:shopId, with the route defined in order.routes.js as follows.
mern-marketplace/server/routes/order.routes.js:
router.route('/api/orders/shop/:shopId') .get(authCtrl.requireSignin, shopCtrl.isOwner, orderCtrl.listByShop)router.param('shopId', shopCtrl.shopByID)
To retrieve the shop associated with the :shopId parameter in the route, we will use the shopByID shop controller method, which gets the shop from the Shop collection and attaches it to the request object to be accessed by the next methods.
The listByShop controller method will ...