const router = require('express').Router();
const ctrl = require('../controllers/productController');
const { authenticate } = require('../middleware/auth');
const { authorizeMinRole } = require('../middleware/rbac');

router.use(authenticate);
router.get('/active', ctrl.getActive);
router.get('/categories', ctrl.getCategories);
router.get('/', ctrl.getAll);
router.get('/:id', ctrl.getById);
router.post('/', authorizeMinRole('admin'), ctrl.create);
router.put('/:id', authorizeMinRole('admin'), ctrl.update);
router.delete('/:id', authorizeMinRole('admin'), ctrl.remove);

module.exports = router;
