using node.js with closure library

690 views
Skip to first unread message

ramesh

unread,
Jun 7, 2012, 12:59:29 PM6/7/12
to closure-lib...@googlegroups.com
The reason I am thinking of something like this is because I want to access Dynamodb and I don't want to use anything more than javascript . I found node.js client for Dynamo on github https://github.com/jed/dynamo.

I have no clue if I can use node.js in my closure js file. I want to know if and how I can use code like this in my closure js file.

var dynamo = require("dynamo")
  , client = dynamo.createClient()
  , db = client.get("us-east-1")

// High-level API

db.get("myTable")
  .query({id: "123", date: {">=": new Date - 6000 }})
  .get("id", "date", "name")
  .reverse()
  .fetch(function(err, data){ ... })

// Same call, using low-level API

db.query({
  TableName: "myTable",
  HashKeyValue: {S: "123"},
  RangeKeyValue: {
    ComparisonOperator: "LE",
    AttributeValueList: [{N: "1329912311806"}]
  },
  AttributesToGet: ["id", "date", "name"],
  ScanIndexForward: false
}, function(err, data){ ... })


Appreciate any help or guidance.

regards,
Ramesh

Christopher Peisert

unread,
Jun 7, 2012, 1:50:51 PM6/7/12
to closure-lib...@googlegroups.com
Ramesh,


Christopher

ramesh

unread,
Jun 7, 2012, 2:10:42 PM6/7/12
to closure-lib...@googlegroups.com
Thanks Christopher for the pointer. I get the idea now.

PS. If anyone has ever tried similar with node.js , that would be even more helpful.

regards,
Ramesh

Peter StJ

unread,
Jun 8, 2012, 6:35:37 AM6/8/12
to closure-lib...@googlegroups.com
Is the closure compiler able to wrap / process built in modules (like http)? As per the announcement all files need to be in directory processed, and evidently http module is not.

On the other hand the code is pretty clean and with very little tweaks can be ported to use closure library instead of the built in modules. 

ramesh

unread,
Jun 8, 2012, 9:52:33 AM6/8/12
to closure-lib...@googlegroups.com
Thanks Peter for your input. I found this http://www.bramstein.com/projects/calcdeps.js/  , node.js port of closure library and probably this would help me achieve my goal.

regards,
Ramesh

ramesh

unread,
Jun 8, 2012, 10:04:50 AM6/8/12
to closure-lib...@googlegroups.com
On 06/08/2012 05:35 AM, Peter StJ wrote:
For someone who might be attempting the same, there is some work on github.

https://github.com/bolinfest/node-google-closure-latitude-experiment
And it says.

" Here, I am trying to take a different approach, in which JavaScript is written in the style of the Closure Library, and the Node APIs are exposed as externs so that the application code can be compiled using the Advanced mode of the Closure Compiler, in order to maximize the amount of static checking and dead code elimination that can be done."


Ramesh

Peter StJ

unread,
Jun 9, 2012, 8:45:27 AM6/9/12
to closure-lib...@googlegroups.com
I believe it was not clear if you are to use the code on node server or in the browser. 

If the later is true, I do not see how any of those projects would help achieve the goal.

If on the other hand the point is to run on node server, the latest mentioned links are the right way. I have used nclosure to allow tests to be run on non-dom code written for the browser on server instances with node and it is awesome. 

ramesh

unread,
Jun 9, 2012, 2:21:13 PM6/9/12
to closure-lib...@googlegroups.com
Thanks Peter,

 Sorry, I wasn't very clear initially. I just wanted to use Node as externs in Closure similar to https://github.com/bolinfest/node-google-closure-latitude-experiment. But I think I will give nclosure a try as this approach looks interesting.

regards,
Ramesh

Christopher Peisert

unread,
Jun 9, 2012, 4:09:55 PM6/9/12
to closure-lib...@googlegroups.com
Additional discussion threads for using Node.js with Closure:




On Thursday, June 7, 2012 9:59:29 AM UTC-7, Ramesh wrote:

ramesh

unread,
Jun 10, 2012, 5:23:57 AM6/10/12
to closure-lib...@googlegroups.com
Thanks Christopher, that was helpful.

regards,
Ramesh
Reply all
Reply to author
Forward
0 new messages