How to use the ipfsd-ctl.disposable function in ipfsd-ctl

To help you get started, we’ve selected a few ipfsd-ctl 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 / test / ipfs-factory / daemon-spawner.js View on Github external
function spawnEphemeralNode (callback) {
  ipfsd.disposable((err, node) => {
    if (err) {
      return callback(err)
    }

    // Note: we have to set each config value
    // independently since the config/replace endpoint
    // doesn't work as expected
    series([
      (cb) => {
        const configValues = {
          Bootstrap: [],
          Discovery: {},
          'API.HTTPHeaders.Access-Control-Allow-Origin': ['*'],
          // This is not needed after all
          // 'API.HTTPHeaders.Access-Control-Allow-Credentials': true,
          'API.HTTPHeaders.Access-Control-Allow-Methods': [
github ipfs / js-ipfs / test / utils / interop-daemon-spawner / go.js View on Github external
(cb) => {
        if (this.disposable) {
          const config = Object.assign({ init: this.init }, this.config)
          ctl.disposable(config, cb)
        } else if (this.init) {
          ctl.local(this.path, (err, node) => {
            if (err) {
              return cb(err)
            }
            node.init((err) => cb(err, node))
          })
        } else {
          ctl.local(this.path, cb)
        }
      },
      (node, cb) => {
github ipfs / js-ipfs-http-client / test / setup / spawn-daemons.js View on Github external
function startIndependentNode (nodes, key, cb) {
    ipfsd.disposable((err, node) => {
      if (err) {
        return cb(err)
      }

      nodes[key] = node

      console.log('  ipfs init done - (bootstrap and mdns off) - ' + key)

      const configValues = {
        Bootstrap: [],
        Discovery: {},
        'API.HTTPHeaders.Access-Control-Allow-Origin': ['*'],
        'API.HTTPHeaders.Access-Control-Allow-Credentials': 'true',
        'API.HTTPHeaders.Access-Control-Allow-Methods': ['PUT', 'POST', 'GET']
      }