function normalizeHeaders(event, lowerCaseKey = false) {
  const headers = event.multiValueHeaders ?? event.headers

  if (!headers) {
    return {}
  }

  return Object.fromEntries(
    Object.entries(headers).map(([headerKey, headerValue]) => {
      const newKey = lowerCaseKey ? headerKey.toLowerCase() : headerKey

      if (Array.isArray(headerValue)) {
        return [newKey, headerValue.join(',')]
      }
      return [newKey, headerValue]
    })
  )
}
Normalizes both request and response headers,
either from Multi Value headers or "normal" headers to a
lowercase key map with comma separated string

@param {object} event The event with headers to normalize
@param {boolean} lowerCaseKey Whether to lowercase the header names or not
@returns {Object<string, string>} The normalized headers map