const express = require('express');
const router = express.Router();
const ctrl = require('../controllers/purchaseController');
const { createRequirePage } = require('../../../shared/middleware/pagePermission');
const { getDb } = require('../dbPool');
const requirePage = createRequirePage(getDb);

router.get('/', ctrl.getAll);
router.post('/', requirePage('factory_purchases'), ctrl.create);
router.get('/price-history/:itemId', ctrl.getPriceHistory);

module.exports = router;
