Advertisement
Guest User

Untitled

a guest
Oct 13th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. const {Router} = require('express')
  2. const Users = require('./model')
  3. const bcrypt = require('bcrypt');
  4.  
  5. const router = new Router()
  6.  
  7. router.post('/users', (req,res,next)=>{
  8. const user = {
  9. email: req.body.email,
  10. password: bcrypt.hashSync(req.body.password, 10)
  11. }
  12.  
  13. Users
  14. .create(user)
  15. .then(person => {
  16. if(!person) res.status(401).send({
  17. message: 'You dun goofd, send a e-mail and password next time'
  18. })
  19. res.status(201).send(person)
  20. })
  21. .catch(error=>next(error))
  22. })
  23.  
  24. module.exports = router
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement