<commit_before>/** @module database */

import { DBLogger, logger } from '../utils/dev-tools'
import config from '../config'

var AWS = require('aws-sdk')

AWS.config.update({
  region: config.AWS_REGION,
  endpoint: config.DYNAMODB_ENDPOINT,
  accessKeyId: config.AWS_ACCESS_KEY_ID,
  secretAccessKey: config.AWS_SECRET_ACCESS_KEY
})

var dynamoDb = new AWS.DynamoDB.DocumentClient()

/** Dynamo DB wrapper. */
var database = {}

/**
 * Represents a put operation.
 * @param {Object} params - the query parameters.
 * @return {Promise<Object>} A promise that resolve
 * into the response data.
 */
database.put = function (params) {
  DBLogger.action('put', params)
  return dynamoDb.put(params).promise()
    .then(data => {
      DBLogger.response('put', data)
      return data
    })
    .catch(err => {
      logger.error(err)
    })
}

/**
 * Represents a get operation.
 * @param {Object} params - the query parameters.
 * @return {Promise<Object>} A promise that resolve
 * into the response data.
 */
database.get = function (params) {
  DBLogger.action('get', params)
  return dynamoDb.get(params).promise()
    .then(data => {
      DBLogger.response('get', data)
      return data
    })
    .catch(err => {
      logger.error(err)
    })
}

/**
 * Represents a batchGet operation.
 * @param {Object} params - the query parameters.
 * @return {Promise<Object>} A promise that resolve
 * into the response data.
 */
database.batchGet = function (params) {
  DBLogger.action('batchGet', params)
  return dynamoDb.batchGet(params).promise()
    .then(data => {
      DBLogger.response('get', data)
      return data
    })
    .catch(err => {
      logger.error(err)
    })
}

/**
 * Represents a query operation.
 * @param {Object} params - the query parameters.
 * @return {Promise<Object>} A promise that resolve
 * into the response data.
 */
database.query = function (params) {
  DBLogger.action('query', params)
  return dynamoDb.query(params).promise()
    .then(data => {
      DBLogger.response('query', data)
      return data
    })
    .catch(err => {
      logger.error(err)
    })
}

/**
 * Represents a scan operation.
 * @param {Object} params - the query parameters.
 * @return {Promise<Object>} A promise that resolve
 * into the response data.
 */
database.scan = function (params) {
  DBLogger.action('scan', params)
  return dynamoDb.scan(params).promise()
    .then(data => {
      DBLogger.response('scan', data)
      return data
    })
    .catch(err => {
      logger.error(err)
    })
}

/**
 * Represents an update operation.
 * @param {Object} params - the query parameters.
 * @return {Promise<Object>} A promise that resolve
 * into the response data.
 */
database.update = function (params) {
  DBLogger.action('update', params)
  return dynamoDb.update(params).promise()
    .then(data => {
      DBLogger.response('update', data)
      return data
    })
    .catch(err => {
      logger.error(err)
    })
}

/** Dynamo DB wrapper. */
export default database
<commit_msg>Try DB client without access keys.<commit_after>/** @module database */

import { DBLogger, logger } from '../utils/dev-tools'
import config from '../config'

var AWS = require('aws-sdk')

AWS.config.update({
  region: config.AWS_REGION,
  endpoint: config.DYNAMODB_ENDPOINT
})

var dynamoDb = new AWS.DynamoDB.DocumentClient()

/** Dynamo DB wrapper. */
var database = {}

/**
 * Represents a put operation.
 * @param {Object} params - the query parameters.
 * @return {Promise<Object>} A promise that resolve
 * into the response data.
 */
database.put = function (params) {
  DBLogger.action('put', params)
  return dynamoDb.put(params).promise()
    .then(data => {
      DBLogger.response('put', data)
      return data
    })
    .catch(err => {
      logger.error(err)
    })
}

/**
 * Represents a get operation.
 * @param {Object} params - the query parameters.
 * @return {Promise<Object>} A promise that resolve
 * into the response data.
 */
database.get = function (params) {
  DBLogger.action('get', params)
  return dynamoDb.get(params).promise()
    .then(data => {
      DBLogger.response('get', data)
      return data
    })
    .catch(err => {
      logger.error(err)
    })
}

/**
 * Represents a batchGet operation.
 * @param {Object} params - the query parameters.
 * @return {Promise<Object>} A promise that resolve
 * into the response data.
 */
database.batchGet = function (params) {
  DBLogger.action('batchGet', params)
  return dynamoDb.batchGet(params).promise()
    .then(data => {
      DBLogger.response('get', data)
      return data
    })
    .catch(err => {
      logger.error(err)
    })
}

/**
 * Represents a query operation.
 * @param {Object} params - the query parameters.
 * @return {Promise<Object>} A promise that resolve
 * into the response data.
 */
database.query = function (params) {
  DBLogger.action('query', params)
  return dynamoDb.query(params).promise()
    .then(data => {
      DBLogger.response('query', data)
      return data
    })
    .catch(err => {
      logger.error(err)
    })
}

/**
 * Represents a scan operation.
 * @param {Object} params - the query parameters.
 * @return {Promise<Object>} A promise that resolve
 * into the response data.
 */
database.scan = function (params) {
  DBLogger.action('scan', params)
  return dynamoDb.scan(params).promise()
    .then(data => {
      DBLogger.response('scan', data)
      return data
    })
    .catch(err => {
      logger.error(err)
    })
}

/**
 * Represents an update operation.
 * @param {Object} params - the query parameters.
 * @return {Promise<Object>} A promise that resolve
 * into the response data.
 */
database.update = function (params) {
  DBLogger.action('update', params)
  return dynamoDb.update(params).promise()
    .then(data => {
      DBLogger.response('update', data)
      return data
    })
    .catch(err => {
      logger.error(err)
    })
}

/** Dynamo DB wrapper. */
export default database

{'fraction_non_alphanumeric': 0.14640281737380514, 'fraction_numerical': 0.0, 'mean_word_length': 3.0488798370672097, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 39, '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': '4304896', 'n_tokens_mistral': 1862, 'n_tokens_neox': 1909, 'n_words': 487}