<commit_before>/*
 * Author: <NAME> (Oxyno-zeta)
 * Date: 09/07/16
 * Licence: See Readme
 */

/* ************************************* */
/* ********       REQUIRE       ******** */
/* ************************************* */
const _ = require('lodash');
const logger = require('../../shared/logger')('[Core API]');

/* ************************************* */
/* ********       EXPORTS       ******** */
/* ************************************* */
module.exports = {
	sendArrayResponse: sendArrayResponse,
	sendResponse: sendResponse,
	sendTextResponse: sendTextResponse,
	getDefaultResponseBody: getDefaultResponseBody
};

/* ************************************* */
/* ********  PRIVATE FUNCTIONS  ******** */
/* ************************************* */



/* ************************************* */
/* ********   PUBLIC FUNCTIONS  ******** */
/* ************************************* */

/**
 * Send array response.
 * @param response {Object} Response
 * @param array {Array} Array
 * @param statusObject {Object} Status object (from APICodes)
 */
function sendArrayResponse(response, array, statusObject) {
	// Update response
	response.status(statusObject.code);
	// Debug part
	logger.debug(`Answer: Code = ${statusObject.code}, Text = ${array}`);
	// Send response
	response.send(array);
}

/**<commit_msg>[API] Fix log response<commit_after>/*
 * Author: <NAME> (Oxyno-zeta)
 * Date: 09/07/16
 * Licence: See Readme
 */

/* ************************************* */
/* ********       REQUIRE       ******** */
/* ************************************* */
const _ = require('lodash');
const logger = require('../../shared/logger')('[Core API]');

/* ************************************* */
/* ********       EXPORTS       ******** */
/* ************************************* */
module.exports = {
	sendArrayResponse: sendArrayResponse,
	sendResponse: sendResponse,
	sendTextResponse: sendTextResponse,
	getDefaultResponseBody: getDefaultResponseBody
};

/* ************************************* */
/* ********  PRIVATE FUNCTIONS  ******** */
/* ************************************* */



/* ************************************* */
/* ********   PUBLIC FUNCTIONS  ******** */
/* ************************************* */

/**
 * Send array response.
 * @param response {Object} Response
 * @param array {Array} Array
 * @param statusObject {Object} Status object (from APICodes)
 */
function sendArrayResponse(response, array, statusObject) {
	// Update response
	response.status(statusObject.code);
	// Debug part
	logger.debug(`Answer: Code = ${statusObject.code}, Text = ${JSON.stringify(array)}`);
	// Send response
	response.send(array);
}

/**
{'fraction_non_alphanumeric': 0.39827002632568637, 'fraction_numerical': 0.0045129748025573525, 'mean_word_length': 4.576519916142558, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7560172', 'n_tokens_mistral': 734, 'n_tokens_neox': 678, 'n_words': 133}