const express = require('express');
const router = express.Router();
const verifyToken = require('../middlewares/verifyToken');
const verifyAdmin = require('../middlewares/verifyAdmin');
const verifyAdminOrAuditor = require('../middlewares/verifyAdminOrAuditor');
const {
    getAllUsers,
    getUserById,
    createUser,
    updateUser,
    deleteUser,
    getUserLogs
} = require('../controllers/usersController');

// List users: Admin or Auditor (Auditor needs it for Create/Update Audit dropdowns)
router.get('/', verifyToken, verifyAdminOrAuditor, getAllUsers);
// User logs (users_logs; optional ?action=CREATED|UPDATED|DELETED&limit=&offset=)
router.get('/logs', verifyToken, verifyAdmin, getUserLogs);
router.get('/:id', verifyToken, getUserById);
router.post('/', verifyToken,verifyAdmin, createUser);
router.put('/:id', verifyToken, updateUser);
router.delete('/:id', verifyToken, deleteUser);

module.exports = router;

