const router = require('express').Router();
const ctrl = require('../controllers/settings.controller');
const { authenticate, authorize } = require('../middlewares/auth');
const { validate } = require('../middlewares/validate');
const { settingsSchemas } = require('../validators');

router.use(authenticate);
router.use(authorize('admin'));

router.get('/', ctrl.getAll);
router.get('/:key', ctrl.getByKey);
router.put('/', validate({ body: settingsSchemas.upsert }), ctrl.upsert);
router.post('/bulk', validate({ body: settingsSchemas.bulkUpsert }), ctrl.bulkUpsert);

module.exports = router;
