Skip to content

Instantly share code, notes, and snippets.

@talyssonoc
Created April 4, 2017 02:19
Show Gist options
  • Save talyssonoc/14648f2a7b90eeb9a43649498d123a5a to your computer and use it in GitHub Desktop.
Save talyssonoc/14648f2a7b90eeb9a43649498d123a5a to your computer and use it in GitHub Desktop.
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