diff --git a/questionsservice/questiongeneratorservice/questiongenerator-service.js b/questionsservice/questiongeneratorservice/questiongenerator-service.js index c69d7548..5c485da8 100644 --- a/questionsservice/questiongeneratorservice/questiongenerator-service.js +++ b/questionsservice/questiongeneratorservice/questiongenerator-service.js @@ -48,7 +48,6 @@ function validateFields(query) { app.get('/questions', async (req, res) => { try { - const { preguntas, respuestas, temas } = validateFields(req.query); try { const retQuestions = await QuestionGenerator.generateQuestions(preguntas, respuestas, temas); @@ -79,6 +78,17 @@ app.get('/topics', async (req, res) => { } }); +// Route for getting topics for questions +app.get('/topics', async (req, res) => { + try { + const topics = QuestionGenerator.getAvailableTopics(); + res.send(topics); + } catch (error) { + console.error(`An error occurred: ${error.message}`); + res.status(500).json({ error: 'Internal Server Error' }); + } +}); + app.use((err, req, res, next) => { console.error(`An error occurred: ${err}`); res.status(500).send(`An error occurred: ${err.message}`); @@ -94,4 +104,4 @@ server.on('close', () => { mongoose.connection.close(); }); -module.exports = server +module.exports = server \ No newline at end of file