vedranjukic
12/12/2017 - 1:06 PM

Separated update user logic from the route

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')
})