function populateAllRoutes(){
    Request.find({}).populate('headers mapping').exec(function(err, requestsList){
      if (err){
        console.error("Failed to find routes on startup: " + JSON.stringify(err));
      }
      // Restore our router to it's previous state before we had mounted any user routes
      router.stack.splice(previousRouterStackLength, router.stack.length);
      // Now, re-mount every route to ensure we're up to date
      requestsList.forEach(populateSingleRoute);
    });
  }
// Finds all our requests, clears out the router of any old request definitions, then adds these routes to the DB
Finds all our requests, clears out the router of any old request definitions, then adds these routes to the DB
Finds all our requests clears out the router of any old request definitions then adds these routes to the DB
function populateAllRoutes(){
    Request.find({}).populate('headers mapping').exec(function(err, requestsList){
      if (err){
        console.error("Failed to find routes on startup: " + JSON.stringify(err));
      }
      router.stack.splice(previousRouterStackLength, router.stack.length);
      requestsList.forEach(populateSingleRoute);
    });
  }
function populateAllRoutes ( ) { Request . find ( { } ) . populate ( 'headers mapping' ) . exec ( function ( err , requestsList ) { if ( err ) { console . error ( "Failed to find routes on startup: " + JSON . stringify ( err ) ) ; } router . stack . splice ( previousRouterStackLength , router . stack . length ) ; requestsList . forEach ( populateSingleRoute ) ; } ) ; }
Finds all our requests, clears out the router of any old request definitions, then adds these routes to the DB
Finds all our requests clears out the router of any old request definitions then adds these routes to the DB
// Restore our router to it's previous state before we had mounted any user routes // Now, re-mount every route to ensure we're up to date