const User = require('./../../models/user')

const usersRoutes = (api) => {
  api.post('/users', (req, res) => {
    User.create(req.body.user)
      .then((user) => {
        res.status(201).send(user)
      })
      .catch((user) => {
        res.status(400).send(user)
      })
  })
}

module.exports = usersRoutes

const User = require('./../../models/user')

const usersRoutes = (api) => {
  api.post('/users', (req, res) => {
    User.create(req.body.user)
      .then((user) => {
        delete user.password

        res.status(201).send(user)
      })
      .catch((user) => {
        res.status(400).send({ 'errors': user.errors })
      })
  })
}

module.exports = usersRoutes

Set a better format to errors and remove password when user created
Set a better format to errors and remove password when user created
