Merge branch 'master' into feat/check-routes

This commit is contained in:
Alex Holliday committed 2024-05-27 15:38:12 -07:00
commit bd4d442781
9 files changed
+185 -47

No files matched your search

+26
View File
@@ -63,6 +63,31 @@ const getUserByEmail = async (req, res) => {
// Monitors
//****************************************
/**
* 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 UserModel.findByIdAndUpdate(
candidateUserId,
candidateUser,
{ new: true } // Returns updated user instead of pre-update user
).select("-password");
return updatedUser;
} catch (error) {
throw error;
}
};
/**
* Get all monitors
* @async
@@ -244,6 +269,7 @@ module.exports = {
connect,
insertUser,
getUserByEmail,
updateUser,
getAllMonitors,
getMonitorById,
getMonitorsByUserId,