List by shop API

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 ...

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.