<commit_before>/* eslint no-console:0 */
// TODO: remove eslint-disable

import { URL } from 'url'
import fetch from 'node-fetch'
import aws4 from 'aws4'

const redisAccessEndpoint = `${process.env.REDIS_SERVICE_ENDPOINT}/redis/`

// TODO:
//   - call to get/set values
//   - gracefully handle Redis downtime or missing cache value
const callRedis = async data => {
  let responseData
  try {
    // Add AWS IAM authorization.
    // https://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
    // https://docs.aws.amazon.com/general/latest/gr/signature-v4-examples.html#signature-v4-examples-javascript
    // https://github.com/mhart/aws4
    const endpointURL = new URL(redisAccessEndpoint)
    const body = JSON.stringify(data)
    const authorizationInfo = aws4.sign({
      host: endpointURL.host,
      path: endpointURL.pathname,
      method: 'POST',
      body,
    })

    console.log('===== Calling Redis service =====', redisAccessEndpoint)
    const response = await fetch(redisAccessEndpoint, {
      method: 'POST',
      headers: {
        ...authorizationInfo.headers,
      },
      body,
    })
    responseData = await response.json()
  } catch (e) {
    console.log('Error calling Redis service', e)<commit_msg>Remove trailing slash<commit_after>/* eslint no-console:0 */
// TODO: remove eslint-disable

import { URL } from 'url'
import fetch from 'node-fetch'
import aws4 from 'aws4'

const redisAccessEndpoint = `${process.env.REDIS_SERVICE_ENDPOINT}/redis`

// TODO:
//   - call to get/set values
//   - gracefully handle Redis downtime or missing cache value
const callRedis = async data => {
  let responseData
  try {
    // Add AWS IAM authorization.
    // https://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
    // https://docs.aws.amazon.com/general/latest/gr/signature-v4-examples.html#signature-v4-examples-javascript
    // https://github.com/mhart/aws4
    const endpointURL = new URL(redisAccessEndpoint)
    const body = JSON.stringify(data)
    const authorizationInfo = aws4.sign({
      host: endpointURL.host,
      path: endpointURL.pathname,
      method: 'POST',
      body,
    })

    console.log('===== Calling Redis service =====', redisAccessEndpoint)
    const response = await fetch(redisAccessEndpoint, {
      method: 'POST',
      headers: {
        ...authorizationInfo.headers,
      },
      body,
    })
    responseData = await response.json()
  } catch (e) {
    console.log('Error calling Redis service', e)
{'fraction_non_alphanumeric': 0.13127258129265354, 'fraction_numerical': 0.006423123243677238, 'mean_word_length': 2.9935897435897436, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 6, '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': '5683155', 'n_tokens_mistral': 777, 'n_tokens_neox': 768, 'n_words': 179}