<commit_before>'use strict';

const utils = require('../utils.js');
const services = require('../services.js');
const async = require('async');


/**
 * GET Object - Get an object
 * @param  {string} accessKey - user's access key
 * @param {object} datastore - datastore with object data
 * @param {object} metastore - metastore with buckets containing objects and their metadata
 * @param {object} request - normalized request object
 * @param {function} callback - callback to function in route
 * @return {function} callback with error, object data result and responseMetaHeaders as arguments
 *
 */

let objectGet = function (accessKey, datastore,  metastore, request, callback) {
    let bucketname = utils.getResourceNames(request).bucket;
    let bucketUID = utils.getResourceUID(request.namespace, bucketname);
    let objectKey = utils.getResourceNames(request).object;
    let objectUID = utils.getResourceUID(request.namespace, bucketname + objectKey);
    let metadataValParams = {accessKey: accessKey, bucketUID: bucketUID, objectKey: objectKey, metastore: metastore};
    let metadataCheckParams = {headers: request.lowerCaseHeaders};

    async.waterfall([
            function (next) {
                services.metadataValidateAuthorization(metadataValParams, next);
            },
            function (bucket, objectMetadata, next) {
                services.metadataChecks(bucket, objectMetadata, metadataCheckParams, next);
            },
            function (bucket, objectMetadata, metaHeaders, next) {
                services.getFromDatastore(bucket, objectMetadata, metaHeaders, datastore, next);
            }
    ], function (err, result, responseMetaHeaders) {
        return callback(err, result, responseMetaHeaders);
    });
};

module.exports = objectGet;
<commit_msg>CLEANUP: Refactor objectGet.js per style guide<commit_after>import utils from '../utils.js';
import services from '../services.js';
import async from 'async';


/**
 * GET Object - Get an object
 * @param  {string} accessKey - user's access key
 * @param {object} datastore - datastore with object data
 * @param {object} metastore - metastore with buckets containing
 * objects and their metadata
 * @param {object} request - normalized request object
 * @param {function} callback - callback to function in route
 * @return {function} callback with error, object data result
 * and responseMetaHeaders as arguments
 *
 */

export default
function objectGet(accessKey, datastore,  metastore, request, callback) {
    const bucketname = utils.getResourceNames(request).bucket;
    const bucketUID = utils.getResourceUID(request.namespace, bucketname);
    const objectKey = utils.getResourceNames(request).object;
    const metadataValParams = {
        accessKey: accessKey,
        bucketUID: bucketUID,
        objectKey: objectKey,
        metastore: metastore};
    const metadataCheckParams = {headers: request.lowerCaseHeaders};

    async.waterfall([
        function waterfall1(next) {
            services.metadataValidateAuthorization(metadataValParams, next);
        },
        function waterfall2(bucket, objectMetadata, next) {
            services.metadataChecks(bucket, objectMetadata,
            metadataCheckParams, next);
        },
        function waterfall3(bucket, objectMetadata, metaHeaders, next) {
            services.getFromDatastore(bucket, objectMetadata,
            metaHeaders, datastore, next);
        }
    ], function waterfallFinal(err, result, responseMetaHeaders) {
        return callback(err, result, responseMetaHeaders);
    });
}

{'fraction_non_alphanumeric': 0.09751327186364907, 'fraction_numerical': 0.0008382229673093043, 'mean_word_length': 3.578005115089514, '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': '6846357', 'n_tokens_mistral': 918, 'n_tokens_neox': 912, 'n_words': 271}