Implemented Forum

This commit is contained in:
Torsten Schulz
2024-10-24 11:22:40 +02:00
parent 663564aa96
commit f74a16e58e
8 changed files with 270 additions and 3 deletions

View File

@@ -58,6 +58,31 @@ const forumController = {
console.error('Error in createTopic:', error);
res.status(400).json({ error: error.message });
}
},
async getTopic(req, res) {
try {
const { userid: userId } = req.headers;
const { id: topicId } = req.params;
const topic = await forumService.getTopic(userId, topicId);
res.status(200).json(topic);
} catch (error) {
console.error('Error in getTopic:', error);
res.status(400).json({ error: error.message });
}
},
async addMessage(req, res) {
try {
const { userid: userId } = req.headers;
const { id: topicId } = req.params;
const { content } = req.body;
const result = await forumService.addMessage(userId, topicId, content);
res.status(201).json(result);
} catch (error) {
console.error('Error in addMessage:', error);
res.status(400).json({ error: error.message });
}
}
};