<commit_before>'use strict';

var axios = require('axios');

var resources = {
  Post: require('./resources/Post'),
  Category: require('./resources/Category'),
  Tag: require('./resources/Tag'),
  Author: require('./resources/Author'),
  Feed: require('./resources/Feed'),
  Content: require('./resources/Content')
}

function Butter(apiToken, testMode, timeout) {
  if (!(this instanceof Butter)) {
    return new Butter(apiToken, testMode, timeout);
  }

  if (!apiToken) {
    throw 'ButterCMS API token not set';
  }

  // Use live mode by default
  var testMode = testMode || false;

  // 3000ms timeout by default
  var timeout = timeout || 3000;

  var requestMethods = this._prepMethods(apiToken, testMode, timeout);

  this._prepResources(requestMethods);
}

Butter.prototype = {
  _prepResources: function(requestMethods) {
    for (var name in resources) {
      this[
        name[0].toLowerCase() + name.substring(1)
      ] = new resources[name](requestMethods);
    }
  },
  _prepMethods: function(apiToken, testMode, timeout) {
    return {
      get: function(url, params) {
        var conn = axios.create({
          baseURL: 'https://api.buttercms.com/v2',
          timeout: timeout
        });

        var params = params || {};
<commit_msg>Add header signature for better insight into requests<commit_after>'use strict';

var axios = require('axios');
var config = require('../package');

var resources = {
  Post: require('./resources/Post'),
  Category: require('./resources/Category'),
  Tag: require('./resources/Tag'),
  Author: require('./resources/Author'),
  Feed: require('./resources/Feed'),
  Content: require('./resources/Content')
}

function Butter(apiToken, testMode, timeout) {
  if (!(this instanceof Butter)) {
    return new Butter(apiToken, testMode, timeout);
  }

  if (!apiToken) {
    throw 'ButterCMS API token not set';
  }

  // Use live mode by default
  var testMode = testMode || false;

  // 3000ms timeout by default
  var timeout = timeout || 3000;

  var requestMethods = this._prepMethods(apiToken, testMode, timeout);

  this._prepResources(requestMethods);
}

Butter.prototype = {
  _prepResources: function(requestMethods) {
    for (var name in resources) {
      this[
        name[0].toLowerCase() + name.substring(1)
      ] = new resources[name](requestMethods);
    }
  },
  _prepMethods: function(apiToken, testMode, timeout) {
    return {
      get: function(url, params) {
        var conn = axios.create({
          baseURL: 'https://api.buttercms.com/v2',
          timeout: timeout,
          headers: {'X-Butter-Client': 'JS/' + config.version}
        });

        var params = params || {};

{'fraction_non_alphanumeric': 0.14569288389513108, 'fraction_numerical': 0.008239700374531835, 'mean_word_length': 3.2262658227848102, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '451263', 'n_tokens_mistral': 810, 'n_tokens_neox': 771, 'n_words': 202}