Add debug logging for conversation routes and store

This commit is contained in:
josedario87
2025-06-05 13:58:54 -06:00
parent e135868cb7
commit 84798a014f
2 changed files with 12 additions and 0 deletions

View File

@@ -8,30 +8,36 @@ import {
export function registerConversationRoutes(app: Application, openWaUrl: string | undefined) {
app.get('/conversations', (req, res) => {
console.log('[routes] GET /conversations');
res.json({ conversations: listConversations() });
});
app.get('/conversations/:id', async (req, res) => {
console.log(`[routes] GET /conversations/${req.params.id}`);
if (!openWaUrl) return res.status(500).json({ error: 'Service URLs not configured' });
try {
const conv = await getConversation(req.params.id, openWaUrl);
res.json(conv);
} catch (err: any) {
console.error('Failed to get conversation:', err.message);
res.status(500).json({ error: err.message });
}
});
app.post('/conversations/:id/update', async (req, res) => {
console.log(`[routes] POST /conversations/${req.params.id}/update`);
if (!openWaUrl) return res.status(500).json({ error: 'Service URLs not configured' });
try {
const conv = await buildConversation(req.params.id, openWaUrl);
res.json(conv);
} catch (err: any) {
console.error('Failed to update conversation:', err.message);
res.status(500).json({ error: err.message });
}
});
app.delete('/conversations/:id', (req, res) => {
console.log(`[routes] DELETE /conversations/${req.params.id}`);
const deleted = deleteConversation(req.params.id);
res.json({ success: deleted });
});