text: import PageSerializer from '@apps/websites/serializers/page_serializer'
  import Website from '@apps/websites/models/website'
  import Alias from '@apps/websites/models/alias'
  import Page from '@apps/websites/models/page'
  
  const showRoute = async (req, res) => {
  
    const website = await Website.query(qb => {
      qb.where('team_id', req.team.get('id'))
      qb.where('id', req.params.website_id)
    }).fetch({
      transacting: req.trx
    })
  
    if(!website) return res.status(404).respond({
      code: 404,
      message: 'Unable to load website'
    })
  
    const page = await Page.query(qb => {
      qb.select('websites_pages.*','maha_version_versions.active_value as config','maha_version_versions.status')
      qb.joinRaw('inner join maha_version_versions on maha_version_versions.versionable_type=? and maha_version_versions.versionable_id=websites_pages.id and maha_version_versions.key=?', ['websites_pages','config'])
      qb.where('websites_pages.website_id', website.get('id'))
      qb.where('websites_pages.id', req.params.id)
      qb.whereNull('websites_pages.deleted_at')
    }).fetch({
      withRelated: ['template'],
      transacting: req.trx
    })
  
    if(!page) return res.status(404).respond({
      code: 404,
      message: 'Unable to load page'
    })
  
    const primary_alias = await Alias.query(qb => {
      qb.where('website_id', website.get('id'))
      qb.where('destination', `pages/${page.get('id')}`)
    }).fetch({
      transacting: req.trx
    })
  
    page.set('primary_alias', primary_alias.get('path'))
  
    await res.status(200).respond(page, PageSerializer)
  
  }
  
  export default showRoute
  