const express = require('express');
const router = express.Router();

const { uploadCategory } = require('../config/cloudinaryUpload');

const { asyncHandler, authUser, authAdmin } = require('../auth/checkAuth');

const categoryController = require('../controller/category.controller');

router.post('/create', authAdmin, uploadCategory.single('image'), asyncHandler(categoryController.createCategory));
router.put('/update/:id', authAdmin, uploadCategory.single('image'), asyncHandler(categoryController.updateCategory));
router.delete('/delete/:id', authAdmin, asyncHandler(categoryController.deleteCategory));
router.get('/list', asyncHandler(categoryController.getAllCategory));

module.exports = router;
