import express from 'express';
import { Role } from '../declarations/roles';
import { customerController } from '../controller/customerController';
import SecurityUtil from '../utils/security/securityUtil';
import { userController } from '../controller/userController';

const router = express.Router();

router.get(
    '/',
    SecurityUtil.handleAuthorizeRoleMiddleware(Role.Employee),
    customerController.getCustomers.bind(customerController)
);
router.post(
    '/',
    SecurityUtil.handleAuthorizeRoleMiddleware(Role.Employee),
    customerController.createCustomer.bind(customerController)
);

router.get('/:id', customerController.getCustomer.bind(customerController));
router.put('/:id', customerController.updateCustomer.bind(customerController));
router.delete(
    '/:id',
    SecurityUtil.handleAuthorizeRoleMiddleware(Role.Employee),
    userController.removeUser.bind(userController)
);

export const customerRoutes = router;
