Socket
Socket
Sign inDemoInstall

octonode

Package Overview
Dependencies
1
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.2 to 0.1.3

lib/octonode/org.js

2

lib/octonode.js
(function() {
var octonode;
octonode = module.exports = {

@@ -12,3 +11,2 @@ auth: require('./octonode/auth'),

};
}).call(this);
(function() {
var auth, qs, request;
request = require('request');
qs = require('querystring');
auth = module.exports = {

@@ -79,3 +76,2 @@ modes: {

};
}).call(this);
(function() {
var Client, Me, Organization, Repository, User, request;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
request = require('request');
Me = require('./me');
User = require('./user');
Repository = require('./repository');
Organization = require('./organization');
Client = (function() {
function Client(token) {
this.token = token;
}
Client.prototype.me = function() {
return new Me(this);
};
Client.prototype.user = function(name) {
return new User(name, this);
};
Client.prototype.repository = function(name) {
return new Repository(name, this);
};
Client.prototype.organization = function(name) {
return new Organization(name, this);
};
Client.prototype.query = function(path) {
var uri;
if (path == null) path = '/';
if (path[0] !== '/') path = '/' + path;
if (path == null) {
path = '/';
}
if (path[0] !== '/') {
path = '/' + path;
}
uri = "https://api.github.com" + path;
return uri += this.token ? "?access_token=" + this.token : '';
};
Client.prototype.errorHandle = function(res, body, callback) {

@@ -54,3 +46,5 @@ var _ref;

}
if (res.statusCode === 422) return callback(new Error(body.message));
if (res.statusCode === 422) {
return callback(new Error(body.message));
}
if ((_ref = res.statusCode) === 400 || _ref === 401 || _ref === 404) {

@@ -61,17 +55,17 @@ return callback(new Error(body.message));

};
Client.prototype.get = function(path, callback) {
var _this = this;
return request({
uri: this.query(path),
method: 'GET'
}, function(err, res, body) {
if (err) return callback(err);
return _this.errorHandle(res, body, callback);
});
}, __bind(function(err, res, body) {
if (err) {
return callback(err);
}
return this.errorHandle(res, body, callback);
}, this));
};
Client.prototype.post = function(path, content, callback) {
var _this = this;
if (content == null) content = {};
if (content == null) {
content = {};
}
return request({

@@ -84,11 +78,13 @@ uri: this.query(path),

}
}, function(err, res, body) {
if (err) return callback(err);
return _this.errorHandle(res, body, callback);
});
}, __bind(function(err, res, body) {
if (err) {
return callback(err);
}
return this.errorHandle(res, body, callback);
}, this));
};
Client.prototype.put = function(path, content, callback) {
var _this = this;
if (content == null) content = {};
if (content == null) {
content = {};
}
return request({

@@ -101,11 +97,13 @@ uri: this.query(path),

}
}, function(err, res, body) {
if (err) return callback(err);
return _this.errorHandle(res, body, callback);
});
}, __bind(function(err, res, body) {
if (err) {
return callback(err);
}
return this.errorHandle(res, body, callback);
}, this));
};
Client.prototype.del = function(path, content, callback) {
var _this = this;
if (content == null) content = {};
if (content == null) {
content = {};
}
return request({

@@ -118,14 +116,12 @@ uri: this.query(path),

}
}, function(err, res, body) {
if (err) return callback(err);
return _this.errorHandle(res, body, callback);
});
}, __bind(function(err, res, body) {
if (err) {
return callback(err);
}
return this.errorHandle(res, body, callback);
}, this));
};
return Client;
})();
module.exports = Client;
}).call(this);
(function() {
var Me, User;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
User = require('./user');
Me = (function() {
function Me(client) {
this.client = client;
}
Me.prototype.profile = function(data) {
return Object.keys(data).forEach(__bind(function(e) {
return this[e] = data[e];
}, this));
};
Me.prototype.info = function(cb) {
return this.client.get('/user', function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 200) {

@@ -22,6 +26,7 @@ return cb(new Error('User info error'));

};
Me.prototype.update = function(info, cb) {
return this.client.post('/user', info, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 200) {

@@ -34,3 +39,2 @@ return cb(new Error('User update error'));

};
Me.prototype.emails = function(cbOrEmails, cb) {

@@ -43,3 +47,5 @@ if ((cb != null) && typeof cbOrEmails !== 'function') {

return this.client.get('/user/emails', function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 200) {

@@ -53,6 +59,7 @@ return cb(new Error('User emails error'));

};
Me.prototype.setEmails = function(emails, cb) {
return this.client.post('/user/emails', emails, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 201) {

@@ -65,6 +72,7 @@ return cb(new Error('User setEmails error'));

};
Me.prototype.delEmails = function(emails) {
return this.client.del('/user/emails', emails, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 204) {

@@ -77,6 +85,7 @@ return cb(new Error('User delEmails error'));

};
Me.prototype.followers = function(cb) {
return this.client.get('/user/followers', function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 200) {

@@ -89,3 +98,2 @@ return cb(new Error('User followers error'));

};
Me.prototype.following = function(cbOrUser, cb) {

@@ -96,3 +104,5 @@ if ((cb != null) && typeof cbOrUser !== 'function') {

return this.client.get('/user/following', function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 200) {

@@ -106,13 +116,15 @@ return cb(new Error('User following error'));

};
Me.prototype.checkFollowing = function(cbOrUser, cb) {
return this.client.get("/user/following/" + cbOrUser, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
return cb(null, s === 204);
});
};
Me.prototype.follow = function(user) {
return this.client.put("/user/following/" + user, {}, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 204) {

@@ -125,6 +137,7 @@ return cb(new Error('User follow error'));

};
Me.prototype.unfollow = function(user) {
return this.client.del("/user/following/" + user, {}, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 204) {

@@ -137,3 +150,2 @@ return cb(new Error('User unfollow error'));

};
Me.prototype.keys = function(cbOrIdOrKey, cbOrKey, cb) {

@@ -150,3 +162,5 @@ if (!(cb != null) && typeof cbOrIdOrKey === 'number' && typeof cbOrKey === 'function') {

return this.client.get('/user/keys', function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 200) {

@@ -160,6 +174,7 @@ return cb(new Error('User keys error'));

};
Me.prototype.getKey = function(id, cb) {
return this.client.get("/user/keys/" + id, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 200) {

@@ -172,6 +187,7 @@ return cb(new Error('User getKey error'));

};
Me.prototype.createKey = function(key, cb) {
return this.client.post('/user/keys', key, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 201) {

@@ -184,6 +200,7 @@ return cb(new Error('User createKey error'));

};
Me.prototype.updateKey = function(id, key, cb) {
return this.client.post("/user/keys/" + id, key, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 200) {

@@ -196,6 +213,7 @@ return cb(new Error('User updateKey error'));

};
Me.prototype.delKey = function(id) {
return this.client.del("/user/keys/" + id, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 204) {

@@ -208,6 +226,7 @@ return cb(new Error('User delKey error'));

};
Me.prototype.createRepo = function(repo, cb) {
return this.client.post("/user/repos", repo, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 201) {

@@ -220,9 +239,5 @@ return cb(new Error('User createRepo error'));

};
return Me;
})();
module.exports = Me;
}).call(this);
(function() {
var Organization;
Organization = (function() {
function Organization(name, client) {

@@ -10,6 +8,7 @@ this.name = name;

}
Organization.prototype.info = function(cb) {
return this.client.get("/orgs/" + this.name, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 200) {

@@ -22,9 +21,41 @@ return cb(new Error('Organization info error'));

};
Organization.prototype.getTeams = function(cb) {
return this.client.get("/orgs/" + this.name + "/teams", function(err, s, b) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Organization teams error'));
} else {
return cb(null, b);
}
});
};
Organization.prototype.getMembers = function(cb) {
return this.client.get("/orgs/" + this.name + "/members", function(err, s, b) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Organization members error'));
} else {
return cb(null, b);
}
});
};
Organization.prototype.getMember = function(user, cb) {
return this.client.get("/orgs/" + this.name + "/members/" + user, function(err, s, b) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Organization members error'));
} else {
return cb(null, b);
}
});
};
return Organization;
})();
module.exports = Organization;
}).call(this);
(function() {
var Repository;
Repository = (function() {
function Repository(name, client) {

@@ -10,7 +8,10 @@ this.name = name;

}
Repository.prototype._invokeGet = function(path, expectedStatus, methodName, cb) {
if (expectedStatus == null) expectedStatus = 200;
if (expectedStatus == null) {
expectedStatus = 200;
}
return this.client.get(path, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== expectedStatus) {

@@ -23,7 +24,10 @@ return cb(new Error("Repository." + methodName + " error"));

};
Repository.prototype._invokePost = function(path, body, expectedStatus, methodName, cb) {
if (expectedStatus == null) expectedStatus = 202;
if (expectedStatus == null) {
expectedStatus = 202;
}
return this.client.post(path, body, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== expectedStatus) {

@@ -36,49 +40,113 @@ return cb(new Error("Repository." + methodName + " error"));

};
Repository.prototype.info = function(cb) {
return this._invokeGet("/repos/" + this.name, 200, "info", cb);
return this.client.get("/repos/" + this.name, function(err, s, b) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repository info error"));
} else {
return cb(null, b);
}
});
};
Repository.prototype.getCommits = function(cb) {
return this._invokeGet("/repos/" + this.name + "/commits", 200, "getCommits", cb);
Repository.prototype.commits = function(cb) {
return this.client.get("/repos/" + this.name + "/commits", function(err, s, b) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repository commits error"));
} else {
return cb(null, b);
}
});
};
Repository.prototype.getTags = function(cb) {
return this._invokeGet("/repos/" + this.name + "/tags", 200, "getTags", cb);
Repository.prototype.tags = function(cb) {
return this.client.get("/repos/" + this.name + "/tags", function(err, s, b) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repository tags error"));
} else {
return cb(null, b);
}
});
};
Repository.prototype.getLanguages = function(cb) {
return this._invokeGet("/repos/" + this.name + "/languages", 200, "getLanguages", cb);
Repository.prototype.languages = function(cb) {
return this.client.get("/repos/" + this.name + "/languages", function(err, s, b) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repository languages error"));
} else {
return cb(null, b);
}
});
};
Repository.prototype.getContributors = function(cb) {
return this._invokeGet("/repos/" + this.name + "/contributors", 200, "getContributors", cb);
Repository.prototype.contributors = function(cb) {
return this.client.get("/repos/" + this.name + "/contributors", function(err, s, b) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repository contributors error"));
} else {
return cb(null, b);
}
});
};
Repository.prototype.getTeams = function(cb) {
return this._invokeGet("/repos/" + this.name + "/teams", 200, "getTeams", cb);
Repository.prototype.teams = function(cb) {
return this.client.get("/repos/" + this.name + "/teams", function(err, s, b) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repository teams error"));
} else {
return cb(null, b);
}
});
};
Repository.prototype.getBranches = function(cb) {
return this._invokeGet("/repos/" + this.name + "/branches", 200, "getBranches", cb);
Repository.prototype.branches = function(cb) {
return this.client.get("/repos/" + this.name + "/branches", function(err, s, b) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repository branches error"));
} else {
return cb(null, b);
}
});
};
Repository.prototype.getIssues = function(cb) {
return this._invokeGet("/repos/" + this.name + "/issues", 200, "getIssues", cb);
Repository.prototype.issues = function(cb) {
return this.client.get("/repos/" + this.name + "/issues", function(err, s, b) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repository issues error"));
} else {
return cb(null, b);
}
});
};
Repository.prototype.getForks = function(cb) {
return this._invokeGet("/repos/" + this.name + "/forks", 200, "getForks", cb);
Repository.prototype.forks = function(cb) {
return this.client.get("/repos/" + this.name + "/forks", function(err, s, b) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repository forks error"));
} else {
return cb(null, b);
}
});
};
Repository.prototype.createFork = function(cb) {
return this._invokePost("/repos/" + this.name + "/forks", {}, 202, "createFork", cb);
};
return Repository;
})();
module.exports = Repository;
}).call(this);
(function() {
var User;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
User = (function() {
function User(user, client) {
function User(login, client) {
this.login = login;
this.client = client;
if (typeof user === 'string') {
this.login = user;
} else {
this.profile(user);
}
}
User.prototype.profile = function(data) {
return this.login = data.login;
return Object.keys(data).forEach(__bind(function(e) {
return this[e] = data[e];
}, this));
};
User.prototype.info = function(cb) {
return this.client.get("/users/" + this.login, function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 200) {

@@ -29,6 +26,7 @@ return cb(new Error('User info error'));

};
User.prototype.followers = function(cb) {
return this.client.get("/users/" + this.login + "/followers", function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 200) {

@@ -41,6 +39,7 @@ return cb(new Error('User followers error'));

};
User.prototype.following = function(cb) {
return this.client.get("/users/" + this.login + "/following", function(err, s, b) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (s !== 200) {

@@ -53,9 +52,5 @@ return cb(new Error('User following error'));

};
return User;
})();
module.exports = User;
}).call(this);
{
"name": "octonode",
"version": "0.1.2",
"version": "0.1.3",
"author": "Pavan Kumar Sunkara <pavan.sss1991@gmail.com> (http://pksunkara.github.com)",

@@ -20,3 +20,3 @@ "description": "nodejs wrapper for github v3 api",

"prepublish": "./node_modules/.bin/cake lib",
"test": "./node_modules/.bin/vows --spec $(find test -name '[^nock]*.coffee')"
"test": "./node_modules/.bin/vows --spec $(find test -name '*.js')"
},

@@ -23,0 +23,0 @@ "contributors": [

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc