Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
351e24f
commit 597ec53
Showing
4 changed files
with
136 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var reqHandler = require('./request_handler.js'); | ||
|
||
module.exports = { | ||
newRequest: function (queueObj){ | ||
generateResponse(queueObj); | ||
} | ||
} | ||
|
||
function generateResponse(q){ | ||
var ordrinURL = "r-test.ordr.in" | ||
|
||
var params;//build rest of path using queue's params | ||
var options = { | ||
host: ordrinURL, | ||
path: '/dl/datetime,etc', | ||
method: 'GET' | ||
} | ||
|
||
var req = https.request(option, function(result){ | ||
//pass this response to Fn that puts it to S3 | ||
var responseString = ""; | ||
response.on('data', function(chunk) { | ||
responseString += chunk; | ||
}); | ||
|
||
response.on('end', function() { | ||
//at this point, the handler has the queue; | ||
var responseObj = JSON.parse(responseString); | ||
console.log(responseObj); | ||
}); | ||
|
||
}); | ||
|
||
req.end(); | ||
|
||
req.on('error', function(e) { | ||
console.error(e); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,71 @@ | ||
var https = require('https'); | ||
var ordrin = require('./ordrin.js'); | ||
var s3 = require('./s3.js'); | ||
|
||
module.exports = { | ||
getQueue: getQueue(), | ||
handle: fn, | ||
popQueue: fn | ||
getQueue : function() { | ||
getQueue(); | ||
}, | ||
handle : function() { | ||
|
||
}, | ||
popQueue : function() { | ||
|
||
}, | ||
config: function(){ | ||
return config; | ||
} | ||
} | ||
|
||
//abstract the following config object; possibly put it in app.js | ||
|
||
config = { | ||
|
||
git : { | ||
user : 'scrooge-demo' | ||
}, | ||
s3 : { | ||
s3_url : 'scrooge.leknarf.net', | ||
s3_folder : 'results', | ||
access_key_id : 'AKIAIWZWQG72NWWW7G3Q', | ||
access_key : '8RlneaSOIjyiXWgWjf7lWoyTomHofiYSx5LLFcIi' | ||
}, | ||
ordrn : { | ||
access_key: 'LkAHD4QSAAAA6RoMAABJug' | ||
} | ||
} | ||
|
||
function getQueue(){ | ||
options = { | ||
host: 'api.github.com', | ||
port: 80, | ||
path: '/repos/:user/:repo/git/blobs/' | ||
function getQueue() { | ||
|
||
var options = { | ||
host : 'api.github.com', | ||
path : '/users/' + config.git.user + '/gists', | ||
method : 'GET' | ||
} | ||
|
||
https.request(options, function(res){ | ||
|
||
|
||
var req = https.request(options, function(response) { | ||
var queueString = ""; | ||
response.on('data', function(chunk) { | ||
queueString += chunk; | ||
}); | ||
|
||
response.on('end', function() { | ||
//at this point, the handler has the queue; | ||
var queue = JSON.parse(queueString); | ||
console.log(queue); | ||
}); | ||
}); | ||
|
||
req.end(); | ||
|
||
req.on('error', function(e) { | ||
console.error(e); | ||
}); | ||
} | ||
|
||
function handleQueue(queue){ | ||
//loops over | ||
//takes parameters from queue object | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var reqHandler = require('./request_handler.js'); | ||
|
||
module.exports = { | ||
post: function(response){ | ||
postResponse(r); | ||
} | ||
} | ||
|
||
function postResponse(r){ | ||
|
||
var params;//build params from passed in Ordrin response | ||
var options = { | ||
host: reqHandler.config.s3.url, | ||
path: '', | ||
method: 'POST' | ||
} | ||
|
||
var req = https.request(options, function(result){ | ||
var responseString = ""; | ||
response.on('data', function(chunk) { | ||
responseString += chunk; | ||
}); | ||
|
||
response.on('end', function() { | ||
//s3's response | ||
var responseObj = JSON.parse(responseString); | ||
}); | ||
|
||
}); | ||
|
||
req.end(); | ||
|
||
req.on('error', function(e) { | ||
console.error(e); | ||
}); | ||
} |