feat(sprint1-step2): core economy TS + useEconomy hook (lazy calc) + 13 tests vitest
This commit is contained in:
@@ -410,6 +410,27 @@ const destroy = async (req, res) => {
|
||||
};
|
||||
|
||||
|
||||
const updateCoins = async (req, res) => {
|
||||
const userId = req.params.id;
|
||||
const { tetardcoin } = req.body;
|
||||
|
||||
if (tetardcoin === undefined || typeof tetardcoin !== "number") {
|
||||
return res.status(400).json({ message: "tetardcoin (number) requis." });
|
||||
}
|
||||
|
||||
try {
|
||||
const affectedRows = await tables.users.edit(userId, { tetardcoin });
|
||||
|
||||
if (affectedRows === 0) {
|
||||
return res.status(404).json({ message: "Utilisateur non trouvé." });
|
||||
}
|
||||
|
||||
return res.status(200).json({ tetardcoin });
|
||||
} catch (err) {
|
||||
return res.status(500).json({ message: "Erreur lors de la mise à jour.", error: err.message });
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
browse,
|
||||
read,
|
||||
@@ -419,4 +440,5 @@ module.exports = {
|
||||
login,
|
||||
forgottenPassword,
|
||||
resetPassword,
|
||||
updateCoins,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user