<commit_before>import aws from 'aws-sdk'
import path from 'path'
import { Readable } from 'stream'
import { FileStore } from './store'

// How long browsers can cache resources for (in seconds). These resources should all be pretty
// static, so this can be a long time
export const FILE_MAX_AGE_SECONDS = 14 * 24 * 60 * 60

// Convert some of the more frequently used options to the AWS formatting
function formatOptions(options: any = {}) {
  const formatted = { ...options }
  if (options.cache) {
    formatted.CacheControl = options.cache
  }
  if (options.type) {
    formatted.ContentType = options.type
  }
  if (options.expires) {
    formatted.Expires = options.expires
  }

  return formatted
}

// This is a generic implementation of a file-store using the aws-sdk. Note however, that it can be
// used by any compatible storage provider, e.g. DigitalOcean Spaces or Amazon S3.
export default class Aws implements FileStore {
  readonly bucket: string
  readonly client: aws.S3
  readonly cdnHost: string | undefined

  constructor({
    endpoint,
    accessKeyId,
    secretAccessKey,
    region,
    bucket,
    cdnHost,
  }: {
    endpoint: string
    accessKeyId: string
    secretAccessKey: string
    region: string
    bucket: string
    cdnHost?: string
  }) {
    const options: aws.S3.ClientConfiguration = {
      accessKeyId,
      secretAccessKey,
    }

    // DO Spaces use endpoints
    if (endpoint) {
      options.endpoint = new aws.Endpoint(endpoint)
    }
    // Amazon S3 uses regions
    if (region) {
      options.region = region
    }

    this.bucket = bucket
    this.client = new aws.S3(options)
  }<commit_msg>It would probably help if I actually assigned the field from the constructor params...<commit_after>import aws from 'aws-sdk'
import path from 'path'
import { Readable } from 'stream'
import { FileStore } from './store'

// How long browsers can cache resources for (in seconds). These resources should all be pretty
// static, so this can be a long time
export const FILE_MAX_AGE_SECONDS = 14 * 24 * 60 * 60

// Convert some of the more frequently used options to the AWS formatting
function formatOptions(options: any = {}) {
  const formatted = { ...options }
  if (options.cache) {
    formatted.CacheControl = options.cache
  }
  if (options.type) {
    formatted.ContentType = options.type
  }
  if (options.expires) {
    formatted.Expires = options.expires
  }

  return formatted
}

// This is a generic implementation of a file-store using the aws-sdk. Note however, that it can be
// used by any compatible storage provider, e.g. DigitalOcean Spaces or Amazon S3.
export default class Aws implements FileStore {
  readonly bucket: string
  readonly client: aws.S3
  readonly cdnHost: string | undefined

  constructor({
    endpoint,
    accessKeyId,
    secretAccessKey,
    region,
    bucket,
    cdnHost,
  }: {
    endpoint: string
    accessKeyId: string
    secretAccessKey: string
    region: string
    bucket: string
    cdnHost?: string
  }) {
    const options: aws.S3.ClientConfiguration = {
      accessKeyId,
      secretAccessKey,
    }

    // DO Spaces use endpoints
    if (endpoint) {
      options.endpoint = new aws.Endpoint(endpoint)
    }
    // Amazon S3 uses regions
    if (region) {
      options.region = region
    }

    this.bucket = bucket
    this.client = new aws.S3(options)
    this.cdnHost = cdnHost
  }
{'fraction_non_alphanumeric': 0.08607520564042304, 'fraction_numerical': 0.00763807285546416, 'mean_word_length': 2.9092996555683124, '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': '6620028', 'n_tokens_mistral': 1016, 'n_tokens_neox': 987, 'n_words': 353}