How to use the ky-universal.default.extend function in ky-universal

To help you get started, we’ve selected a few ky-universal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipfs / js-ipfs-http-client / src / lib / configure.js View on Github external
// Use configured apiPath, or path on the end of apiAddr (if there is one) or default to /api/v0
  config.apiPath = config.apiPath || config['api-path'] || apiAddrPath || '/api/v0'
  config.apiPath = trimEnd(config.apiPath, '/')

  // If user passed apiAddr with a path, trim it from the end (it is now apiPath)
  config.apiAddr = apiAddrPath ? trimEnd(config.apiAddr, apiAddrPath) : config.apiAddr

  const defaults = {
    prefixUrl: config.apiAddr + config.apiPath,
    timeout: parseTimeout(config.timeout) || 60000 * 20,
    headers: config.headers,
    hooks: {
      afterResponse: [errorHandler]
    }
  }
  const k = ky.extend(defaults)
  const client = ['get', 'post', 'put', 'delete', 'patch', 'head']
    .reduce((client, key) => {
      client[key] = wrap(k[key], defaults)

      return client
    }, wrap(k, defaults))

  return create({
    ky: client,
    ...config
  })
}
github ipfs / js-ipfsd-ctl / src / ipfsd-client.js View on Github external
'use strict'

const multiaddr = require('multiaddr')
const merge = require('merge-options').bind({ ignoreUndefined: true })
const debug = require('debug')
const kyOriginal = require('ky-universal').default

const ky = kyOriginal.extend({ timeout: false })
const daemonLog = {
  info: debug('ipfsd-ctl:client:stdout'),
  err: debug('ipfsd-ctl:client:stderr')
}

/** @typedef {import("./index").ControllerOptions} ControllerOptions */

/**
 * Controller for remote nodes
 * @class
 */
class Client {
  /**
   * @constructor
   * @param {string} baseUrl
   * @param {Object} remoteState