Skip to content

Commit

Permalink
refactor: remove deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Nov 17, 2018
1 parent 23d5a7b commit 033254b
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 414 deletions.
12 changes: 0 additions & 12 deletions lib/deprecate.js

This file was deleted.

79 changes: 0 additions & 79 deletions lib/endpoint/index.js

This file was deleted.

53 changes: 0 additions & 53 deletions lib/get-request-agent.js

This file was deleted.

51 changes: 4 additions & 47 deletions lib/parse-client-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ module.exports = parseOptions

const deepmerge = require('deepmerge')
const getUserAgent = require('universal-user-agent')
const isPlainObject = require('is-plain-object')
const pick = require('lodash/pick')

const deprecate = require('./deprecate')
const getRequestAgent = require('./get-request-agent')
const pkg = require('../package.json')

const DEFAULTS = require('./defaults')
Expand All @@ -21,64 +20,22 @@ function parseOptions (userOptions) {
userOptions = {}
}

if ('followRedirects' in userOptions) {
deprecate('followRedirects option is no longer supported. All redirects are followed correctly')
}

if ('protocol' in userOptions) {
deprecate('protocol option is no longer supported')
}

if ('host' in userOptions) {
deprecate('host option is no longer supported')
}

if ('port' in userOptions) {
deprecate('port option is no longer supported')
}

if ('pathPrefix' in userOptions) {
deprecate('pathPrefix option is no longer supported')
}

if ('Promise' in userOptions) {
deprecate('Promise option is no longer supported. The native Promise API is used')
}

if (userOptions.headers) {
userOptions.headers = Object.keys(userOptions.headers).reduce((newObj, key) => {
newObj[key.toLowerCase()] = userOptions.headers[key]
return newObj
}, {})
}

const options = deepmerge(DEFAULTS, pick(userOptions, OPTION_NAMES))
const options = deepmerge(DEFAULTS, pick(userOptions, OPTION_NAMES), { isMergeableObject: isPlainObject })

const clientDefaults = {
baseUrl: options.baseUrl,
headers: options.headers,
request: {
timeout: options.timeout
}
}
if (userOptions.protocol) {
clientDefaults.baseUrl = `${userOptions.protocol}://${userOptions.host}`

/* istanbul ignore else */
if (userOptions.port) {
clientDefaults.baseUrl += `:${userOptions.port}`
timeout: options.timeout,
agent: options.agent
}

// Check if a prefix is passed in the options and strip any leading or trailing slashes from it.
/* istanbul ignore else */
if (userOptions.pathPrefix) {
clientDefaults.baseUrl += '/' + userOptions.pathPrefix.replace(/(^[/]+|[/]+$)/g, '')
}
}
/* istanbul ignore else */

if (!process.browser) {
clientDefaults.request.agent = getRequestAgent(clientDefaults.baseUrl, userOptions)
}

const userAgentOption = clientDefaults.headers['user-agent']
Expand Down
35 changes: 0 additions & 35 deletions lib/plugins/endpoint-methods/method.js

This file was deleted.

39 changes: 0 additions & 39 deletions lib/request/http-error.js

This file was deleted.

Loading

0 comments on commit 033254b

Please sign in to comment.