lib/render.js
function renderUri(uri, req, res, hrStart) {
  hrStart = hrStart || process.hrtime(); // Check if we actually have a start time

  return db.get(uri).then(function (result) {
    const route = _.find(uriRoutes, function (item) {
      return result.match(item.when);
    });

    if (!route) {
      throw new Error('Invalid URI: ' + uri + ': ' + result);
    }

    if (route.isUri) {
      let newBase64Uri = _.last(result.split('/')),
        newUri = buf.decode(newBase64Uri),
        newPath = url.parse(`${res.req.protocol}://${newUri}`).path,
        newUrl = `${res.req.protocol}://${res.req.hostname}${newPath}`,
        queryString = req._parsedUrl.search;

      if (queryString) newUrl += queryString;

      log('info', `Redirecting to ${newUrl}`);
      res.redirect(301, newUrl);
    } else {
      return route.default(result, req, res, hrStart);
    }
  });
}
function renderUri(uri, req, res, hrStart) {
  hrStart = hrStart || process.hrtime(); // Check if we actually have a start time

  return db.get(uri).then(function (result) {
    const route = _.find(uriRoutes, function (item) {
      return result.match(item.when);
    });

    if (!route) {
      throw new Error('Invalid URI: ' + uri + ': ' + result);
    }

    if (route.isUri) {
      let newBase64Uri = _.last(result.split('/')),
        newUri = buf.decode(newBase64Uri),
        newPath = url.parse(`${res.req.protocol}://${newUri}`).path,
        newUrl = `${res.req.protocol}://${res.req.hostname}${newPath}`,
        queryString = req._parsedUrl.search;

      if (queryString) newUrl += queryString;

      log('info', `Redirecting to ${newUrl}`);
      res.redirect(301, newUrl);
    } else {
      return route.default(result, req, res, hrStart);
    }
  });
}
function renderUri ( uri , req , res , hrStart ) { hrStart = hrStart || process . hrtime ( ) ; // Check if we actually have a start time return db . get ( uri ) . then ( function ( result ) { const route = _ . find ( uriRoutes , function ( item ) { return result . match ( item . when ) ; } ) ; if ( ! route ) { throw new Error ( 'Invalid URI: ' + uri + ': ' + result ) ; } if ( route . isUri ) { let newBase64Uri = _ . last ( result . split ( '/' ) ) , newUri = buf . decode ( newBase64Uri ) , newPath = url . parse ( ` ${ res . req . protocol } ${ newUri } ` ) . path , newUrl = ` ${ res . req . protocol } ${ res . req . hostname } ${ newPath } ` , queryString = req . _parsedUrl . search ; if ( queryString ) newUrl += queryString ; log ( 'info' , ` ${ newUrl } ` ) ; res . redirect ( 301 , newUrl ) ; } else { return route . default ( result , req , res , hrStart ) ; } } ) ; }
Redirect to referenced type.

Depending on what the uri references, load something different.

@param {string} uri
@param {object} req
@param {object} res
@param {object} hrStart
@returns {Promise}
Redirect to referenced type .