Last active
December 29, 2017 13:47
-
-
Save vedranjukic/389bd7607f47160e0b67ce366db89fe3 to your computer and use it in GitHub Desktop.
Implemented UserRepositoryMongo adapter
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 UserRepositoryMongo instantiated | |
// and passed to updateUser | |
// | |
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 | |
// get userRepository instance from factory | |
const userRepository = UserRepositoryMongo(db) | |
await updateUser({ | |
userRepository, | |
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