isaacs
217bb0c964
|
11 years ago | |
---|---|---|
.. | ||
lib | 11 years ago | |
test | 11 years ago | |
.npmignore | 13 years ago | |
LICENSE | 13 years ago | |
README.md | 11 years ago | |
index.js | 11 years ago | |
package.json | 11 years ago |
README.md
npm-registry-client
The code that npm uses to talk to the registry.
It handles all the caching and HTTP calls.
Usage
var RegClient = require('npm-registry-client')
var client = new RegClient(config)
client.get("npm", "latest", 1000, function (er, data, raw, res) {
// error is an error if there was a problem.
// data is the parsed data object
// raw is the json string
// res is the response from couch
})
Configuration
This program is designed to work with npmconf, but you can also pass in a plain-jane object with the appropriate configs, and it'll shim it for you. Any configuration thingie that has get/set/del methods will also be accepted.
registry
Required {String} URL to the registrycache
Required {String} Path to the cache folderalways-auth
{Boolean} Auth even for GET requests.auth
{String} A base64-encodedusername:password
email
{String} User's email addresstag
{String} The default tag to use when publishing new packages. Default ="latest"
ca
{String} Cerficate signing authority certificates to trust.cert
{String} Client certificate (PEM encoded). Enable access to servers that require client certificateskey
{String} Private key (PEM encoded) for client certificate 'cert'strict-ssl
{Boolean} Whether or not to be strict with SSL certificates. Default =true
user-agent
{String} User agent header to send. Default ="node/{process.version} {process.platform} {process.arch}"
log
{Object} The logger to use. Defaults torequire("npmlog")
if that works, otherwise logs are disabled.fetch-retries
{Number} Number of times to retry on GET failures. Default=2fetch-retry-factor
{Number}factor
setting fornode-retry
. Default=10fetch-retry-mintimeout
{Number}minTimeout
setting fornode-retry
. Default=10000 (10 seconds)fetch-retry-maxtimeout
{Number}maxTimeout
setting fornode-retry
. Default=60000 (60 seconds)proxy
{URL} The url to proxy requests through.https-proxy
{URL} The url to proxy https requests through. Defaults to be the same asproxy
if unset._auth
{String} The base64-encoded authorization header.username
_password
{String} Username/password to use to generate_auth
if not supplied._token
{Object} A token for use with couch-login
client.request(method, where, [what], [etag], [nofollow], cb)
method
{String} HTTP methodwhere
{String} Path to request on the serverwhat
{Stream | Buffer | String | Object} The request body. Objects that are not Buffers or Streams are encoded as JSON.etag
{String} The cached ETagnofollow
{Boolean} Prevent following 302/301 responsescb
{Function}error
{Error | null}data
{Object} the parsed data objectraw
{String} the jsonres
{Response Object} response from couch
Make a request to the registry. All the other methods are wrappers around this. one.
client.adduser(username, password, email, cb)
username
{String}password
{String}email
{String}cb
{Function}
Add a user account to the registry, or verify the credentials.
client.deprecate(name, version, message, cb)
name
{String} The package nameversion
{String} Semver version rangemessage
{String} The message to use as a deprecation warningcb
{Function}
Deprecate a version of a package in the registry.
client.bugs(name, cb)
name
{String} the name of the packagecb
{Function}
Get the url for bugs of a package
client.get(url, [timeout], [nofollow], [staleOk], cb)
url
{String} The url path to fetchtimeout
{Number} Number of seconds old that a cached copy must be before a new request will be made.nofollow
{Boolean} Do not follow 301/302 responsesstaleOk
{Boolean} If there's cached data available, then return that to the callback quickly, and update the cache the background.
Fetches data from the registry via a GET request, saving it in the cache folder with the ETag.
client.publish(data, tarball, [readme], cb)
data
{Object} Package datatarball
{String | Stream} Filename or stream of the package tarballreadme
{String} Contents of the README markdown filecb
{Function}
Publish a package to the registry.
Note that this does not create the tarball from a folder. However, it can accept a gzipped tar stream or a filename to a tarball.
client.star(package, starred, cb)
package
{String} Name of the package to starstarred
{Boolean} True to star the package, false to unstar it.cb
{Function}
Star or unstar a package.
Note that the user does not have to be the package owner to star or unstar a package, though other writes do require that the user be the package owner.
client.stars(username, cb)
username
{String} Name of user to fetch starred packages for.cb
{Function}
View your own or another user's starred packages.
client.tag(project, version, tag, cb)
project
{String} Project nameversion
{String} Version to tagtag
{String} Tag name to applycb
{Function}
Mark a version in the dist-tags
hash, so that pkg@tag
will fetch the specified version.
client.unpublish(name, [ver], cb)
name
{String} package namever
{String} version to unpublish. Leave blank to unpublish all versions.cb
{Function}
Remove a version of a package (or all versions) from the registry. When the last version us unpublished, the entire document is removed from the database.
client.upload(where, file, [etag], [nofollow], cb)
where
{String} URL path to upload tofile
{String | Stream} Either the filename or a readable streametag
{String} Cache ETagnofollow
{Boolean} Do not follow 301/302 responsescb
{Function}
Upload an attachment. Mostly used by client.publish()
.