Comparing version 0.1.1 to 0.1.2
@@ -46,3 +46,10 @@ (function() { | ||
var _ref; | ||
body = JSON.parse(body || '{}'); | ||
if (Math.floor(res.statusCode / 100) === 5) { | ||
return callback(new Error('Error ' + res.statusCode)); | ||
} | ||
try { | ||
body = JSON.parse(body || '{}'); | ||
} catch (err) { | ||
return callback(err); | ||
} | ||
if (res.statusCode === 422) return callback(new Error(body.message)); | ||
@@ -49,0 +56,0 @@ if ((_ref = res.statusCode) === 400 || _ref === 401 || _ref === 404) { |
@@ -193,2 +193,13 @@ (function() { | ||
Me.prototype.createRepo = function(repo, cb) { | ||
return this.client.post("/user/repos", repo, function(err, s, b) { | ||
if (err) return cb(err); | ||
if (s !== 201) { | ||
return cb(new Error('User createRepo error')); | ||
} else { | ||
return cb(null, b); | ||
} | ||
}); | ||
}; | ||
return Me; | ||
@@ -195,0 +206,0 @@ |
@@ -23,2 +23,14 @@ (function() { | ||
Repository.prototype._invokePost = function(path, body, expectedStatus, methodName, cb) { | ||
if (expectedStatus == null) expectedStatus = 202; | ||
return this.client.post(path, body, function(err, s, b) { | ||
if (err) return cb(err); | ||
if (s !== expectedStatus) { | ||
return cb(new Error("Repository." + methodName + " error")); | ||
} else { | ||
return cb(null, b); | ||
} | ||
}); | ||
}; | ||
Repository.prototype.info = function(cb) { | ||
@@ -36,2 +48,30 @@ return this._invokeGet("/repos/" + this.name, 200, "info", cb); | ||
Repository.prototype.getLanguages = function(cb) { | ||
return this._invokeGet("/repos/" + this.name + "/languages", 200, "getLanguages", cb); | ||
}; | ||
Repository.prototype.getContributors = function(cb) { | ||
return this._invokeGet("/repos/" + this.name + "/contributors", 200, "getContributors", cb); | ||
}; | ||
Repository.prototype.getTeams = function(cb) { | ||
return this._invokeGet("/repos/" + this.name + "/teams", 200, "getTeams", cb); | ||
}; | ||
Repository.prototype.getBranches = function(cb) { | ||
return this._invokeGet("/repos/" + this.name + "/branches", 200, "getBranches", cb); | ||
}; | ||
Repository.prototype.getIssues = function(cb) { | ||
return this._invokeGet("/repos/" + this.name + "/issues", 200, "getIssues", cb); | ||
}; | ||
Repository.prototype.getForks = function(cb) { | ||
return this._invokeGet("/repos/" + this.name + "/forks", 200, "getForks", cb); | ||
}; | ||
Repository.prototype.createFork = function(cb) { | ||
return this._invokePost("/repos/" + this.name + "/forks", {}, 202, "createFork", cb); | ||
}; | ||
return Repository; | ||
@@ -38,0 +78,0 @@ |
{ | ||
"name": "octonode", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"author": "Pavan Kumar Sunkara <pavan.sss1991@gmail.com> (http://pksunkara.github.com)", | ||
@@ -19,4 +19,4 @@ "description": "nodejs wrapper for github v3 api", | ||
"scripts": { | ||
"prepublish": "cake lib", | ||
"test": "NODE_ENV=test node_modules/.bin/mocha --require assert --require should --globals name -R spec $(find test -name '*.coffee')" | ||
"prepublish": "./node_modules/.bin/cake lib", | ||
"test": "./node_modules/.bin/vows --spec $(find test -name '[^nock]*.coffee')" | ||
}, | ||
@@ -38,12 +38,8 @@ "contributors": [ | ||
"dependencies": { | ||
"request": "*" | ||
"request": "2.9.x" | ||
}, | ||
"devDependencies": { | ||
"nock": "0.7.x", | ||
"mocha": "0.7.x", | ||
"sinon": "1.2.x", | ||
"async": "0.1.x", | ||
"should": "~0.2.1", | ||
"underscore": "1.2.x", | ||
"coffee-script": "1.1.2" | ||
"vows": "0.6.x", | ||
"coffee-script": "1.2.x" | ||
}, | ||
@@ -50,0 +46,0 @@ "engines": { |
@@ -15,2 +15,4 @@ # octonode | ||
// Then we instanciate a client with or without a token (as show in a later section) | ||
var ghme = client.me(); | ||
@@ -32,3 +34,3 @@ var ghuser = client.user('pkumar'); | ||
password: 'password' | ||
}).login(['user', 'repo', 'gist'], function (token) { | ||
}).login(['user', 'repo', 'gist'], function (err, token) { | ||
console.log(token); | ||
@@ -62,3 +64,3 @@ }); | ||
else if (uri.pathname=='/auth') { | ||
github.auth.login(qs.parse(uri.query).code, function (token) { | ||
github.auth.login(qs.parse(uri.query).code, function (err, token) { | ||
console.log(token); | ||
@@ -82,3 +84,3 @@ }); | ||
client.get('/users/pkumar', function (status, body) { | ||
client.get('/users/pkumar', function (err, status, body) { | ||
console.log(body); //json object | ||
@@ -93,3 +95,3 @@ }); | ||
client.get('/user', function (status, body) { | ||
client.get('/user', function (err, status, body) { | ||
console.log(body); //json object | ||
@@ -99,8 +101,15 @@ }); | ||
__All the callbacks for the following will take only a data argument__ | ||
## Github authenticated user api | ||
Token required for the following | ||
__All the callbacks for the following will take first an error argument, then a data argument, like this:__ | ||
```js | ||
ghme.info(function(err, data) { | ||
console.log("error: " + err); | ||
console.log("data: " + data); | ||
}); | ||
``` | ||
Token required for the following: | ||
### Get information about the user (GET /user) | ||
@@ -107,0 +116,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
46392
3
28
511
0
407
+ Addedrequest@2.9.203(transitive)
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.9.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
Updatedrequest@2.9.x