How to use the npm-registry-fetch.json function in npm-registry-fetch

To help you get started, we’ve selected a few npm-registry-fetch 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 graalvm / graaljs / deps / npm / lib / unpublish.js View on Github external
return libaccess.lsPackages(username, opts).then(access => {
      // do a bit of filtering at this point, so that we don't need
      // to fetch versions for more than one thing, but also don't
      // accidentally a whole project.
      let pkgs = Object.keys(access)
      if (!cliOpts.partialWord || !pkgs.length) { return pkgs }
      const pp = npa(cliOpts.partialWord).name
      pkgs = pkgs.filter(p => !p.indexOf(pp))
      if (pkgs.length > 1) return pkgs
      return npmFetch.json(npa(pkgs[0]).escapedName, opts).then(doc => {
        const vers = Object.keys(doc.versions)
        if (!vers.length) {
          return pkgs
        } else {
          return vers.map(v => `${pkgs[0]}@${v}`)
        }
      })
    })
  }).nodeify(cb)
github npm / npm-profile / lib / index.js View on Github external
const body = {
    _id: 'org.couchdb.user:' + username,
    name: username,
    password: password,
    type: 'user',
    roles: [],
    date: new Date().toISOString()
  }
  const logObj = {}
  Object.keys(body).forEach(k => {
    logObj[k] = k === 'password' ? 'XXXXX' : body[k]
  })
  process.emit('log', 'verbose', 'login', 'before first PUT', logObj)

  const target = '-/user/org.couchdb.user:' + encodeURIComponent(username)
  return fetch.json(target, opts.concat({
    method: 'PUT',
    body
  })).catch(err => {
    if (err.code === 'E400') {
      err.message = `There is no user with the username "${username}".`
      throw err
    }
    if (err.code !== 'E409') throw err
    return fetch.json(target, opts.concat({
      query: {write: true}
    })).then(result => {
      Object.keys(result).forEach(function (k) {
        if (!body[k] || k === 'roles') {
          body[k] = result[k]
        }
      })
github npm / npm-profile / lib / index.js View on Github external
_id: 'org.couchdb.user:' + username,
    name: username,
    password: password,
    email: email,
    type: 'user',
    roles: [],
    date: new Date().toISOString()
  }
  const logObj = {}
  Object.keys(body).forEach(k => {
    logObj[k] = k === 'password' ? 'XXXXX' : body[k]
  })
  process.emit('log', 'verbose', 'adduser', 'before first PUT', logObj)

  const target = '/-/user/org.couchdb.user:' + encodeURIComponent(username)
  return fetch.json(target, opts.concat({
    method: 'PUT',
    body
  })).then(result => {
    result.username = username
    return result
  })
}
github graalvm / graaljs / graal-nodejs / deps / npm / node_modules / libnpmorg / index.js View on Github external
return new opts.Promise((resolve, reject) => {
    validate('SSSO|SSZO', [org, user, role, opts])
    user = user.replace(/^@?/, '')
    org = org.replace(/^@?/, '')
    fetch.json(`/-/org/${eu(org)}/user`, opts.concat({
      method: 'PUT',
      body: { user, role }
    })).then(resolve, reject)
  }).then(ret => Object.assign(new MembershipDetail(), ret))
}
github npm / npm-profile / lib / index.js View on Github external
function get (opts) {
  validate('O', arguments)
  return fetch.json('/-/npm/v1/user', opts)
}
github npm / libnpmhook / index.js View on Github external
cmd.find = (id, opts) => {
  opts = HooksConfig(opts)
  validate('SO', [id, opts])
  return fetch.json(`/-/npm/v1/hooks/hook/${eu(id)}`, opts)
}
github npm / npm-profile / lib / index.js View on Github external
function untilLastPage (href, objects) {
    return fetch.json(href, opts).then(result => {
      objects = objects ? objects.concat(result.objects) : result.objects
      if (result.urls.next) {
        return untilLastPage(result.urls.next, objects)
      } else {
        return objects
      }
    })
  }
}
github npm / libnpmhook / index.js View on Github external
cmd.rm = (id, opts) => {
  opts = HooksConfig(opts)
  validate('SO', [id, opts])
  return fetch.json(`/-/npm/v1/hooks/hook/${eu(id)}`, opts.concat({
    method: 'DELETE'
  }, opts)).catch(err => {
    if (err.code === 'E404') {
      return null
    } else {
      throw err
    }
  })
}
github npm / npm-profile / lib / index.js View on Github external
})).then(result => {
      Object.keys(result).forEach(function (k) {
        if (!body[k] || k === 'roles') {
          body[k] = result[k]
        }
      })
      return fetch.json(`${target}/-rev/${body._rev}`, opts.concat({
        method: 'PUT',
        body,
        forceAuth: {
          username,
          password: Buffer.from(password, 'utf8').toString('base64'),
          otp: opts.otp
        }
      }))
    })
  }).then(result => {

npm-registry-fetch

Fetch-based http client for use with npm registry APIs

ISC
Latest version published 2 months ago

Package Health Score

92 / 100
Full package analysis