Skip to content

Instantly share code, notes, and snippets.

@vedranjukic
Last active December 29, 2017 13:47
Show Gist options
  • Save vedranjukic/0138d97d4985594fb701d949ce22af3c to your computer and use it in GitHub Desktop.
Save vedranjukic/0138d97d4985594fb701d949ce22af3c to your computer and use it in GitHub Desktop.
Separated update user logic from the route
//
// Express controller with isolated
// update user logic
//
router.put('/user', async (req, res) => {
// db object is already added to req object when express is initialised
const db = req.db;
const { userId, userName, userEmail } = req.body
await updateUser({
db,
updateParams: {
userId,
userName,
userEmai
}
})
res.send('User updated')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment