var http = require('http')
,https = require('https')
,fs = require('fs'),json;
var GOOGLE_API_KEY = process.env.GOOGLE_API_KEY;
var TABLE_ID = "1epTUiUlv5NQK5x4sgdy1K47ACDTpHH60hbng1qw";
var GOOGLE_PATH =
"/fusiontables/v1/query?sql=SELECT%20*%20FROM%20"+TABLE_ID+"&key="+GOOGLE_API_KEY
var GOOGLE_DRIVE_PATH = "/drive/v2/files/"+TABLE_ID+"?key="+GOOGLE_API_KEY
var options = {
hostname: 'www.googleapis.com',
port: 443,
method: 'GET',
};
http.createServer(function (req, res) {
var file = fs.createWriteStream("../data/chapters.json");
var clientRes = res;
clientRes.writeHead(200, {'Content-Type': 'application/json',
"Access-Control-Allow-Origin": "*"});
clientRes["modifiedDate"] = "2012-12-04T18:51:12.762Z";
options["path"] = GOOGLE_PATH;
var req = https.request(options, function(res) {
console.log(res);
res.on('data', function(data) {
clientRes.write(data, 'utf8');
file.write(data);
}).on('end', function() {
// send the JSON here
clientRes.end(json);
file.end();
});
});
req.end();
req.on('error', function(e) {
console.error(e);
});
}).listen(process.env.VMC_APP_PORT || 9080, null);
basically when you access the site, this returns the json output read from
the google fusion table, but i am not sure how to go about in getting the
matadata first from the GOOGLE_DRIVE_PATH and then merging this with the
data received from GOOGLE_PATH on the fly. Is this possible with modules
like https://github.com/fent/node-kat or do i need to redesign my approach?
i would like to check if the modifiedDate from the Google Fusion Table has
changed and if it has changed to pull the data and create the chapters.json
file.
any advice much appreciated.
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en