2015-01-09 06:37:26 +08:00
|
|
|
module.exports = stars
|
|
|
|
|
|
|
|
var assert = require("assert")
|
2014-08-01 00:05:30 +08:00
|
|
|
var url = require("url")
|
|
|
|
|
2015-01-09 06:37:26 +08:00
|
|
|
function stars (uri, params, cb) {
|
|
|
|
assert(typeof uri === "string", "must pass registry URI to stars")
|
|
|
|
assert(params && typeof params === "object", "must pass params to stars")
|
|
|
|
assert(typeof cb === "function", "must pass callback to stars")
|
|
|
|
|
|
|
|
var auth = params.auth
|
|
|
|
var name = params.username || (auth && auth.username)
|
|
|
|
if (!name) return cb(new Error("must pass either username or auth to stars"))
|
|
|
|
var encoded = encodeURIComponent(name)
|
|
|
|
var path = "-/_view/starredByUser?key=\""+encoded+"\""
|
2013-02-16 02:49:16 +08:00
|
|
|
|
2015-01-09 06:37:26 +08:00
|
|
|
this.request(url.resolve(uri, path), { auth : auth }, cb)
|
2013-02-16 02:49:16 +08:00
|
|
|
}
|