How to Replace Object With Named Parameters in ES6 ( Error handing of undefined in JavaScript )

function loadProfiles(userNames = [],  {profilesClass, reverseSort} = {}) {
   profilesClass = profilesClass || ".user-profile";
   reverseSort   = reverseSort   || false;

  if (reverseSort) {
    userNames = _reverse(userNames);
  }

  _loadProfilesToSideBar(userNames, profilesClass);
}

Add Param middleware to fix dynamic routing in express

app.param('name', function (request, response, next) {

  request.cityName = parseCityName(request.params.name);

  next();

});

Create custom logger module in nodejs

create file name: logger.js

module.exports = function (request, response, next) {
  var startTime = +new Date();
  var stream = process.stdout;
  var duration = null;

  response.on('finish', function () {
    duration = +new Date() - startTime;
    stream.write("This request took " + duration + " ms" + request + " "+ response);
  });
  
  next();
};

// used to log  the request and response and duration