MCPcopy Create free account
hub / github.com/Muhammadsiddiq-code/backend-group-lessons / getUserById

Function getUserById

controller/userController.js:279–292  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

277
278// Get user by ID
279const getUserById = async (req, res) => {
280 try {
281 const userId = req.params.id;
282 const user = await User.findById(userId).populate("product_id");
283
284 if (!user) {
285 return res.status(404).json({ message: "User not found" });
286 }
287 res.status(200).json({ message: "User found", user });
288 } catch (error) {
289 console.error(error);
290 res.status(500).json({ message: "Internal Server Error" });
291 }
292};
293
294// Update user
295const updateUser = async (req, res) => {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected