controllers/resolver.js
/**
 * @method middleware
 * @description main middleware function handling the resolving of
 * external ids to aggie expert ids in url paths
 * 
 * @param {Object} req 
 * @param {Object} res 
 * @param {Function} next 
 */
@method middleware
@description main middleware function handling the resolving of
external ids to aggie expert ids in url paths


@method middleware @description main middleware function handling the resolving of external ids to aggie expert ids in url paths
async function middleware(req, res, next) {
  let id = req.path
    .replace(/^\/(person|work)\//, '')
    .replace(/^\//, '');
  let newPath = await resolveId(id);
  if( newPath && newPath !== req.path ) {
    logger.info(`resolved: ${req.path} to ${newPath}`);
    res.redirect(newPath);
    return;
  }
  next();
}
async function middleware ( req , res , next ) { let id = req . path . replace ( / ^\/(person|work)\/ / , '' ) . replace ( / ^\/ / , '' ) ; let newPath = await resolveId ( id ) ; if ( newPath && newPath !== req . path ) { logger . info ( ` ${ req . path } ${ newPath } ` ) ; res . redirect ( newPath ) ; return ; } next ( ) ; }
@method middleware
 @description main middleware function handling the resolving of
 external ids to aggie expert ids in url paths
@method middleware @description main middleware function handling the resolving of external ids to aggie expert ids in url paths