import { Router } from 'express';
import {
  listCourses,
  getCourse,
  createCourse,
  updateCourse,
  deleteCourse,
  adminListCourses,
} from '../controllers/course.controller.js';
import { authenticate, requireAdmin, optionalAuth } from '../middleware/auth.middleware.js';

const router = Router();

router.get('/', listCourses);
router.get('/admin/all', authenticate, requireAdmin, adminListCourses);
router.get('/:slug', optionalAuth, getCourse);

router.post('/', authenticate, requireAdmin, createCourse);
router.patch('/:id', authenticate, requireAdmin, updateCourse);
router.delete('/:id', authenticate, requireAdmin, deleteCourse);

export default router;
