Started update user route

This commit is contained in:
Alex Holliday committed 2024-05-27 11:57:25 -07:00
1 parent 5fa73a1f17
commit d84a0f9c87
7 files changed
+125 -46

No files matched your search

+26
View File
@@ -55,6 +55,31 @@ const getUserByEmail = async (req, res) => {
}
};
/**
* Update a user by ID
* @async
* @param {Express.Request} req
* @param {Express.Response} res
* @returns {Promise<UserModel>}
* @throws {Error}
*/
const updateUser = async (req, res) => {
const candidateUserId = req.params.userId;
const candidateUser = req.body;
try {
const updatedUser = await user.findByIdAndUpdate(
candidateUserId,
candidateUser,
{ new: true } // Returns updated user instead of pre-update user
);
return updatedUser;
} catch (error) {
throw error;
}
};
/**
* Get all monitors
* @async
@@ -173,6 +198,7 @@ module.exports = {
connect,
insertUser,
getUserByEmail,
updateUser,
getAllMonitors,
getMonitorById,
getMonitorsByUserId,