Merge remote-tracking branch 'origin/v0.8'
[platform/upstream/nodejs.git] / deps / npm / node_modules / npm-registry-client / README.md
1 # npm-registry-client
2
3 The code that npm uses to talk to the registry.
4
5 It handles all the caching and HTTP calls.
6
7 ## Usage
8
9 ```javascript
10 var RegClient = require('npm-registry-client')
11 var client = new RegClient(options)
12
13 client.get("npm", "latest", 1000, function (er, data, raw, res) {
14   // error is an error if there was a problem.
15   // data is the parsed data object
16   // raw is the json string
17   // res is the response from couch
18 })
19 ```
20
21 # Options
22
23 * `registry` **Required** {String} URL to the registry
24 * `cache` **Required** {String} Path to the cache folder
25 * `alwaysAuth` {Boolean} Auth even for GET requests.
26 * `auth` {String} A base64-encoded `username:password`
27 * `email` {String} User's email address
28 * `tag` {String} The default tag to use when publishing new packages.
29   Default = `"latest"`
30 * `ca` {String} Cerficate signing authority certificates to trust.
31 * `strictSSL` {Boolean} Whether or not to be strict with SSL
32   certificates.  Default = `true`
33 * `userAgent` {String} User agent header to send.  Default =
34   `"node/{process.version}"`
35 * `log` {Object} The logger to use.  Defaults to `require("npmlog")` if
36   that works, otherwise logs are disabled.
37 * `retries` {Number} Number of times to retry on GET failures.
38   Default=2
39 * `retryFactor` {Number} `factor` setting for `node-retry`. Default=10
40 * `retryMinTimeout` {Number} `minTimeout` setting for `node-retry`.
41   Default=10000 (10 seconds)
42 * `retryMaxTimeout` {Number} `maxTimeout` setting for `node-retry`.
43   Default=60000 (60 seconds)
44
45 # client.request(method, where, [what], [etag], [nofollow], cb)
46
47 * `method` {String} HTTP method
48 * `where` {String} Path to request on the server
49 * `what` {Stream | Buffer | String | Object} The request body.  Objects
50   that are not Buffers or Streams are encoded as JSON.
51 * `etag` {String} The cached ETag
52 * `nofollow` {Boolean} Prevent following 302/301 responses
53 * `cb` {Function}
54   * `error` {Error | null}
55   * `data` {Object} the parsed data object
56   * `raw` {String} the json
57   * `res` {Response Object} response from couch
58
59 Make a request to the registry.  All the other methods are wrappers
60 around this. one.
61
62 # client.adduser(username, password, email, cb)
63
64 * `username` {String}
65 * `password` {String}
66 * `email` {String}
67 * `cb` {Function}
68
69 Add a user account to the registry, or verify the credentials.
70
71 # client.get(url, [timeout], [nofollow], [staleOk], cb)
72
73 * `url` {String} The url path to fetch
74 * `timeout` {Number} Number of seconds old that a cached copy must be
75   before a new request will be made.
76 * `nofollow` {Boolean} Do not follow 301/302 responses
77 * `staleOk` {Boolean} If there's cached data available, then return that
78   to the callback quickly, and update the cache the background.
79
80 Fetches data from the registry via a GET request, saving it in
81 the cache folder with the ETag.
82
83 # client.publish(data, tarball, [readme], cb)
84
85 * `data` {Object} Package data
86 * `tarball` {String | Stream} Filename or stream of the package tarball
87 * `readme` {String} Contents of the README markdown file
88 * `cb` {Function}
89
90 Publish a package to the registry.
91
92 Note that this does not create the tarball from a folder.  However, it
93 can accept a gzipped tar stream or a filename to a tarball.
94
95 # client.star(package, starred, cb)
96
97 * `package` {String} Name of the package to star
98 * `starred` {Boolean} True to star the package, false to unstar it.
99 * `cb` {Function}
100
101 Star or unstar a package.
102
103 Note that the user does not have to be the package owner to star or
104 unstar a package, though other writes do require that the user be the
105 package owner.
106
107 # client.tag(project, version, tag, cb)
108
109 * `project` {String} Project name
110 * `version` {String} Version to tag
111 * `tag` {String} Tag name to apply
112 * `cb` {Function}
113
114 Mark a version in the `dist-tags` hash, so that `pkg@tag`
115 will fetch the specified version.
116
117 # client.unpublish(name, [ver], cb)
118
119 * `name` {String} package name
120 * `ver` {String} version to unpublish. Leave blank to unpublish all
121   versions.
122 * `cb` {Function}
123
124 Remove a version of a package (or all versions) from the registry.  When
125 the last version us unpublished, the entire document is removed from the
126 database.
127
128 # client.upload(where, file, [etag], [nofollow], cb)
129
130 * `where` {String} URL path to upload to
131 * `file` {String | Stream} Either the filename or a readable stream
132 * `etag` {String} Cache ETag
133 * `nofollow` {Boolean} Do not follow 301/302 responses
134 * `cb` {Function}
135
136 Upload an attachment.  Mostly used by `client.publish()`.