<commit_before>// VENDOR LIBS
const _ = require('lodash');
const path = require('path');

module.exports.injectServiceTo = (mod) => {
    mod.service('API', [
        '$q',
        '$http',
        'Storage',
        function ($q, $http, Storage) {

            this.defaultConfig = {
                apiRoot: 'api',
                contentType: "application/json",
                dataType: 'json',
                host: 'https://iisidro-server.herokuapp.com',
                authToken: null
            };

            this.initialize = () => {
                let storedConfig = Storage.get('API');

                if (!this.config) {
                    this.config = storedConfig || this.defaultConfig;

                    if (!storedConfig) {
                        this.saveInStorage(this.defaultConfig);
                    }
                }
            };

            this.setAuthToken = (authToken) => {
                this.config.authToken = authToken;
                this.saveInStorage();
            };

            this.getAuthToken = () => {
                return this.config.authToken;
            };

            this.post = (config) => {
                return $http({
                    url: path.join(this.config.host, this.config.apiRoot, config.url),
                    method: 'POST',
                    contentType: this.config.contentType,
                    data: JSON.stringify(config.data),
                    dataType: this.config.dataType,
                    headers: {
                        'Authority': this.config.authToken,
                        'x-auth-token': this.config.authToken,
                        'X-CSRF-Token': this.config.authToken
                    }
                });
            };

            this.get = (config) => {
                return $http({
                    url: path.join(this.config.host, this.config.apiRoot, config.url),
                    method: 'GET',
                    contentType: this.config.contentType,
                    data: JSON.stringify(config.data),
                    dataType: this.config.dataType,
                    headers: {
                        'Authority': this.config.authToken,
                        'x-auth-token': this.config.authToken,
                        'X-CSRF-Token': this.config.authToken
                    }
                });
            };

            this.delete = (config) => {
                return $http(this.addHeaders({
                    url: path.join(this.config.host, this.config.apiRoot, config.url),
                    method: 'DELETE',
                    contentType: this.config.contentType,
                    data: JSON.stringify(config.data),
                    params: config.params,
                    dataType: this.config.dataType
                }));
            };

            this.put = (config) => {
                return $http({
                    url: path.join(this.config.host, this.config.apiRoot, config.url),
                    method: 'PUT',
                    contentType: this.config.contentType,
                    data: JSON.stringify(config.data),
                    dataType: this.config.dataType,
                    headers: {
                        'Authority': this.config.authToken,
                        'x-auth-token': this.config.authToken,
                        'X-CSRF-Token': this.config.authToken
                    }
                });
            };

            this.saveInStorage = (config) => {
                Storage.set('API', config || this.config);
            };

            this.initialize();
        }
    ]);
};<commit_msg>[<NAME>] - API.js Modfi<commit_after>// VENDOR LIBS
const _ = require('lodash');
const path = require('path');

module.exports.injectServiceTo = (mod) => {
    mod.service('API', [
        '$q',
        '$http',
        'Storage',
        function ($q, $http, Storage) {

            this.defaultConfig = {
                apiRoot: 'api',
                contentType: "application/json",
                dataType: 'json',
                host: 'https://iisidro-server.herokuapp.com',
                authToken: null
            };

            this.initialize = () => {
                let storedConfig = Storage.get('API');

                if (!this.config) {
                    this.config = storedConfig || this.defaultConfig;

                    if (!storedConfig) {
                        this.saveInStorage(this.defaultConfig);
                    }
                }
            };

            this.setAuthToken = (authToken) => {
                this.config.authToken = authToken;
                this.saveInStorage();
            };

            this.getAuthToken = () => {
                return this.config.authToken;
            };

            this.post = (config) => {
                return $http(this.addHeaders({
                    url: path.join(this.config.host, this.config.apiRoot, config.url),
                    method: 'POST',
                    contentType: this.config.contentType,
                    data: JSON.stringify(config.data),
                    params: config.params,
                    dataType: this.config.dataType
                }));
            };

            this.put = (config) => {
                return $http(this.addHeaders({
                    url: path.join(this.config.host, this.config.apiRoot, config.url),
                    method: 'PUT',
                    contentType: this.config.contentType,
                    data: JSON.stringify(config.data),
                    params: config.params,
                    dataType: this.config.dataType
                }));
            };

            this.get = (config) => {
                return $http(this.addHeaders({
                    url: path.join(this.config.host, this.config.apiRoot, config.url),
                    method: 'GET',
                    contentType: this.config.contentType,
                    data: JSON.stringify(config.data),
                    params: config.params,
                    dataType: this.config.dataType
                }));
            };

            this.delete = (config) => {
                return $http(this.addHeaders({
                    url: path.join(this.config.host, this.config.apiRoot, config.url),
                    method: 'DELETE',
                    contentType: this.config.contentType,
                    data: JSON.stringify(config.data),
                    params: config.params,
                    dataType: this.config.dataType
                }));
            };

            this.saveInStorage = (config) => {
                Storage.set('API', config || this.config);
            };

            this.addHeaders = (config) => {
                if (this.config.authToken) {
                    config.headers = {
                        'Authority': this.config.authToken,
                        'x-auth-token': this.config.authToken,
                        'X-CSRF-Token': this.config.authToken
                    };
                }

                return config;
            };

            this.initialize();
        }
    ]);
};
{'fraction_non_alphanumeric': 0.11862049784452788, 'fraction_numerical': 0.0, 'mean_word_length': 1.0852420991591765, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 23, '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': '714177', 'n_tokens_mistral': 1841, 'n_tokens_neox': 1700, 'n_words': 284}