<commit_before>'use strict';

var superagent = require('superagent'),
  debug = require('debug')("app:services:Rest");

var Rest = {

  config: {
    API_URL: "",
    TIMEOUT: 10000
  },

  /**
   * this is the base request used to communicate with the API server
   * creates a superagent preconfigured request
   * @param  {String} method   The http verb; One of (GET, POST, PUT, DELETE, PATCH, OPTIONS)
   * @param  {String} endpoint The endpoint used to send the request
   * @return {Request}         The request object from superagent package
   */
  request: function(context, method, endpoint) {

    var API_URL = Rest.config.API_URL,
        TIMEOUT = Rest.config.TIMEOUT;

    if ("" === API_URL) {
      throw new Error("You must provide the API_URL before using any flux actions. You must pass it in config property when creating the dispatcher");
    }

    if (endpoint.indexOf(API_URL) === -1) {
      endpoint = API_URL + endpoint;
    }

    var r = superagent(method, endpoint)
      .timeout(TIMEOUT)
      .type('json')
      .accept('json'),
      serverReq = context.req;

    if (serverReq) {
      r.set('Cookie', server.get('Cookie'));
    }

    return r;
  },

  setConfig: function(config) {
    Rest.config = config;
  }
};

module.exports = Rest;<commit_msg>minor fixes<commit_after>'use strict';

var superagent = require('superagent'),
  debug = require('debug')("app:services:Rest");

var Rest = {

  config: {
    API_URL: "",
    TIMEOUT: 10000
  },

  /**
   * this is the base request used to communicate with the API server
   * creates a superagent preconfigured request
   * @param  {String} method   The http verb; One of (GET, POST, PUT, DELETE, PATCH, OPTIONS)
   * @param  {String} endpoint The endpoint used to send the request
   * @return {Request}         The request object from superagent package
   */
  request: function(context, method, endpoint) {

    var API_URL = Rest.config.API_URL,
        TIMEOUT = Rest.config.TIMEOUT;

    if ("" === API_URL) {
      throw new Error("You must provide the API_URL before using any flux actions. You must pass it in config property when creating the dispatcher");
    }

    if (endpoint.indexOf(API_URL) === -1) {
      endpoint = API_URL + endpoint;
    }

    var r = superagent(method, endpoint)
      .timeout(TIMEOUT)
      .type('json')
      .accept('json'),
      serverReq = context.req;

    if (typeof serverReq === 'object') {
      r.set('Cookie', serverReq.get('Cookie'));
    }

    return r;
  },

  setConfig: function(config) {
    Rest.config = config;
  }
};

module.exports = Rest;
{'fraction_non_alphanumeric': 0.12350904193920739, 'fraction_numerical': 0.00461716044632551, 'mean_word_length': 2.898050974512744, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6365959', 'n_tokens_mistral': 809, 'n_tokens_neox': 777, 'n_words': 248}