added get specific user API route
This commit is contained in:
@@ -20,5 +20,25 @@ router.get('/', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.get('/:id', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const userId = req.params.id;
|
||||||
|
const result = await pool.query('SELECT * FROM view_member_rank_status_all WHERE id = $1;', [userId]);
|
||||||
|
if (result.rows.length === 0) {
|
||||||
|
return res.status(404).json({ error: 'User not found' });
|
||||||
|
}
|
||||||
|
return res.status(200).json(result.rows[0]);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching user:', err);
|
||||||
|
return res.status(500).json({ error: 'Failed to fetch user' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//update a user's display name (stub)
|
||||||
|
router.put('/:id/displayname', async (req, res) => {
|
||||||
|
// Stub: not implemented yet
|
||||||
|
return res.status(501).json({ error: 'Update display name not implemented' });
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ const router = createRouter({
|
|||||||
{ path: '/members', component: MemberList},
|
{ path: '/members', component: MemberList},
|
||||||
{ path: '/loa', component: LOA}
|
{ path: '/loa', component: LOA}
|
||||||
]
|
]
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
|||||||
Reference in New Issue
Block a user