<commit_before>import path from 'path';
import fs from 'fs';
import https from 'https';
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
import { cloneDeep } from 'lodash';

import { version } from '../package.json';

export interface IMollieRequestConfig extends AxiosRequestConfig {
  apiKey: string;
}

declare let window: any;

/**
 * Create pre-configured httpClient instance
 *
 * @private
 */
export default function createHttpClient(options: IMollieRequestConfig): AxiosInstance {
  const newOptions = cloneDeep(options);
  newOptions.baseURL = 'https://api.mollie.com:443/v2/';

  newOptions.headers = {
    ...options.headers,
    Authorization: `Bearer ${options.apiKey}`,
    'Accept-Encoding': 'gzip',
    'Content-Type': 'application/json',
    'User-Agent': `node.js/${process.version}`,
    'X-Mollie-User-Agent': `mollie/${version}`,
  };

  // Setting the root CA certificate will fail in a browser environment
  if (typeof window !== 'undefined' && typeof fs !== 'undefined' && typeof fs.readFileSync !== 'undefined') {
    newOptions.httpsAgent = new https.Agent({
      cert: fs.readFileSync(path.resolve(__dirname, './cacert.pem'), 'utf8'),
    });
  }

  return axios.create(newOptions);
}<commit_msg>Remove browser check<commit_after>import path from 'path';
import fs from 'fs';
import https from 'https';
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
import { cloneDeep } from 'lodash';

import { version } from '../package.json';

export interface IMollieRequestConfig extends AxiosRequestConfig {
  apiKey: string;
}

/**
 * Create pre-configured httpClient instance
 *
 * @private
 */
export default function createHttpClient(options: IMollieRequestConfig): AxiosInstance {
  const newOptions = cloneDeep(options);
  newOptions.baseURL = 'https://api.mollie.com:443/v2/';

  newOptions.headers = {
    ...options.headers,
    Authorization: `Bearer ${options.apiKey}`,
    'Accept-Encoding': 'gzip',
    'Content-Type': 'application/json',
    'User-Agent': `node.js/${process.version}`,
    'X-Mollie-User-Agent': `mollie/${version}`,
  };

  newOptions.httpsAgent = new https.Agent({
    cert: fs.readFileSync(path.resolve(__dirname, './cacert.pem'), 'utf8'),
  });

  return axios.create(newOptions);
}
{'fraction_non_alphanumeric': 0.15147512109202993, 'fraction_numerical': 0.004403346543372964, 'mean_word_length': 4.38388625592417, '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': '3363767', 'n_tokens_mistral': 718, 'n_tokens_neox': 713, 'n_words': 169}