const express = require('express'); const router = express.Router(); const questionController = require('../controllers/question.controller'); const { optionalAuth } = require('../middleware/auth.middleware'); /** * @route GET /api/questions/search * @desc Search questions using full-text search * @access Public (with optional auth for more questions) * @query q - Search query (required) * @query category - Filter by category UUID (optional) * @query difficulty - Filter by difficulty (easy, medium, hard) (optional) * @query limit - Number of results per page (default: 20, max: 100) * @query page - Page number (default: 1) */ router.get('/search', optionalAuth, questionController.searchQuestions); /** * @route GET /api/questions/category/:categoryId * @desc Get questions by category with filtering * @access Public (with optional auth for more questions) * @query difficulty - Filter by difficulty (easy, medium, hard) * @query limit - Number of questions to return (default: 10, max: 50) * @query random - Boolean to randomize questions (default: false) */ router.get('/category/:categoryId', optionalAuth, questionController.getQuestionsByCategory); /** * @route GET /api/questions/:id * @desc Get single question by ID * @access Public (with optional auth for auth-only questions) */ router.get('/:id', optionalAuth, questionController.getQuestionById); module.exports = router;