renombrado nucleoClient y nucleoActions por whatsappCliente y whatsappActions
All checks were successful
Deploy conversation layer / deploy (push) Successful in 2m4s

This commit is contained in:
2025-06-06 23:06:59 -06:00
parent 781b4e809f
commit 0671cc9445
4 changed files with 73 additions and 73 deletions

View File

@@ -0,0 +1,44 @@
import { Application } from 'express';
import {
deleteConversation,
getConversation,
listConversations,
buildConversation,
} from '../store/conversation';
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 });
});
}