import { Router } from 'express';
import {
  getUserNotifications,
  getUnreadCount,
  markAsRead,
  markAllAsRead,
  deleteNotification,
} from '../controllers/notificationController';
import { authenticate } from '../middlewares/auth';
import { authGeneralRateLimiter } from '../middlewares/authRateLimiter';

const router = Router();

// Apply authentication to all notification routes
router.use(authenticate);

// Apply rate limiting to notification routes
router.use(authGeneralRateLimiter);

/**
 * @route GET /api/notifications
 * @desc Get notifications for the authenticated user
 * @access Private
 */
router.get('/', getUserNotifications);

/**
 * @route GET /api/notifications/unread-count
 * @desc Get unread notifications count
 * @access Private
 */
router.get('/unread-count', getUnreadCount);

/**
 * @route PUT /api/notifications/:id/read
 * @desc Mark a specific notification as read
 * @access Private
 */
router.put('/:id/read', markAsRead);

/**
 * @route PUT /api/notifications/mark-all-read
 * @desc Mark all notifications as read for the authenticated user
 * @access Private
 */
router.put('/mark-all-read', markAllAsRead);

/**
 * @route DELETE /api/notifications/:id
 * @desc Delete a notification
 * @access Private
 */
router.delete('/:id', deleteNotification);

export default router;
