import { Router } from 'express';
import { getAll, getById, create } from '../controllers/purchaseController.js';
import { protect } from '../middlewares/auth.js';
import { authorize } from '../middlewares/authorize.js';
import { ACTIONS } from '../utils/permissions.js';
import { createPurchaseValidator } from '../validators/purchaseValidator.js';
import { handleValidation } from '../utils/handleValidation.js';

const router = Router();

router.get('/', protect, getAll);
router.get('/:id', protect, getById);
router.post('/', protect, authorize(ACTIONS.PURCHASE_MANAGE), createPurchaseValidator, handleValidation, create);

export default router;
