// [2] middleWares Functions
// -
exports.signup = (req, res, next) => {
bcrypt
.hash(req.body.password, 10)
.then((hash) => {
const user = new User({
email: req.body.email,
password: hash,
});
user
.save()
.then(() => res.status(201).json({ message: "User créé !" }))
.catch((error) => res.status(400).json({ error }));
})
.catch((error) => res.status(500).json({ error }));
};
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter