Skip to content

Instantly share code, notes, and snippets.

@vedranjukic
Last active December 29, 2017 13:47
Show Gist options
  • Save vedranjukic/389bd7607f47160e0b67ce366db89fe3 to your computer and use it in GitHub Desktop.
Save vedranjukic/389bd7607f47160e0b67ce366db89fe3 to your computer and use it in GitHub Desktop.
Implemented UserRepositoryMongo adapter
//
// 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