text: import WebsiteSerializer from '@apps/websites/serializers/website_serializer'
  import { activity } from '@core/services/routes/activities'
  import { whitelist } from '@core/services/routes/params'
  import Website from '@apps/websites/models/website'
  import { audit } from '@core/services/routes/audit'
  import socket from '@core/services/routes/emitter'
  
  const updateRoute = async (req, res) => {
  
    const website = await Website.query(qb => {
      qb.where('team_id', req.team.get('id'))
      qb.where('id', req.params.id)
    }).fetch({
      transacting: req.trx
    })
  
    if(!website) return res.status(404).respond({
      code: 404,
      message: 'Unable to load website'
    })
  
    await website.save({
      ...whitelist(req.body, ['title','home_page_id','notfound_page_id'])
    }, {
      transacting: req.trx,
      patch: true
    })
  
    await audit(req, {
      story: 'updated',
      auditable: website
    })
  
    await activity(req, {
      story: 'updated {object}',
      object: website
    })
  
    await socket.refresh(req, [
      '/admin/websites/websites',
      `/admin/websites/websites/${website.get('id')}`
    ])
  
    await res.status(200).respond(website, WebsiteSerializer)
  
  }
  
  export default updateRoute
  