Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

se añadieron algunas pequeñas validaciones #116

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ const getIncomesByDate = (req, res) => {
const rapiTransfer = (req, res) => {
const { amount, cvu } = req.body;

if(amount <= 0 || amount === '') res.status(400).json({
message: 'Ingrese un monto correcto'
})

AccountModel.findOne({ cvu: cvu })
.then((acc) => {
acc.balance += amount;
Expand Down Expand Up @@ -113,7 +117,7 @@ const rapiTransfer = (req, res) => {
})
.catch((err) => {
res.status(400).json({
message: err.message || 'Error in transfer'
message: 'No se encontro el cvu'
});
});
};
Expand Down
15 changes: 8 additions & 7 deletions api/microservices/services/User/controllers/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ const addContact = (req, res) => {
if (foundUser.contacts.includes(contact._id)) {
return res
.status(400)
.json({ message: 'Contacto ya existe.', contact });
.json({ message: 'El contacto ya existe.', contact });
}

// Adding contact to user
Expand All @@ -258,7 +258,7 @@ const addContact = (req, res) => {
});
})
.catch((error) => {
res.status(400).json({ message: 'Error.', error });
res.status(400).json({ message: 'No se ha encontrado el usuario a añadir' });
});
};

Expand All @@ -279,7 +279,6 @@ const addCreditCard = (req, res) => {

User.findById(userId)
.then((user) => {
console.log('user >>>', user);

let newCreditCard = {
_id: mongo_id,
Expand All @@ -300,8 +299,8 @@ const addCreditCard = (req, res) => {
.status(200)
.json({ message: 'Tarjeta agregada.', cards: user.cards });
})
.catch((error) => {
res.status(400).json({ message: 'Error.', error: error.message });
.catch(() => {
res.status(400).json({ message: 'Error al agregar la tarjeta.' });
});
};

Expand All @@ -324,7 +323,7 @@ const deleteCreditCard = (req, res) => {
user.save();
return res.status(200).json(user.cards);
})
.catch((err) => err.message);
.catch(() => 'Error al borrar la taarjeta de credito');
};

const deleteContact = (req, res) => {
Expand All @@ -341,7 +340,9 @@ const deleteContact = (req, res) => {
user.save();
res.status(200).json(user);
})
.catch((e) => res.send(404).json(e));
.catch(() => res.send(404).json({
message: 'Error al borrar el contacto.'
}));
};

const modifyAlias = (req, res) => {
Expand Down