Skip to content

Commit 78aca0c

Browse files
committed
refactor: Add console log statements to resolve lint error
1 parent 3d1b065 commit 78aca0c

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

backend/controllers/user.controller.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ UserController.user_list = async function (req, res) {
2222
const user = await User.find(query);
2323
return res.status(200).send(user);
2424
} catch (err) {
25+
console.log(err);
2526
return res.sendStatus(400);
2627
}
2728
};
@@ -38,6 +39,7 @@ UserController.admin_list = async function (req, res) {
3839
const admins = await User.find({ accessLevel: { $in: ['admin', 'superadmin'] } });
3940
return res.status(200).send(admins);
4041
} catch (err) {
42+
console.log(err);
4143
return res.sendStatus(400);
4244
}
4345
};
@@ -58,11 +60,7 @@ UserController.projectManager_list = async function (req, res) {
5860
});
5961

6062
// Collect all unique project IDs
61-
const allProjectIds = [
62-
...new Set(
63-
projectManagers.flatMap(pm => pm.managedProjects)
64-
),
65-
];
63+
const allProjectIds = [...new Set(projectManagers.flatMap((pm) => pm.managedProjects))];
6664

6765
// Fetch all projects in one query
6866
const projects = await Project.find({ _id: { $in: allProjectIds } });
@@ -71,17 +69,18 @@ UserController.projectManager_list = async function (req, res) {
7169
projectIdToName[project._id.toString()] = project.name;
7270
}
7371

74-
const updatedProjectManagers = projectManagers.map(pm => {
72+
const updatedProjectManagers = projectManagers.map((pm) => {
7573
const pmObj = pm.toObject();
7674
pmObj.isProjectLead = true;
77-
pmObj.managedProjectNames = (pmObj.managedProjects || []).map(
78-
pid => projectIdToName[pid.toString()] || null
79-
).filter(Boolean);
75+
pmObj.managedProjectNames = (pmObj.managedProjects || [])
76+
.map((pid) => projectIdToName[pid.toString()] || null)
77+
.filter(Boolean);
8078
return pmObj;
8179
});
8280

8381
return res.status(200).send(updatedProjectManagers);
8482
} catch (err) {
83+
console.log(err);
8584
return res.sendStatus(400);
8685
}
8786
};
@@ -101,6 +100,7 @@ UserController.user_by_id = async function (req, res) {
101100
// and look downstream to see whether 404 would break anything
102101
return res.status(200).send(user);
103102
} catch (err) {
103+
console.log(err);
104104
return res.sendStatus(400);
105105
}
106106
};
@@ -144,6 +144,7 @@ UserController.update = async function (req, res) {
144144
const user = await User.findOneAndUpdate({ _id: UserId }, req.body, { new: true });
145145
return res.status(200).send(user);
146146
} catch (err) {
147+
console.log(err);
147148
return res.sendStatus(400);
148149
}
149150
};
@@ -161,6 +162,7 @@ UserController.delete = async function (req, res) {
161162
const user = await User.findByIdAndDelete(UserId);
162163
return res.status(200).send(user);
163164
} catch (err) {
165+
console.log(err);
164166
return res.sendStatus(400);
165167
}
166168
};
@@ -230,7 +232,7 @@ UserController.signin = function (req, res) {
230232
};
231233

232234
UserController.verifySignIn = async function (req, res) {
233-
// eslint-disable-next-line dot-notation
235+
234236
let token = req.headers['x-access-token'] || req.headers['authorization'];
235237
if (token.startsWith('Bearer ')) {
236238
// Remove Bearer from string
@@ -243,6 +245,7 @@ UserController.verifySignIn = async function (req, res) {
243245
res.cookie('token', token, { httpOnly: true });
244246
return res.send(user);
245247
} catch (err) {
248+
console.log(err);
246249
return res.status(403);
247250
}
248251
};

0 commit comments

Comments
 (0)