const express = require('express')
const router = express.Router()
const controller = require('../controllers/userManagement.controller')
const jwt = require('../../middlewares/authentication')
const apiKey = require('../../middlewares/apiKey')
const checkRole = require('../../middlewares/checkRole')

router.use(jwt, checkRole('admin'))

router.post('/', apiKey, jwt, (req, res) => {
    controller.create(req, res)
})

router.get('/', apiKey, jwt, (req, res) => {
    controller.index(req, res)
})

router.put('/:id', apiKey, jwt, (req, res) => {
    controller.update(req, res)
})

router.delete('/:id', apiKey, jwt, (req, res) => {
    controller.destroy(req, res)
})

router.patch('/:id/suspend', apiKey, jwt, (req, res) => {
    controller.suspend(req, res)
})

router.patch('/:id/unsuspend', apiKey, jwt, (req, res) => {
    controller.unsuspend(req, res)
})

module.exports = router