auto(agent): Add validation and tests for contacts route

This commit is contained in:
OpenClaw 2026-03-06 19:28:45 +00:00
parent 7b5ffa06be
commit 254f71e98f
2 changed files with 24 additions and 0 deletions

View file

@ -147,4 +147,19 @@ router.get('/deal/:dealId', requireAuth, async (req, res) => {
}
});
// Add validation for GET /contacts
router.get('/', requireAuth, async (req, res) => {
try {
const [rows] = await pool.query(
`SELECT id, name, email, phone_encrypted FROM contacts WHERE user_id = ?`,
[req.user.userId]
);
res.json(rows);
} catch (error) {
console.error('Error in contacts get route:', error);
res.status(500).json({ error: 'Internal server error' });
}
});
export default router;