const express = require('express');
const {
  getAll,
  getById,
  create,
  update,
  remove,
  adjustStock,
} = require('../controllers/productController');
const { authenticateToken, authorizeRoles } = require('../middleware/auth');

const router = express.Router();

router.use(authenticateToken);

router.get('/', getAll);
router.get('/:id', getById);
router.post('/', authorizeRoles('admin', 'manager'), create);
router.put('/:id', authorizeRoles('admin', 'manager'), update);
router.delete('/:id', authorizeRoles('admin'), remove);
router.post('/:id/stock', authorizeRoles('admin', 'manager', 'staff'), adjustStock);

module.exports = router;
