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

const { isAdministratorUser, isLoggedUser } = require('../../middlewares/accessValidator');
/*const PaginateMiddleware = require('../../middlewares/paginate');
const FieldMiddleware = require('../../middlewares/fields');*/
const SortMiddleware = require('../../middlewares/sort');

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

/********************************************************************************************************
*  ADMINISTRACIÓN
*********************************************************************************************************
*/

routes.get('/admin/categories', 
    isAdministratorUser, 
    SortMiddleware.middleware({ default: "sort" }), 
    categoryController.find()
);

routes.get('/admin/categories/:id', 
    isAdministratorUser, 
    categoryController.findOne()
);

routes.post('/admin/categories', 
    isAdministratorUser, 
    categoryController.create()
);

routes.put('/admin/categories/:id', 
    isAdministratorUser, 
    categoryController.update()
);

routes.delete('/admin/categories/:id', 
    isAdministratorUser, 
    categoryController.delete()
);

module.exports = routes;