FAQ
hello i have this code:

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

Search Discussions

  • Martin Cooper at Dec 24, 2012 at 4:50 pm

    On Mon, Dec 24, 2012 at 2:41 AM, Norman Khine wrote:

    hello i have this code:
    (code snipped)

    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.

    What do you mean by "merge"? If you really mean concatenate, and just want
    to stream both pieces to the client, one after the other, in the same
    response, then you can make the request for the second piece when the
    response for the first piece ends, and end the response to your client only
    when that second response ends. If you really do mean merge, in some sense,
    then it seems likely that you'd need to do some buffering and analysis of
    your streams, which could get a lot more complicated.

    --
    Martin Cooper


    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
    --
    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedDec 24, '12 at 10:41a
activeDec 24, '12 at 4:50p
posts2
users2
websitenodejs.org
irc#node.js

2 users in discussion

Norman Khine: 1 post Martin Cooper: 1 post

People

Translate

site design / logo © 2022 Grokbase