feat(sprint1-step2): core economy TS + useEconomy hook (lazy calc) + 13 tests vitest

This commit is contained in:
2026-03-17 06:36:51 +01:00
parent c414cf2d07
commit c69da320cc
13 changed files with 2627 additions and 174 deletions

View File

@@ -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,
};