const createUser = async (req, res) => {
const { email } = req.body;
const existUser = await User.findOne({ email });
if (existUser) {
const error = new Error("Usuario ya existe");
return res.json({ msg: error.message });
}
try {
const newUser = new User(req.body);
newUser.token = generadeIdToken();
const saveUser = await newUser.save();
res.json(saveUser);
} catch (error) {
console.log(error);
}
};