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

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

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

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

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

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

module.exports = router