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

const usersRoutes = (api) => {
  api.post('/users', (req, res) => {
    User.create(req.body.user)
      .then((user) => {
        res.status(201).send(_.omit(user, ['password']))
      })
      .catch((user) => {
        res.status(400).send({ 'errors': user.errors })
      })
  })
}

module.exports = usersRoutes

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

const usersRoutes = (api) => {
  api.post('/users', (req, res) => {
    User.create(req.body.user)
      .then((user) => {
        user = _.omit(user.get({ 'plain': true }), ['password'])

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

module.exports = usersRoutes

Fix error when trying to send user model to response instead of user values
Fix error when trying to send user model to response instead of user values
