import { Router } from 'express';
import { conclusionController } from '@controllers/conclusion.controller';
import { authenticateToken } from '../middlewares/auth.middleware';
import { aiLimiter } from '../middlewares/rateLimiter.middleware';

const router = Router();

// All routes require authentication
router.use(authenticateToken);

/**
 * @route   POST /api/v1/conclusions/:requestId/generate
 * @desc    Generate AI-powered conclusion remark
 * @access  Private (Initiator only)
 */
router.post('/:requestId/generate', aiLimiter, (req, res) =>
  conclusionController.generateConclusion(req, res)
);

/**
 * @route   PUT /api/v1/conclusions/:requestId
 * @desc    Update conclusion remark (edit by initiator)
 * @access  Private (Initiator only)
 */
router.put('/:requestId', (req, res) =>
  conclusionController.updateConclusion(req, res)
);

/**
 * @route   POST /api/v1/conclusions/:requestId/finalize
 * @desc    Finalize conclusion and close request
 * @access  Private (Initiator only)
 */
router.post('/:requestId/finalize', (req, res) =>
  conclusionController.finalizeConclusion(req, res)
);

/**
 * @route   GET /api/v1/conclusions/:requestId
 * @desc    Get conclusion for a request
 * @access  Private
 */
router.get('/:requestId', (req, res) =>
  conclusionController.getConclusion(req, res)
);

export default router;

