Last active
December 29, 2017 13:47
-
-
Save vedranjukic/0138d97d4985594fb701d949ce22af3c to your computer and use it in GitHub Desktop.
Separated update user logic from the route
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
// | |
// 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