<commit_before>'use strict';

var Status = require('flora-cluster').Status;
var Profiler = require('./profiler');

/**
 * Create new request
 *
 * @constructor
 * @param {Object} options          - Request configuration
 * @param {string} options.resource - Requested resource
 * @param {string=} options.action  - Resource action
 * @param {string=} options.format  - Response format
 */
module.exports = function (options) {
    var self = this;

    var readable = function (property, value) {
        Object.defineProperty(self, property, {
            value: value,
            configurable: false,
            enumerable: false
        });
    };

    var writable = function (property, value) {
        Object.defineProperty(self, property, {
            value: value,
            configurable: true,
            enumerable: false,
            writable: true
        });
    };

    options = options || {};

    /**
     * Requested resource
     *
     * @name Request#resource
     * @type {string}
     * @readonly
     */
    this.resource = options.resource;

    /**
     * Resource action to execute
     *
     * @type {string}
     * @name Request#action
     * @default json
     * @readonly
     */
    this.action = options.action || 'retrieve';

    /**
     * Response format
     *
     * @type {string}
     * @name Request#format
     * @default json
     * @readonly
     */
    this.format = options.format || 'json';

    /**
     * Status helper object
     *
     * @type {Status}
     * @name Request#_status
     * @readonly
     */
    readable('_status', options._status || new Status());

    /**
     * Profiling helper object
     *
     * @type {Profiler}
     * @name Request#_profiler
     * @readonly
     */
    readable('_profiler', new Profiler('request'));

    /**
     * Authorization information
     *
     * @name Request#_auth
     * @readonly
     */
    writable('_auth', null);

    /**
     * HTTP-Request object (if available)
     *
     * @type {http.IncomingMessage}
     * @name Request#_httpRequest
     * @readonly
     */
    readable('_httpRequest', options._httpRequest);

    for (var key in options) { // copy custom parameters
        if (!this.hasOwnProperty(key)) this[key] = options[key];
    }
};<commit_msg>profiling: inject startTime from "onRequest" if available<commit_after>'use strict';

var Status = require('flora-cluster').Status;
var Profiler = require('./profiler');

/**
 * Create new request
 *
 * @constructor
 * @param {Object} options          - Request configuration
 * @param {string} options.resource - Requested resource
 * @param {string=} options.action  - Resource action
 * @param {string=} options.format  - Response format
 */
module.exports = function (options) {
    var self = this;

    var readable = function (property, value) {
        Object.defineProperty(self, property, {
            value: value,
            configurable: false,
            enumerable: false
        });
    };

    var writable = function (property, value) {
        Object.defineProperty(self, property, {
            value: value,
            configurable: true,
            enumerable: false,
            writable: true
        });
    };

    options = options || {};

    /**
     * Requested resource
     *
     * @name Request#resource
     * @type {string}
     * @readonly
     */
    this.resource = options.resource;

    /**
     * Resource action to execute
     *
     * @type {string}
     * @name Request#action
     * @default json
     * @readonly
     */
    this.action = options.action || 'retrieve';

    /**
     * Response format
     *
     * @type {string}
     * @name Request#format
     * @default json
     * @readonly
     */
    this.format = options.format || 'json';

    /**
     * Status helper object
     *
     * @type {Status}
     * @name Request#_status
     * @readonly
     */
    readable('_status', options._status || new Status());

    /**
     * Profiling helper object
     *
     * @type {Profiler}
     * @name Request#_profiler
     * @readonly
     */
    readable('_profiler', new Profiler('request'));

    // inject startTime from "onRequest" if available:
    if (options._httpRequest && options._httpRequest.flora && options._httpRequest.flora.startTime) {
        this._profiler._startTime = options._httpRequest.flora.startTime;
    }

    /**
     * Authorization information
     *
     * @name Request#_auth
     * @readonly
     */
    writable('_auth', null);

    /**
     * HTTP-Request object (if available)
     *
     * @type {http.IncomingMessage}
     * @name Request#_httpRequest
     * @readonly
     */
    readable('_httpRequest', options._httpRequest);

    for (var key in options) { // copy custom parameters
        if (!this.hasOwnProperty(key)) this[key] = options[key];
    }
};
{'fraction_non_alphanumeric': 0.13031805039239983, 'fraction_numerical': 0.0, 'mean_word_length': 2.1104688503532434, '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': '3896150', 'n_tokens_mistral': 1402, 'n_tokens_neox': 1368, 'n_words': 330}