<commit_before>

/**
 * Generate options services.
 *
 * @param {Object} services
 * @api private
 */

module.exports = services => {
  const options = methods(services)
  services.options = services.options || {}
  Object.keys(options).map(path => {
    services.options = {
      ...services.options,
      [path] : {
        service() {
          return {}
        }
      }
    }
  })
  return services
}


/**
 * Extract allowed methods from a resource.
 *
 * @param {Object} resource
 * @return {Object}
 * @api private
 */

function methods (resource) {
  const result = {}
  Object.keys(resource).map(method => {
    Object.keys(resource[method]).map(path => {
      const option = result[path] = result[path] || {}
      const allowed = option.methods = (option.methods || [])
      allowed.push(method)
    })
  })
  return result
}
<commit_msg>Generate methods options<commit_after>

/**
 * Generate options services.
 *
 * @param {Object} services
 * @api private
 */

module.exports = services => {
  const options = methods(services)
  services.options = services.options || {}
  Object.keys(options).map(path => {
    services.options = {
      ...services.options,
      [path] : {
        service(data, req, res) {
          const head = headers(options[path])
          if (res) res.writeHead(200, head)
          return head
        }
      }
    }
  })
  return services
}


/**
 * Extract allowed methods from a resource.
 *
 * @param {Object} resource
 * @return {Object}
 * @api private
 */

function methods (resource) {
  const result = {}
  Object.keys(resource).map(method => {
    Object.keys(resource[method]).map(path => {
      const option = result[path] = result[path] || {}
      const allowed = option.methods = (option.methods || [])
      allowed.push(method)
    })
  })
  return result
}


/**
 * Generate options headers from object.
 *
 * @param {Object} obj
 * @return {Object}
 * @api private
 */

function headers (obj) {
  return {
    'Access-Control-Allow-Origin': '*',
    'Access-Control-Allow-Methods': `${obj.methods.map(method => method.toUpperCase()).join(', ')}, OPTIONS`,
    'Access-Control-Allow-Headers': 'Origin, Content-Type, Authorization, Content-Length, X-Requested-With'
  }
}

{'fraction_non_alphanumeric': 0.15841142347166443, 'fraction_numerical': 0.0013386880856760374, 'mean_word_length': 2.7242524916943522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '1722818', 'n_tokens_mistral': 685, 'n_tokens_neox': 676, 'n_words': 149}