<commit_before>'use strict';

const SSM = require( './ssm' );

let input = '';

process.stdin.setEncoding( 'utf8' );

process.stdin.on( 'readable', () => {

    let chunk = process.stdin.read();

    if( chunk ) {

        input+= chunk;
    }
});

process.stdin.on( 'end', () => {

    try {

        let query = JSON.parse( input );

        return new SSM().getParameters( query )
            .then( (parameters) => {

                console.log( JSON.stringify( { success: true, result: { parameters } } ) );
                process.exit( 0 );
            })
            .catch( (error) => {

                let resultObj = { success: false, err: { message: error.message, message: error.stacktrace } };

                console.log( JSON.stringify( resultObj ) );
                process.exit( 1 );

            });
    }
    catch( err ) {

        let resultObj = { success: false, err: { message: err.message, message: err.stacktrace } };

        console.log( JSON.stringify( resultObj ) );
        process.exit( 1 );
    }
});<commit_msg>cleaned up code<commit_after>'use strict';

const SSM = require( './ssm' );

function handleError( err ) {

    let resultObj = { success: false, err };

    console.log( JSON.stringify( resultObj ) );
    process.exit( 1 );
}

let input = '';

process.stdin.setEncoding( 'utf8' );

process.stdin.on( 'readable', () => {

    let chunk = process.stdin.read();

    if( chunk ) {

        input+= chunk;
    }
});

process.stdin.on( 'end', () => {

    try {

        let query = JSON.parse( input );

        return new SSM().getParameters( query )
            .then( (parameters) => {

                console.log( JSON.stringify( { success: true, result: { parameters } } ) );
                process.exit( 0 );
            })
            .catch( handleError );
    }
    catch( err ) {

        handleError( err );
    }
});
{'fraction_non_alphanumeric': 0.16302610548748003, 'fraction_numerical': 0.0037293553542887587, 'mean_word_length': 1.8628048780487805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '5413220', 'n_tokens_mistral': 596, 'n_tokens_neox': 559, 'n_words': 133}