Socket
Socket
Sign inDemoInstall

octonode

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

octonode - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

src/octonode.coffee

9

lib/octonode/client.js

@@ -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 @@

16

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc