import express from 'express';
import { projectRoutes } from './projectRoutes';
import { statsRoutes } from './statsRoutes';
import { customerRoutes } from './customerRoutes';
import { employeeRoutes } from './employeeRoutes';
import { authRoutes } from './authRoutes';
import { userRoutes } from './userRoutes';
import SecurityUtil from '../utils/security/securityUtil';
import { Role } from '../declarations/roles';

const router = express.Router();

router.use(
    '/projects',
    SecurityUtil.handleAuthenticateMiddleware(),
    projectRoutes
);
router.use(
    '/customers',
    SecurityUtil.handleAuthenticateMiddleware(),
    customerRoutes
);
router.use(
    '/employees',
    SecurityUtil.handleAuthenticateMiddleware(),
    SecurityUtil.handleAuthorizeRoleMiddleware(Role.Employee),
    employeeRoutes
);
router.use(
    '/stats',
    SecurityUtil.handleAuthenticateMiddleware(),
    SecurityUtil.handleAuthorizeRoleMiddleware(Role.Employee),
    statsRoutes
);
router.use('/auth', authRoutes);

export const indexRoutes = router;
