Created
April 4, 2017 02:19
-
-
Save talyssonoc/14648f2a7b90eeb9a43649498d123a5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const UsersController = { | |
create(req, res) { | |
const createUser = new CreateUser({ usersRepository }); | |
createUser | |
.on('SUCCESS', (user) => { | |
res.status(201).json(user); | |
}) | |
.on('VALIDATION_ERROR', (error) => { | |
res.status(400).json({ | |
type: 'ValidationError', | |
details: error.details | |
}); | |
}) | |
.on('ERROR', (error) => { | |
res.sendStatus(500); | |
}); | |
createUser.execute(req.body.user); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment