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

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

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

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

router.get('/check-location', apiKey, jwt, (req, res) => {
    controller.checkLocation(req, res)
})

router.post('/clock-out', jwt, apiKey, (req, res) => {
    controller.clockOut(req, res)
})


module.exports = router