Browse files

WIP requesting repolist

  • Loading branch information...
1 parent cc18465 commit 607f803dfbf807baedfa778c2efe22c0d73c7a48 @kuryaki kuryaki committed Dec 14, 2012
Showing with 34 additions and 8 deletions.
  1. +5 −3 config.js
  2. +29 −5 routes/subscription.js
View
8 config.js
@@ -6,7 +6,8 @@ var config = {
},
protocol: 'http',
host: 'localhost',
- port: 3000
+ port: 3000,
+ access_token: 'b7b94ad5a56a71aad5ac96b41615d6df31c158aa'
},
production: {
@@ -17,11 +18,12 @@ var config = {
},
protocol: 'http',
host: 'feedscriber.jit.su',
- port: 80
+ port: 80,
+ access_token: 'b7b94ad5a56a71aad5ac96b41615d6df31c158aa'
}
};
var env = process.env.NODE_ENV || 'development';
config[env].appurl = config[env].protocol+'://'+config[env].host+':'+config[env].port;
-module.exports = config[env];
+module.exports = config[env];
View
34 routes/subscription.js
@@ -1,15 +1,39 @@
-var kue = require('kue');
+var jobs = require('kue').createQueue();
+var request = require('request');
+var config = require('../config.js');
exports.create = function(req, res){
var client = kue.redis;
- console.log(req.body);
+ // TODO handle this job (check for new repos and subscribe to them)
+ jobs.create('update_user', {login:req.body.login}).delay(60000).save();
- client.get('https://github.com/kuryaki.atom', function(error, data){
+ // TODO move this to a middle-ware that gets an array of repositories
+ if(req.body.access_token){
+ request
+ .get('https://api.github.com/user/repos?access_token='+req.body.access_token, {json:true},
+ function(error, response, body){
+ body.map(function(repo){
+ console.log(repo.full_name);
+ // TODO subscribe and keep status in redis
+ });
+ });
+ }else{
+ request
+ .get('https://api.github.com/users/'+req.body.login+'/repos', {json:true},
+ function(error, response, body){
+ body.map(function(repo){
+ console.log(repo.full_name);
+ });
+ });
+ }
- console.log(data);
- });
+ // client.get('https://github.com/kuryaki.json', function(error, data){
+
+ // console.log(data);
+
+ // });
res.send(200);
};

0 comments on commit 607f803

Please sign in to comment.