docs: function wrap(req, res, apiHandler, apiObj, instanceName) {
      const startTime = performanceNow();
  
      const query = URL.parse(req.originalUrl).query;
      let queryObject = {};
      if (query && !_.isEmpty(query)) {
          queryObject = QueryString.parse(query, {allowDots: true});
      }
      
      req.params.__instanceName__ = instanceName;
  
      const data = _.extend({}, req.body, queryObject, req.params);
  
      let promise = null;
      try {
          const dataStr = JSON.stringify(data);
  
          // set req length in header for logging
          res.set('REQ_LENGTH', dataStr.length);
          promise = apiHandler.call(apiObj, req, data);
      } catch (error) {
          console.error('Error in handling request for data: ', JSON.stringify(data), req.originalUrl, error, error.stack);
          apiErrorsLogger.error(error);
          promise = Promise.reject(error);
      }
  
      return Promise.resolve(promise)
        .then((result) => {
            if (result) {
                result.requestTime = req.body.requestTime;
                result.serviceTimeTaken = (performanceNow() - startTime).toFixed(3);
  
                if (!_.isUndefined(result.queryTimeTaken)) {
                    res.header('QUERY_TIME_TAKEN', result.queryTimeTaken);
                }
  
                if (!_.isUndefined(result.totalResults)) {
                    res.header('TOTAL_RESULTS', result.totalResults);
                }
  
                res.set('Content-Type', 'application/json; charset=utf-8');
                const response = new Buffer(JSON.stringify(result), 'utf8');
  
                // set response length in header for logging
                res.header('RES_LENGTH', response.length);
  
                return res.send(response);
            }
  
            return res.json(result);
        })
        .catch((error) => {
            if (error && _.isObject(error)) {
                // TODO: change it
                error._errorId = Date.now();
  
                apiErrorsLogger.error(_.omit(error, 'stack'));
  
                return res.status(error._statusCode || 500).json(error._errorCode === 'INTERNAL_SERVICE_ERROR' ? _.omit(error, 'details') : error);
            }
  
            // log error stack here
            console.error('Error in handling request for data: ', JSON.stringify(data), req.originalUrl, error, error.stack);
  
            apiErrorsLogger.error(error);
  
            return res.status(500).json(error);
        });
  }