So we are trying to build a website and we have different routes but they have somewhat same functioning
So say:
- for recomended products
localhost:3000/products/veg/rec
localhost:3000/products/fruits/rec - for viewing all products
localhost:3000/products/veg
localhost:3000/products/fruits - for viewing single product
localhost:3000/products/veg/:id
localhost:3000/products/fruits/:id
for should i make separate controller for each route or should i try to combine the few of them?
and what might be the reason to choose one above another?
// I have a controller
const getAllProducts = () =>{} // for both fruits and vegetables but it feels messy to use
const getProduct = () => {} // to get a single product (both fruits and veg)..
const getProductsRecomended = () => {} // to get the recomended products (both fruits and veg)..
// tho i have these controller it's confusing to manage the logic and the routes properly