function handleRankingRedirects(server, renderCallback) {
  server.get('/ranking', (req, res) => {
    res.redirect(301, `/ranking/${defaultLocation}`);
  });

  // single, alltime, activities, etc
  server.get(
    `/ranking/:type(${allowedRankingTypes.join('|')})`,
    (req, res) => {
      const { params: { type = '' } } = req;
      res.redirect(301, `/ranking/${defaultLocation}/${type}`);
    },
  );

  // year and optional month
  server.get(
    '/ranking/:year(\\d+)/:month?',
    (req, res) => {
      const { params } = req;
      // Validate month because regex not working with optional param
      if (!requestParamsAreValid({
        ...params,
        location: true,
      })) {
        res.statusCode = 404;
        renderCallback(req, res, '/_error', {});
        return;
      }
      res.redirect(
        301,
        `/ranking/${defaultLocation}/${params.year}/${params.month || ''}`,
      );
    },
  );
}
/**
 * Handle requests for `ranking` routes
 */
Handle requests for `ranking` routes
Handle requests for ` ranking ` routes
function handleRankingRedirects(server, renderCallback) {
  server.get('/ranking', (req, res) => {
    res.redirect(301, `/ranking/${defaultLocation}`);
  });
  server.get(
    `/ranking/:type(${allowedRankingTypes.join('|')})`,
    (req, res) => {
      const { params: { type = '' } } = req;
      res.redirect(301, `/ranking/${defaultLocation}/${type}`);
    },
  );
  server.get(
    '/ranking/:year(\\d+)/:month?',
    (req, res) => {
      const { params } = req;
      if (!requestParamsAreValid({
        ...params,
        location: true,
      })) {
        res.statusCode = 404;
        renderCallback(req, res, '/_error', {});
        return;
      }
      res.redirect(
        301,
        `/ranking/${defaultLocation}/${params.year}/${params.month || ''}`,
      );
    },
  );
}
function handleRankingRedirects ( server , renderCallback ) { server . get ( '/ranking' , ( req , res ) => { res . redirect ( 301 , ` ${ defaultLocation } ` ) ; } ) ; server . get ( ` ${ allowedRankingTypes . join ( '|' ) } ` , ( req , res ) => { const { params : { type = '' } } = req ; res . redirect ( 301 , ` ${ defaultLocation } ${ type } ` ) ; } , ) ; server . get ( '/ranking/:year(\\d+)/:month?' , ( req , res ) => { const { params } = req ; if ( ! requestParamsAreValid ( { ... params , location : true , } ) ) { res . statusCode = 404 ; renderCallback ( req , res , '/_error' , { } ) ; return ; } res . redirect ( 301 , ` ${ defaultLocation } ${ params . year } ${ params . month || '' } ` , ) ; } , ) ; }
Handle requests for `ranking` routes
Handle requests for ` ranking ` routes
// single, alltime, activities, etc // year and optional month // Validate month because regex not working with optional param