Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: CodeTag/githubMonitor
base: 04ed4f3b2c
...
head fork: CodeTag/githubMonitor
compare: 182996c86e
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 15 files changed
  • 0 commit comments
  • 1 contributor
View
2  .gitignore
@@ -1 +1 @@
-node_modules
+node_modules/
View
11 README.md
@@ -0,0 +1,11 @@
+# TODO
+
+1. Save into redis the array of repos for an user
+2. Subscribe to the repo pubsubhub events (all of them)
+3. Service to listen the pubsubhub notifications
+4. Comunicate them to the listener
+5. Task to keep the repositories updated
+6. Handle every type of event (push, pull request, etc)
+7. Put in a middleware/util the repo listing method
+8. Authenticate with github to get more "repo" wise tokens
+:
View
41 app.js
@@ -0,0 +1,41 @@
+
+/**
+ * Module dependencies.
+ */
+var queue = require('./queue');
+
+var express = require('express');
+var routes = require('./routes');
+
+var http = require('http');
+var path = require('path');
+
+var app = express();
+
+app.configure(function(){
+ app.set('port', process.env.PORT || 3000);
+ app.set('views', __dirname + '/views');
+ app.set('view engine', 'jade');
+ app.use(express.favicon());
+ app.use(express.logger('dev'));
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(express.cookieParser('your secret here'));
+ app.use(express.session());
+ app.use(app.router);
+ app.use(express.static(path.join(__dirname, 'public')));
+ app.use(queue.app);
+});
+
+app.configure('development', function(){
+ app.use(express.errorHandler());
+});
+
+app.get('/', routes.index);
+app.post('/subscription', routes.subscription);
+app.post('/event/:login/:repository', routes.events);
+
+
+http.createServer(app).listen(app.get('port'), function(){
+ console.log("Express server listening on port " + app.get('port'));
+});
View
29 config.js
@@ -0,0 +1,29 @@
+var config = {
+ development: {
+ db: {
+ host: '127.0.0.1',
+ port: 6379
+ },
+ protocol: 'http',
+ host: 'localhost',
+ port: 3000,
+ access_token: 'b7b94ad5a56a71aad5ac96b41615d6df31c158aa'
+ },
+
+ production: {
+ db: {
+ host: 'nodejitsudb4906573230.redis.irstack.com',
+ port: 6379,
+ auth: 'nodejitsudb4906573230.redis.irstack.com:f327cfe980c971946e80b8e975fbebb4'
+ },
+ protocol: 'http',
+ host: 'feedscriber.jit.su',
+ 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];
View
15 lib/minion.js
@@ -0,0 +1,15 @@
+var kue = require('kue');
+
+exports = module.exports = Minion;
+
+function Minion(){
+ this.jobs = kue.createQueue();
+}
+
+Minion.prototype.serve=function(){
+ this.jobs.process('salute', function(job, done){
+
+ console.log('yes ' + job.data.name);
+
+ });
+};
View
11 lib/overlord.js
@@ -0,0 +1,11 @@
+var kue = require('kue');
+
+exports = module.exports = Overlord;
+
+function Overlord(){
+ this.jobs = kue.createQueue();
+}
+
+Overlord.prototype.command = function(){
+ this.jobs.create('salute', {name:'David'}).save();
+};
View
15 package.json
@@ -0,0 +1,15 @@
+{
+ "name": "application-name",
+ "version": "0.0.1",
+ "private": true,
+ "scripts": {
+ "start": "node app"
+ },
+ "dependencies": {
+ "express": "3.0.0rc3",
+ "jade": "*",
+ "request": "~2.12.0",
+ "redis": "~0.8.2",
+ "kue": "~0.5.0"
+ }
+}
View
8 public/stylesheets/style.css
@@ -0,0 +1,8 @@
+body {
+ padding: 50px;
+ font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
+}
+
+a {
+ color: #00B7FF;
+}
View
21 queue.js
@@ -0,0 +1,21 @@
+var kue = require('kue');
+var redis = require('redis');
+var config = require('./config');
+
+kue.redis.createClient = function() {
+ var client = redis.createClient(config.db.port, config.db.host);
+ if(config.db.auth){
+ client.auth(config.db.auth);
+ }
+ return client;
+};
+
+// Expose the app
+exports = module.exports = kue;
+
+// Expose the redis connection
+exports.redis = kue.redis.createClient();
+
+kue.jobs = kue.createQueue();
+
+kue.jobs.promote();
View
0  routes/event.js
No changes.
View
5 routes/index.js
@@ -0,0 +1,5 @@
+exports.index = require('./main.js').home;
+
+exports.subscription = require('./subscription.js').create;
+
+exports.event = require('./event.js').create;
View
12 routes/main.js
@@ -0,0 +1,12 @@
+var Overlord = require('./../lib/overlord');
+var Minion = require('./../lib/minion');
+
+exports.home = function(req, res){
+ res.render('index', { title: 'Express' });
+
+ var overlord = new Overlord();
+ var minion = new Minion();
+
+ overlord.command();
+ minion.serve();
+};
View
39 routes/subscription.js
@@ -0,0 +1,39 @@
+var jobs = require('kue').createQueue();
+var request = require('request');
+var config = require('../config.js');
+
+exports.create = function(req, res){
+ var client = kue.redis;
+
+ // TODO handle this job (check for new repos and subscribe to them)
+ jobs.create('update_user', {login:req.body.login}).delay(60000).save();
+
+ // 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);
+ });
+ });
+ }
+
+
+ // client.get('https://github.com/kuryaki.json', function(error, data){
+
+ // console.log(data);
+
+ // });
+
+ res.send(200);
+};
View
5 views/index.jade
@@ -0,0 +1,5 @@
+extends layout
+
+block content
+ h1= title
+ p Welcome to #{title}
View
7 views/layout.jade
@@ -0,0 +1,7 @@
+doctype 5
+html
+ head
+ title= title
+ link(rel='stylesheet', href='/stylesheets/style.css')
+ body
+ block content

No commit comments for this range

Something went wrong with that request. Please try again.