Re: [nodejs] Re: Nodejs listening to a server port and every time you get a 'request' record in database and show to the client.
As other people have mentioned, you really need to do some homework first, and come back here when you have specific problems you're unable to solve. There are many resources out there to help you. For TCP, you can start with the Node.js API documentation: http://nodejs.org/api/net.html -- Martin Cooper On Tue, Aug 27, 2013 at 8:43 AM, Felipe Silveira cont...@felipems.com.brwrote: The example of nodejs.org listen the port 1337 on http but I need to listen in TCP/IP or UDP have some mode to do? On Tuesday, August 27, 2013 9:42:38 AM UTC-3, Felipe Silveira wrote: Hello Guys, I'm newbie in NodeJS and I need an idea to make some requests (packets) sent to a server port are recorded in the database and simultaneously processed and displayed to the client. Who can help me with some example, only the beginning so I can understand and continue. Thanks for any help. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] process out of memory error with 0-wait setTimeout
I ran it with v0.10.15 initially. With v0.8.22, it's been running for over 1.5 hours now, with no problems. So I still think the problem must be with the ... sections. -- Martin Cooper On Mon, Aug 26, 2013 at 10:28 PM, ming hseum...@gmail.com wrote: Hi Martin, Thanks for the input. i was a bit surprised to learn that. What version of node are you running over there? i should have mentioned that the version of Node i use is 0.8.22. Not sure if that plays any role in the crash. i know 0.8.22 is not the latest (and likely the greatest) but that's what i'm stuck with. Whether/when the resource will be depleted also depends on the macho-ness of the bare metal, :-) On Friday, August 23, 2013 8:34:49 PM UTC-4, Martin Cooper wrote: I think you'll find that the problem is in one of the ... sections you've omitted. Your foo1 code has been running on my machine all day without any issue at all. -- Martin Cooper On Wed, Aug 21, 2013 at 8:22 PM, ming hseu...@gmail.com wrote: Hi, My node.js program crashed and i saw the following in the log: FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory i reduced the original program to the following tiny self-contained program: = ... function foo1() { var someBadURI = ...; http.get ( someBadURI, function(res) { if (res.statusCode != 200) { util.log(! bad ); setTimeout(foo1,0); return; } ... } ) ... } foo1(); = If i let the program above run long enough (~30 minutes or more), the process ran out of memory then crashed with the aforementioned error message but it is not clear to me why: FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory However, the following program has been running for days without any problem: = function foo2() { util.log(entering foo2); setTimeout(foo2,0); util.log(leavinging foo2); } foo2(); = Why is that? Should the V8 engine register the event and invoke the callback/handler constantly with 0-wait setTimeout? Why would it consume a lot of memory? My guess is * memory has been allocated for the http.get call in foo1. In foo2, there is only log printing which does not really consume any resource (memory in this case) * the call setTimeout(foo,0); in foo1 always grabs the next tick so the GC never gets a chance to run Am i way off? i'm unsure if i need to yank in scoped, handle, context, etc. into my reasoning though for a better description. Thanks. -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/**node/wiki/Mailing-List-* *Posting-Guidelineshttps://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 nod...@googlegroups.com To unsubscribe from this group, send email to nodejs+un...@**googlegroups.com For more options, visit this group at http://groups.google.com/**group/nodejs?hl=en?hl=enhttp://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@**googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email
Re: [nodejs] Re: The problem with the current working directory
On Mon, Aug 26, 2013 at 9:10 AM, Gagle gagle...@gmail.com wrote: If node.js is better at requiring modules than other platforms why not include a warning when you execute a file with a relative path different than the directory of this file? Because it's not a problem, it's a useful feature, and one that, as you pointed out, is common and well known across many languages and platforms. If the app is coded poorly, makes invalid assumptions about how it's going to be run, and doesn't validate those assumptions on startup, then that's the app's / author's problem. On the flip side, someone running multiple instances of their app from different working directories, specifically to pick up different configs from those directories, shouldn't be faced with a slew of warnings when their app is working as designed. -- Martin Cooper The process.root solution is already implemented: process.root = path.dirname(process.mainModule.filename) We could say: Hey! Node.js is aware the cwd problematic! Awesome El lunes, 26 de agosto de 2013 17:05:16 UTC+2, Tim Caswell escribió: Node's require is always relative to the file that calls require. In fact, the internal implementation of this is done by giving file a unique copy of the require function that embeds that file's directory. If you wanted to require relative to the cwd, then use process.cwd and path.resolve. If you want to require relative to your main module, store a value somewhere in your process (process.root maybe?) and use that in conjunction with path.resolve. The fs operations are relative to the process.cwd instead of the calling file. If you want them to be relative to the calling file, simply path.resolve with __dirname and they will act like require does. Noce gives you more options in this regard than any other platform I've worked with. After working with node's require semantics, it's now painful for me to use other module systems because I can't write portable libraries as easily. Sometimes it's not even possible to have a set of inter-dependencies that only use relative requires. On Mon, Aug 26, 2013 at 8:34 AM, Gagle gagl...@gmail.com wrote: But now suppose you have another file called b.js that is required by a.js and is stored in a different directory and uses a relative path. You can't use __dirname. El lunes, 26 de agosto de 2013 15:32:17 UTC+2, ajlopez escribió: Ah! I see.. But this is not a problem for require, but for fs. Ok, in my code I would use if (fs.existsSync(path.join(__**dir**name, settings.json)) On Mon, Aug 26, 2013 at 10:27 AM, Gagle gagl...@gmail.com wrote: $ pwd /home/user1 $ mkdir dir $ cat dir/app.js console.log (process.cwd ()); $ node dir/app.js /home/user1 $ cd dir node app.js /home/user1/dir Now suppose you have this code: //app.js var fs = require (fs); if (fs.existsSync (settings.json)){ doSomethingUseful (); }else{ //Warning!! saveToDatabaseDefaultSettings (); } And execute the main file with a relative path: node dir/app You will enter into the else case because settings.json is stored inside dir but the cwd is not dir, so you expect the path ./dir/settings.json but in fact the path is ./settings.json. El lunes, 26 de agosto de 2013 15:05:10 UTC+2, ajlopez escribió: Gagle, can you write down a concrete use case? On Mon, Aug 26, 2013 at 9:59 AM, Gagle gagl...@gmail.com wrote: Because it's local to the file, it doesn't work anywhere. El lunes, 26 de agosto de 2013 14:46:55 UTC+2, mks escribió: __dirname is local to any file. It works everywhere. -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/**node /wiki/Mailing-List-**Posting-**Gui**delineshttps://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 nod...@googlegroups.com To unsubscribe from this group, send email to nodejs+un...@**googlegroups.com For more options, visit this group at http://groups.google.com/**group/nodejs?hl=en?hl=enhttp://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@**googlegroups.com. For more options, visit https://groups.google.com/**grou ps/opt_out https://groups.google.com/groups/opt_out. -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/**node** /wiki/Mailing-List-**Posting-**Guidelineshttps://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 nod...@googlegroups.com To unsubscribe from this group, send email to nodejs+un...@**googlegroups.com For more options
Re: [nodejs] Problem with Node.js in For in
And that is exactly the problem. The for ... in construct is defined as enumerating the properties of objects, not the elements of arrays. -- Martin Cooper On Fri, Aug 23, 2013 at 4:39 AM, .//Hack dsshac...@gmail.com wrote: if you look closely, I use array of objects. And iteration in array but not in object. Now I use user[action].forEach(function(act){ and don't have problem 23/08/13 15:05:53, Fedor Indutny fe...@indutny.com: Sorry, but I can't see a problem here... For each iterates not only through own properties, but through the prototype's properties too. That's how it is defined in spec, and that's how javascript behaves. What you probably want to do is `Object.keys(obj).forEach(function(key) { var value = obj[key]; ... })`. Cheers, Fedor. On Fri, Aug 23, 2013 at 3:04 PM, Александр Крылов dsshac...@gmail.comwrote: Installed next modules: cloneextend express imagemagick mongodb mongoose nodemailer session-mongoose socket.io validator And I didn't extend prototype. With Array.forEach no problem. Only for in пятница, 23 августа 2013 г., 14:52:00 UTC+4 пользователь Fedor Indutny написал: It seems that you've installed modules that are extending Array's or Object's prototype. Cheers, Fedor. On Fri, Aug 23, 2013 at 2:24 PM, Александр Крылов dssh...@gmail.comwrote: Hello! I have problem. For test example code: var user = {} var action = 'test'; user[action] = [{ user_id: '521319f2df3b32081005', _id: '521723678857785c050b', action: { acType: 'photo', acId: '3' }, viewed: false }, { user_id: '521319f2df3b32081005', _id: '5217293a1cab19bc1108', action: { acType: 'photo', acId: '1' }, viewed: false }, { user_id: '521319f2df3b32081005', _id: '52172c97d8b04bdc1108', action: { acType: 'photo', acId: '1' }, viewed: false }, { user_id: '521319f2df3b32081005', _id: '52172cc201feeff81108', action: { acType: 'photo', acId: '1' }, viewed: false }, { user_id: '521319f2df3b32081005', _id: '52172ce901feeff81109', action: { acType: 'photo', acId: '1' }, viewed: false }, { user_id: '521319f2df3b32081005', _id: '52172d0d80f9c0701308', action: { acType: 'photo', acId: '1' }, viewed: false }, { user_id: '521319f2df3b32081005', _id: '52172e038c017e041208', action: { acType: 'photo', acId: '1' }, viewed: false }, { user_id: '521319f2df3b32081005', _id: '52172e8ca28258401008', action: { acType: 'photo', acId: '1' }, viewed: false }]; console.log(user[action]); for(var i in user[action]){ console.log(i); } So, first console.log shows all elemrnts of array, good. Second console.log shows key of iteration and shows: 0 1 2 3 4 5 6 7 _atomics validators _path _parent _schema _cast id toObject inspect create notify _markModified _registerAtomic $__getAtomics hasAtomics push nonAtomicPush $pop pop $shift shift pull remove splice unshift sort addToSet set indexOf I tested in Node.js (0.10.12) and all browsers. Problem only in node.js Can you help me? -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/**node/wiki/Mailing-List- **Posting-Guidelineshttps://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 nod...@googlegroups.com To unsubscribe from this group, send email to nodejs+un...@**googlegroups.com For more options, visit this group at http://groups.google.com/**group/nodejs?hl=en?hl=enhttp://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@**googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- Job Board: http://jobs.nodejs.org
Re: [nodejs] process out of memory error with 0-wait setTimeout
I think you'll find that the problem is in one of the ... sections you've omitted. Your foo1 code has been running on my machine all day without any issue at all. -- Martin Cooper On Wed, Aug 21, 2013 at 8:22 PM, ming hseum...@gmail.com wrote: Hi, My node.js program crashed and i saw the following in the log: FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory i reduced the original program to the following tiny self-contained program: = ... function foo1() { var someBadURI = ...; http.get ( someBadURI, function(res) { if (res.statusCode != 200) { util.log(! bad ); setTimeout(foo1,0); return; } ... } ) ... } foo1(); = If i let the program above run long enough (~30 minutes or more), the process ran out of memory then crashed with the aforementioned error message but it is not clear to me why: FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory However, the following program has been running for days without any problem: = function foo2() { util.log(entering foo2); setTimeout(foo2,0); util.log(leavinging foo2); } foo2(); = Why is that? Should the V8 engine register the event and invoke the callback/handler constantly with 0-wait setTimeout? Why would it consume a lot of memory? My guess is * memory has been allocated for the http.get call in foo1. In foo2, there is only log printing which does not really consume any resource (memory in this case) * the call setTimeout(foo,0); in foo1 always grabs the next tick so the GC never gets a chance to run Am i way off? i'm unsure if i need to yank in scoped, handle, context, etc. into my reasoning though for a better description. Thanks. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] Modules by Author
If you're looking for a way that a person can look at the list of packages a specific author has published, the npmjs.org site can show you, as others have mentioned. If you're looking for a programmatic way to get a list of packages published by a specific author, you can use this: $ curl http://registry.npmjs.org/-/by-user/author-name If you're looking for a programmatic way to get a list of all packages along with their authors, you can use this: $ curl http:/registry.npmjs.org/-/by-field?field=author By the way, while Luke is correct that the npm list is extremely quiet, I don't see any reason you shouldn't be able to post there. Odd. -- Martin Cooper On Wed, Aug 21, 2013 at 9:46 AM, Michael Schoonmaker michael.r.schoonma...@gmail.com wrote: Maybe I'm missing something obvious, but hunting around the various docs hasn't revealed a way to get all modules by author. All I'm looking for is module names, and the input requirements are flexible. -Schoon P.S. Is posting disabled in the NPM mailing list for shmoes like me? I thought that list more appropriate. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] Rewriting paths with fstream, tar
You might want to take a look at the npm code that unpacks package tarballs. The key function is gunzTarPerm, here: https://github.com/isaacs/npm/blob/master/lib/utils/tar.js#L191 Note that extractEntry gets to futz with each entry as it goes by: https://github.com/isaacs/npm/blob/master/lib/utils/tar.js#L212 Hope that helps. -- Martin Cooper On Wed, Aug 21, 2013 at 3:53 PM, Brian Lalor bla...@bravo5.org wrote: This isn't pertinent to core node.js, but I'm hoping someone might be able to give me a hand. I want to accomplish the equivalent of tar -cf output.tar -C /tmp/whatever . with Isaac's fstream[1] and tar[2] modules. Unfortunately I find the documentation really lacking; maybe I'm just missing something? Here's essentially the code I'm using: fstream.Reader({ path: /tmp/path/to/root, type: Directory }) .pipe(tar.Pack()) .pipe(zlib.createGzip()) .pipe(fstream.Writer({ path: path.join(output.tar.gz), type: File })); This is based on a gist[3]. If /tmp/path/to/root/file.js is a file, then output.tar.gz will contain the path root/file.js, which is kind of weird. What I want to do is modify the path to each file, but I don't know where to start. I only have a rough grasp of streams, and I can't really figure out how the data and metadata flow from the fstream.Reader. Does anyone have any pointers? Thanks, Brian [1]: https://github.com/isaacs/fstream [2]: https://github.com/isaacs/node-tar [3]: https://gist.github.com/nicolasfont/2040815 -- Brian Lalor bla...@bravo5.org http://github.com/blalor -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] Quick question about npmjs.org
This will get you a list of package names, as a JSON array of strings: $ curl http://registry.npmjs.org/-/short and this will get you a ton of data on all packages, as a JSON object keyed by package name: $ curl http://registry.npmjs.org/-/all npm uses a variation of the second URL, adding args to limit the data, when you use 'npm search'; you can use '-dd' to see the URLs that npm sends to the registry. -- Martin Cooper On Sun, Aug 18, 2013 at 10:26 AM, Stewart Obert ceditsoftw...@gmail.comwrote: Hi, I wanted to find out with the site (npmjs.org) is there any method to retrieve a list of modules or search the modules with the result being json or xml? I appreciate any help Thanks, Stewart -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] Will it be possible to dispose module cache?
There are a couple of issues with that. First, if 'mod' loaded other modules to do its job, those other modules are not removed from the cache. For example, suppose package 'foo' has main module a.js, and that loads module b.js to do some of its work. Now if you delete 'foo', or even a.js, from the cache, b.js is still cached, so when a new version of a.js is loaded, it will still use that old b.js. Hence for this to work reliably, you need to know all of the implementation files that will need to be removed from the cache, not just your entry point. That's pretty fragile. Also, depending on the nature of the modules being removed, and their usage patterns, you may end up with retained references to the now-removed (but possibly still extant) module, or objects created by it, that may result in weird behaviour later. In the OP's case, with a framework designed for this, that may not be so much of an issue, but it's still a risk, especially if the modules being removed from the cache are non-trivial and / or not written by the framework designer. -- Martin Cooper On Sat, Aug 17, 2013 at 2:42 AM, George Stagas gsta...@gmail.com wrote: function removeCached(mod) { delete require.cache[require.resolve(mod)]; } // then require('foo'); // ... later removeCached('foo'); 2013/8/17 Tony Huang cnwz...@gmail.com Hi all, I'm creating a framework for my game server, and developing the module hot update feature. My design is very similar to the Erlang hot update feature. Modules will be hot updated should meet the interface: module.exports = { 'status': data, 'version': 1.0, 'init': function() { return initialStatus; }, 'code_changed': function(oldVersion, newVersion, oldStatus) { return newStatus; } }; So, when the module source file changes, the framework will get the status of original version of module, and remove it from the module cache, and import the new module, and invoke the code_changed method of the new version of module to generate the new status and assign it to the new module to finish the update process. As a result, I need an API to remove the module from the module cache, will it be possible or will this API be added in the future version of node? Best regards. -- -- Tony Huangcnwz...@gmail.com wz...@hotmail.com wz...@vip.sina.com -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] how to get object using nodejs from cypher query?
The literal you pasted is an array of objects. You appear to be assuming it's already the first object in that array. So if 'rels' is actually what you pasted, you want rels[0].rels.type. -- Martin Cooper On Sat, Aug 17, 2013 at 2:45 AM, Jyoti Chhetri nitrous.ooox...@gmail.comwrote: I have following query which is giving me what I want 'START user=node({userId}), other=node({otherId})', 'MATCH (user) -[rels?]- (other)', 'RETURN rels' but I'm unable to access the object it send.I need following high lightened object which I have no idea to access.Object is inspected in console below. [{rels:{db:{url:http://localhost:7474 ,_request:{},_root:..{},start: http://localhost:7474/db/data/node/222,property:; http://localhost:7474/db/data/relationship/245/properties/{key},self:; http://localhost:7474/db/data/relationship/245,properties:; http://localhost:7474/db/data/relationship/245/properties,type:knows; ,end:http://localhost:7474/db/data/node/196 ,data:{created_at:1372829579654}},_start:{db:{url: http://localhost:7474,_request:{},_root:... Full program: User.checkRelationship = function (user, fid, callback) { var uids = [user.uid, fid]; async.map(uids, User.by_uid, function (err, usernodes) { if (!err usernodes usernodes.length) { User.relsCheck(usernodes, function (err, rels) { if (!err rels) { callback(null, rels); // inpecting rels gave the above object but I want to return rels.type , but is not giving i want } else { callback(err || new Error('relationships does\'nt exists')); } }); } else { callback(err || new Error('Unable to fetch user nodes: ' + uids.join(','))); } }); }; User.relsCheck = function (nodes, callback) { if (nodes.length !== 2) { return callback(new Error('Invalid/insufficient arguments')); } var query = [ 'START user=node({userId}), other=node({otherId})', 'MATCH (user) -[rels?]- (other)', 'RETURN rels' ].join('\n'); var params = { userId: nodes[0].node().id, otherId: nodes[1].node().id, }; db.query(query, params, callback); }; -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] Will it be possible to dispose module cache?
Your implementation is still subject to both potential issues I mentioned. Let's suppose M is the module you are removing from the cache in (b), and let's suppose the code for M includes the following lines: var b = require(./b.js); var thing = { ... }; exports.getThing = function () { return thing; }; Now, when you remove M from the cache, and load M1 in its place, ./b.js is still cached, and M1 will get that instead of any new version you may have provided, and the mainline code of b.js will not be re-run. Also, anyone who called M.getThing() and held a reference to it will have a different 'thing' than anyone who later calls M1.getThing(). (I believe this will also prevent M from being collected, since it's still in use.) Whether these issues are okay in the context of your framework, only you can say. I guess as long as you, and everyone else who writes a module to your interface, understands all of this, you may be okay, but I do think it's fragile. -- Martin Cooper On Sat, Aug 17, 2013 at 9:35 AM, Tony Huang cnwz...@gmail.com wrote: @Martin I have noticed this risk. So: 1) This will be just a limited feature used in my framework, it might go open source, but I will never try to make this a part of node.js API. So the risk will affect very little area. 2) I will implement it in this way: a) Get the old exports object from the cache b) Remove the old module from the cache c) Use require() to load the new module to the cache d) Use new module's code_changed function to convert module state e) Delete all fields of the old exports object f) Copy all fields of the new exports to the old exports object g) Update the status field of old exports object to the status object created at step d h) Update the new modules exports field to the reference to the old exports object, to make sure the exports object of the module is unique in the system Thank you for your reply and expecting more comments advices. On Sat, Aug 17, 2013 at 11:55 PM, Martin Cooper mfncoo...@gmail.comwrote: There are a couple of issues with that. First, if 'mod' loaded other modules to do its job, those other modules are not removed from the cache. For example, suppose package 'foo' has main module a.js, and that loads module b.js to do some of its work. Now if you delete 'foo', or even a.js, from the cache, b.js is still cached, so when a new version of a.js is loaded, it will still use that old b.js. Hence for this to work reliably, you need to know all of the implementation files that will need to be removed from the cache, not just your entry point. That's pretty fragile. Also, depending on the nature of the modules being removed, and their usage patterns, you may end up with retained references to the now-removed (but possibly still extant) module, or objects created by it, that may result in weird behaviour later. In the OP's case, with a framework designed for this, that may not be so much of an issue, but it's still a risk, especially if the modules being removed from the cache are non-trivial and / or not written by the framework designer. -- Martin Cooper On Sat, Aug 17, 2013 at 2:42 AM, George Stagas gsta...@gmail.com wrote: function removeCached(mod) { delete require.cache[require.resolve(mod)]; } // then require('foo'); // ... later removeCached('foo'); 2013/8/17 Tony Huang cnwz...@gmail.com Hi all, I'm creating a framework for my game server, and developing the module hot update feature. My design is very similar to the Erlang hot update feature. Modules will be hot updated should meet the interface: module.exports = { 'status': data, 'version': 1.0, 'init': function() { return initialStatus; }, 'code_changed': function(oldVersion, newVersion, oldStatus) { return newStatus; } }; So, when the module source file changes, the framework will get the status of original version of module, and remove it from the module cache, and import the new module, and invoke the code_changed method of the new version of module to generate the new status and assign it to the new module to finish the update process. As a result, I need an API to remove the module from the module cache, will it be possible or will this API be added in the future version of node? Best regards. -- -- Tony Huangcnwz...@gmail.com wz...@hotmail.com wz...@vip.sina.com -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en
Re: [nodejs] Will it be possible to dispose module cache?
Not surprisingly, I disagree. :-) Since the OP is talking about building a framework based on this, I believe it's important to understand the limitations *before* committing to this approach, building the framework, and discovering only later, when there are numerous modules written and possibly even in production, that there are some fundamental issues. Certainly if I was building a framework, I'd want to do my homework and know where the skeletons are ahead of time. Only the OP can tell at this point whether these issues are potential problems for his use case or not. We don't have enough information for us to be able to determine that. But at least armed with the information, he can make an informed decision. -- Martin Cooper On Sat, Aug 17, 2013 at 10:48 AM, George Stagas gsta...@gmail.com wrote: @Martin We could list all the hypothetical breaking cases but I don't think that's useful. Every case is different and we should address issues that belong to the real use case. So, until it becomes an issue it's only speculation and leads to over-engineering and it's a waste of time and effort. He could be fine with deleting the cache entry. If it's not fine, he'll then seek for another solution. 2013/8/17 Martin Cooper mfncoo...@gmail.com Your implementation is still subject to both potential issues I mentioned. Let's suppose M is the module you are removing from the cache in (b), and let's suppose the code for M includes the following lines: var b = require(./b.js); var thing = { ... }; exports.getThing = function () { return thing; }; Now, when you remove M from the cache, and load M1 in its place, ./b.js is still cached, and M1 will get that instead of any new version you may have provided, and the mainline code of b.js will not be re-run. Also, anyone who called M.getThing() and held a reference to it will have a different 'thing' than anyone who later calls M1.getThing(). (I believe this will also prevent M from being collected, since it's still in use.) Whether these issues are okay in the context of your framework, only you can say. I guess as long as you, and everyone else who writes a module to your interface, understands all of this, you may be okay, but I do think it's fragile. -- Martin Cooper On Sat, Aug 17, 2013 at 9:35 AM, Tony Huang cnwz...@gmail.com wrote: @Martin I have noticed this risk. So: 1) This will be just a limited feature used in my framework, it might go open source, but I will never try to make this a part of node.js API. So the risk will affect very little area. 2) I will implement it in this way: a) Get the old exports object from the cache b) Remove the old module from the cache c) Use require() to load the new module to the cache d) Use new module's code_changed function to convert module state e) Delete all fields of the old exports object f) Copy all fields of the new exports to the old exports object g) Update the status field of old exports object to the status object created at step d h) Update the new modules exports field to the reference to the old exports object, to make sure the exports object of the module is unique in the system Thank you for your reply and expecting more comments advices. On Sat, Aug 17, 2013 at 11:55 PM, Martin Cooper mfncoo...@gmail.comwrote: There are a couple of issues with that. First, if 'mod' loaded other modules to do its job, those other modules are not removed from the cache. For example, suppose package 'foo' has main module a.js, and that loads module b.js to do some of its work. Now if you delete 'foo', or even a.js, from the cache, b.js is still cached, so when a new version of a.js is loaded, it will still use that old b.js. Hence for this to work reliably, you need to know all of the implementation files that will need to be removed from the cache, not just your entry point. That's pretty fragile. Also, depending on the nature of the modules being removed, and their usage patterns, you may end up with retained references to the now-removed (but possibly still extant) module, or objects created by it, that may result in weird behaviour later. In the OP's case, with a framework designed for this, that may not be so much of an issue, but it's still a risk, especially if the modules being removed from the cache are non-trivial and / or not written by the framework designer. -- Martin Cooper On Sat, Aug 17, 2013 at 2:42 AM, George Stagas gsta...@gmail.comwrote: function removeCached(mod) { delete require.cache[require.resolve(mod)]; } // then require('foo'); // ... later removeCached('foo'); 2013/8/17 Tony Huang cnwz...@gmail.com Hi all, I'm creating a framework for my game server, and developing the module hot update feature. My design is very similar to the Erlang hot update feature. Modules will be hot updated should meet the interface: module.exports = { 'status': data
Re: [nodejs] zlib fails to extract concatenated files
This isn't a bug. The zlib module decompressed the raw gzipped buffer and stopped. It isn't the job of zlib to try to infer any structure on the buffer you gave it, or to attempt to look for more work to do after finishing what it was asked to do. Subsequent data in the buffer could be anything, after all, not just gzipped data. In contrast, the gunzip command is being told this is a gzipped file (and nothing else), so it's reasonable for it to continue after processing one compressed buffer to see if it can do more. Note that, in your case, you can gunzip the second chunk by slicing it from the original buffer. But remember that only you know the structure of the file you are reading; there is no structure embedded within the file for some piece of code to interpret. -- Martin Cooper On Fri, Aug 9, 2013 at 11:45 PM, ribao wei riba...@gmail.com wrote: Hi, I just encounter this and not sure whether it is a bug in zlib module. echo 1 1.txt echo 2 2.txt gzip 1.txt gzip 2.txt cat 1.txt.gz 2.txt.gz 3.txt.gz Now, gunzip 3.txt.gz prints: 1 2 However, zlib.gunzip(fs.writeReadSync(**c.gz), function (err, buffer) { console.log(buffer.toString())**; }); prints: 1 (empty line) Am I missing something? Thanks, Wei -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] zlib fails to extract concatenated files
The zlib module is not working with gzip files, though, it's working with a data buffer that could have come from anywhere. In that situation, in my opinion, zlib shouldn't be (a) assuming it should keep going after one compressed block (member), or (b) concatenating the decompressed output from multiple blocks (members), given that there's no provision in the API for calling the callback multiple times, once with the output of each block. Ben appears to have a different opinion, though, so I guess the API semantics just changed, in my mind. :-) -- Martin Cooper On Sat, Aug 10, 2013 at 12:15 PM, ribao wei riba...@gmail.com wrote: Hi Martin, Thanks for your response. The concatenated file itself is a perfectly valid gzip file. Quote from RFC 1952 (http://www.ietf.org/rfc/rfc1952.txt ): A gzip file consists of a series of members (compressed data sets). The format of each member is specified in the following section. The members simply appear one after another in the file, with no additional information before, between, or after them. It doesn't make sense if I can't extract a valid gzip file if I don't know the structure of this file beforehand. I am not sure why Node's zlib module assumes the second piece is not gzipped data set. And it seems to be hard to tell from its API how many bytes it has decompressed also. To make sure this is not a common practice, I tested GO's gzip module, which extracts the 2nd file correctly. (Code attached below). // gzip-test.go package main import ( fmt compress/gzip os bufio ) func main(){ file, _ := os.Open(3.txt.gz); fileGzip, _ := gzip.NewReader(file); fileRead:= bufio.NewReader(fileGzip) i := 0 for { line, err := fileRead.ReadString('\n') if err != nil { break } fmt.Printf(Line %v: %s, i, line) i++ } } -- Forwarded message -- From: Martin Cooper mfncoo...@gmail.com Date: Aug 10, 2013 7:44 AM Subject: Re: [nodejs] zlib fails to extract concatenated files To: nodejs@googlegroups.com Cc: This isn't a bug. The zlib module decompressed the raw gzipped buffer and stopped. It isn't the job of zlib to try to infer any structure on the buffer you gave it, or to attempt to look for more work to do after finishing what it was asked to do. Subsequent data in the buffer could be anything, after all, not just gzipped data. In contrast, the gunzip command is being told this is a gzipped file (and nothing else), so it's reasonable for it to continue after processing one compressed buffer to see if it can do more. Note that, in your case, you can gunzip the second chunk by slicing it from the original buffer. But remember that only you know the structure of the file you are reading; there is no structure embedded within the file for some piece of code to interpret. -- Martin Cooper On Fri, Aug 9, 2013 at 11:45 PM, ribao wei riba...@gmail.com wrote: Hi, I just encounter this and not sure whether it is a bug in zlib module. echo 1 1.txt echo 2 2.txt gzip 1.txt gzip 2.txt cat 1.txt.gz 2.txt.gz 3.txt.gz Now, gunzip 3.txt.gz prints: 1 2 However, zlib.gunzip(fs.writeReadSync(**c.gz), function (err, buffer) { console.log(buffer.toString())**; }); prints: 1 (empty line) Am I missing something? Thanks, Wei -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com
Re: [nodejs] Help: Post query not working with express.js
You need to give the textarea a name. Try: textarea(name='thing') Type Something. -- Martin Cooper On Sat, Aug 3, 2013 at 7:31 AM, Ashutosh Das areos...@gmail.com wrote: I m coding simple cms using tinymce , Here is the code of Jade part : body form(method=post ,action='edit') textarea Type Something. br input(type='submit', name=name , value='name') and the express part : app.get('/edit', function(req, res){ }); app.post('/edit' , function(req, res){ console.log(JSON.stringify(req.body)); console.log('req.body.name', req.body['name']); }); Everytime i hit send button it simply returns : {name:names} req.body.name names -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] Node.js - Domain per Express request, inside another domain
Now why would it go and do something like that? Your call to the non-existent function is synchronous w.r.t. Express's request handling chain. This same issue came up here a couple of weeks ago. See: https://groups.google.com/forum/#!msg/nodejs/ZfaJPYyHKoA/BgHxErk9bEUJ If you wrapped your two statements in process.nextTick() / setImmediate(), you'd be fine. -- Martin Cooper On Fri, Jul 19, 2013 at 6:52 AM, Lee l...@leebenson.com wrote: *Copied from http://stackoverflow.com/questions/17729900/node-js-domain-per-express-request-inside-another-domain * I'm trying to layout a basic Node app like this... Cluster - Worker - Server Domain - Express Request Domain So, if an error is thrown 18 layers deep into a call stack because someone misspelled their name on a login form, the entire server doesn't crash. Here's some basic code to simulate the worker part: var domain, server; domain = require('domain'); server = domain.create(); server.on('error', function(e) { console.log('total meltdown...', e.stack); }); server.run(function() { var express = require('express')(); express.configure(function() { // Domain on EVERY request express.use(function(req, res, next) { var d = domain.create(); d.on('error', function(e) { console.log('fired REQUEST error', e.stack); next(e); }); d.run(next); }); // Generic error handler express.use(function(e, req, res, next) { res.status(500); res.end('oops'); }); // Serve the request with a blatent error express.get('/', function(req, res) { this_function_does_not_exist(); res.end('we will never get here'); }); }); // Fire 'er up express.listen(3000); }); What I'm expecting... I curl http://localhost:3000/, get a nice little 'oops' error, and see 'fired REQUEST error' and the error stack in the console. What actually happens... I get this both as the browser response, and in the console... ReferenceError: this_function_does_not_exist is not defined at /Stuff/test.js:38:13 at callbacks (/Stuff/node_modules/express/lib/router/index.js:161:37) at param (/Stuff/node_modules/express/lib/router/index.js:135:11) at pass (/Stuff/node_modules/express/lib/router/index.js:142:5) at Router._dispatch (/Stuff/node_modules/express/lib/router/index.js:170:5) at Object.router (/Stuff/node_modules/express/lib/router/index.js:33:10) at next (/Stuff/node_modules/express/node_modules/connect/lib/proto.js:190:15) at next (/Stuff/node_modules/express/node_modules/connect/lib/proto.js:192:9) at b (domain.js:183:18) at Domain.run (domain.js:123:23) Now why would it go and do something like that? -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] Announcement/Plea for help: Golems.io a Fixtures-As-A-Service solution
What you're describing sounds a lot like this: http://www.generatedata.com/ What would be the key differentiators? -- Martin Cooper On Fri, Jul 12, 2013 at 12:45 PM, Ken ken.woodr...@gmail.com wrote: TL;DR: I started something I can't finish, want to help me? Many times in my career I've found a need for large volumes of realistic test data (aka fixtures), and had long had a thought at the back of my mind that it could be well provided by a service. Last year I had time to work on the idea (using node.js), and made some good progress building the core technology in a project I'm calling golems.io. Later in the year I got sucked into a new venture (http://www.snupi.com/) and no longer have time to dedicate to this. However I don't want the effort so far to go to waste, and am wondering if 1) the community thinks this is a potentially valuable service, and 2) if there are any people or organizations out there interested in taking it on. So what's the point of this? There are many, but the most obvious use case I can think of: automated testing of web sites/services. Consider this form filling example from zombie.js http://zombie.labnotes.org/#Feeding browser. fill(Your Name, Arm Biter). fill(Profession, Living dead). select(Born, 1968). uncheck(Send me the newsletter). pressButton(Sign me up, function() { // Make sure we got redirected to thank you page. assert.equal(browser.location.pathname, /thankyou); }); Consider the second arguments to fill and select--where do these come from? Hard-coded values are perhaps fine for a simple unit test, but what if you wanted to create a few hundred or a few thousand subscribers for your newsletter? That's where a fixture generator comes in handy, but there are serious limitations to the existing ones. First consider the output of a class random fixture generator like Faker https://github.com/marak/Faker.js/ { name:Oswald Goldner, username:Izaiah, email:mich...@nicola.us, address:{zipcode:35411}, phone:1-658-413-1550 } While the text for each individual field is reasonable, there's no overall coherency: the name (Oswald...) and the email (Michael...) suggest two different people, the zip code suggests Alabama, the area code Oregon, the email address isn't actually usable, etc. There's another problem with using random data: it's nearly impossible to reproduce. Run the exact same test again and you could get totally different results. Now imagine a signup similar to the above that includes a password and a typical email confirmation step, where you send an email to the user and they click on a link in the email that includes a temporary unique key and requires them to reenter their password, then shows them a personalized congratulations Oswald Goldner page. To test that scenario you need both an email address that works, some way to access that address's mailbox, and some way of knowing or remembering the password and name across steps. This becomes quite difficult using transient random fixtures. Golems are a different approach to generating fixtures, using a deterministic but chaotic encryption algorithm instead of a random number generator. Realistic statistical data sets are used for demographic data and care is taken to ensure consistency when possible, e.g. zip code and area code; year of birth, gender and first name (they correlate surprisingly strongly, especially for females). Here's an example: { gender:female, given_name:Kimberly, family_name:West, birth_date:1979-05-23, username:g22yjght, password:2r%B0m%B, email:kimberly.west+22yj...@golems.io, address:{postal_code:94947}, phone_number:(707) 229-7163 } Every golem is grown from a single unique 32 bit number, given that number (and some keys and the right version of the code you can fully recreate every attribute of the golem. That number is directly derivable from a few of the fields which are globally unique (username and email in this case), but can typically be recovered from a few pieces of non-unique information (name and phone number would be enough). To fullfill the second part of our email-confirmation-round-trip test we actually need nothing more that the email address to which the confirmation was sent, from this we can recreate the full golem, retrieve the password, and even verify that the user's name is correctly displayed on the congratulations page. So where is this project at? I've developed all of the core enabling technology, much of the low level stuff is already made available on npm https://npmjs.org/%7Efemto113 and github https://github.com/femto113. There's a prototype version of a service running on Heroku http://api.golems.io/person/random.json ( http://api.golems.io/person/random.json). Some of the more advanced features (like an API to let you
Re: [nodejs] Re: Error handling: current state of affairs?
On Sun, Jul 7, 2013 at 10:01 PM, joel orengo...@gmail.com wrote: I started working a project https://github.com/oren/domains-examplesthat demonstrate domains both on vanilla node and with express (it's based on the nodeconf session). take a look and feel free to send pull requests. from some reason the /database route does not get caught by the domain - https://github.com/oren/domains-examples/blob/master/express/server.js#L35 any idea what's missing there? The problem is with Express. It wraps a try / catch around your request handler function, such that any synchronous exception (e.g. from your '/throw' handler) will be caught by that, and not handled by the domain. The reason your '/database' handler works is that the exception is thrown outside of the request handler itself, because of that setTimeout() call. -- Martin Cooper On Saturday, July 6, 2013 4:17:28 AM UTC-7, Tony Mobily wrote: Hi, I have been writing a bit of code with nodejs, and am sort of going back to brush things up, checking that I am doing things the right way. I recently read this: http://geoff.greer.fm/2012/06/**10/nodejs-dealing-with-errors/http://geoff.greer.fm/2012/06/10/nodejs-dealing-with-errors/ After a bit of research, I got to this article: http://benno.id.au/blog/2011/**08/08/nodejs-exceptionshttp://benno.id.au/blog/2011/08/08/nodejs-exceptions And to this SO answer: http://stackoverflow.com/**questions/7310521/node-js-** best-practice-exception-**handlinghttp://stackoverflow.com/questions/7310521/node-js-best-practice-exception-handling At the moment, I am only ever throwing() if: 1) I am enclosing _async_ code with try/catch, like this: // Get the messages from Json, safely try { if( ! req.body.messages ) throw( new Error(req.body.messages not there) ); var messages = JSON.parse(req.body.messages); } catch(e) { var messages = []; } 2) Something rlllyy**y bad happens in terms of how my module was used. For example a class constructor is missing a necessary parameter, etc. In any other case, I am using next( err ). If something really bad happens, for example mongodb dies and calls to the db start failing, I handle it with an error manager in express: app.use( function( err, req, res, next){ // ... }); But... does this mean that if my application uses a library that has a random throw(), my app will effectively die? What's the current state of affairs? Looking at existing code, well, I seem to have gotten it right: nodejs libraries tend to only throw when things really aren't supposed to happen. For example in qs/lib/querystring.js: function stringifyString(str, prefix) { if (!prefix) throw new TypeError('stringify expects an object'); return prefix + '=' + encodeURIComponent(str); } But... am I missing something? Would this be correct: * throw() when the program really deserves to die, and not for external causes (see: the db server goes down, etc.) * Always use next( err ) if anything goes wrong (business as usual) * Figure out if some libraries emit events, and listen to them if necessary Bye, Merc. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] Assertion Error: Path must be string
On Mon, Jul 1, 2013 at 8:43 AM, supr_utah suprajasank...@gmail.com wrote: Hello. I installed nodemailer. I get an Assertion Error: Path must be string error. You should have a call stack, too, telling you where the assertion happened. The error is coming from someone passing a non-string to require(). The assertion was added in Node v0.10.x. I suspect the error is in your own code, since I can require('nodemailer') on Node v0.10.5 without any problems. -- Martin Cooper I am working in coffeescript. I do: nodemailer = require('nodemailer') Is this a known bug ? I reinstalled nodemailer. Please help. Thanks -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] Looking for design pattern or module to invoke Re-Authentication in a REST client I am building
On Wed, Jun 26, 2013 at 4:42 PM, Nate D damin...@gmail.com wrote: I am writing some node based services that run all day, pull data of a queue, perform some processing steps, then does some CRUD operations to a REST service/API with an authenticated session. The authentication is standard POST user/pass params to site root/api/auth/login, session is created and token returned. After trying out a few modules I have started with request ( https://github.com/mikeal/request) and written a module that creates a little API wrapper around it. The pattern I would like to do is each API call will check the response, if there is an unauthorized error, it will attempt X times to create a new session, and re-call the API call. There is design issue around not having a handle on the original callback and losign its context should a re-auth be necessary. The processor would make a call like this: var requestID = apiClient.testPing(function(err,respObj,body){ console.log(inside of processor api callback...); }); Then inside the apiClient, the testPing call would be: this.testPing = function(callback) { var opts = { uri:_this._host+'/'+_this._apiVersion+'/test/ping' }; var reqId = _this._uuid.v4(); _this._reqs[reqId] = { id:reqId, callback:callback, //this is the callback passed to the API client call from the queue processor call func:function(err,resp,body) { console.log(inside api response callback, if auth error, call reAuth, on successful re-authentication re-call testPing); } }; _this._request.get(opts,_this._reqs[reqId].func); //use the node-request module object to carry out the REST call return reqId; //return the request ID } I am trying the following pattern where I generate a request object, with an assigned UUID as its key and use that to maintain state. Issue is that I have no way to know which request ID I am in since the node-request module, and others I have tried, fire the callbacks under the context of its request. Perhaps I'm misunderstanding, but it looks to me like all you need is to bind the callback to your context object. Something like this (which is untested) will result in 'this' in your callback being the ctx object. Note the call to bind(). I've added 'self' to the context object so you can get back to '_this' if you need to. var ctx = { id:reqId, self: _this,// so that you can get back to whatever _this is, if you need to callback:callback, //this is the callback passed to the API client call from the queue processor call }; ctx.func = function(err,resp,body) { console.log(inside api response callback, if auth error, call reAuth, on successful re-authentication re-call testPing); }.bind(ctx); _this._reqs[reqId] = ctx; _this._request.get(opts,ctx.func); //use the node-request module object to carry out the REST call Hope that helps. -- Martin Cooper After looking as many of the REST Client modules most handle basic HTTPAuth, but no hooks/tools for standard forms of authing/auto-re-auth. The restler module seemed like it might be a fit with its .on callbacks and retries built in, but still doesn't quite fit. Is there any node pattern(s) people have used that would solve this problem? Or maybe a module out there my searches haven't revealed yet, so far looked through (request,restify,restler,node-rest-client) -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop
Re: [nodejs] [ANN] ynpm: using package.yaml files instead of package.json
On Mon, Jun 24, 2013 at 11:24 AM, Alex Kocharin a...@equenext.com wrote: Hi Isaac, I'd recommend against using `ynpm` as the bin name, if only because I'm an ex-yahoo, and `ynpm` sounds like Yahoo!'s fork of npm ;) Isn't it a good thing that Yahoo won't be able to fork it under this name? :) Actually, Yahoo! has had an internal customised version of npm under the name 'ynpm' for about 2 years now. It's not published to the public registry because the changes and extensions relate to proprietary technologies. As for whether it's a good thing or not that you named your package 'ynpm', I'll say only that this will make it difficult for people at Yahoo! to experiment with your package. :-) Oh well... could you please suggest another name? I really so bad at naming things... I'm not good at naming things either. A few ideas off the top of my head: alt-npm, yapm, ypkg, yaml-pkg, ypnpm (yaml-patched npm). Did I say I was no good at naming things? :-) -- Martin Cooper Special keys are obviously ugly and generate too much noise. Besides, originally I wanted to comment dependencies, so it can't be used anyway. This was discussed over and over in the past. There was just one acceptable solution (it's javascript instead of json which compiles to json when publishing), but it's long gone now. :( On Monday, June 24, 2013 7:37:07 PM UTC+4, Isaac Schlueter wrote: As with using CoffeeScript or Streamline to write your JavaScript, I have no problem with stuff like this for publishing to npm, as long as what ends up in the registry is regular json and javascript. I'd recommend against using `ynpm` as the bin name, if only because I'm an ex-yahoo, and `ynpm` sounds like Yahoo!'s fork of npm ;) You know, you CAN put comments in JSON by just using a key that isn't used for anything else. You can't put it in places (such as `dependencies`) where the key name is relevant information, of course. But at the top-level, this is fine: ```json { name: silverware-drawer , description: BECAUSE ITS FULL OF FORKS GET IT!? , //: [ This package.json file has a lot of forks on github , of things that I've forked and added patches to. , I'll use the 'real' one once they're merged. ] , //0: Use an ID on multiple comments so they don't clobber , //1: {this:may,not:be,**ideal:but,it:works} , dependencies: { foo:my/fork } } ``` On Sun, Jun 23, 2013 at 11:59 AM, Alex Kocharin al...@equenext.com wrote: When ynpm looks in a directory, it sees both files: real yaml file and a virtual json file. So it packs both. It's very much intentional to ensure interoperability. We can use whatever we want in development enviroment (coffee-script, package.yaml, other cool stuff), but other people who will install a package from registry should have as little issues with it as possible, which means compiled to javascript modules and a package.json format. On Sunday, June 23, 2013 10:32:19 PM UTC+4, José F. Romaniello wrote: Do you pack/publish with package.yaml inside? How does that works with the npm service? El 23/06/2013 13:12, Alex Kocharin al...@equenext.com escribió: Hi guys, TL;DR: I developed a package that monkey-patches npm to work with package.yaml files without any json ever written to a disk. Hope it will be useful. Published as npm module a month ago: https://npmjs.org/package/ynpm (github: https://github.com/rlidwka/**ynpmhttps://github.com/rlidwka/ynpm), and I think it's ready to use now. So, 6 months ago I asked in the mailing list about how to place comments in package.json files ( https://groups.google.com/**forum/?fromgroups#!topic/** nodejs/NmL7jdeuw0Mhttps://groups.google.com/forum/?fromgroups#!topic/nodejs/NmL7jdeuw0M) and found no good answer for that. So for a long time I used package.js and a Makefile to generate package.json. Rather ugly solution. We were developing a large and complex project, and I submitted dozens pull requests to other packages. But until these PR were merged, I needed to point these dependencies to my git repositories with these changes in place. And THAT is why I desperately needed comments. So anyway... these are fundamental issues with JSON: 1. JSON have no comments, you can't comment out why did you put some dependency, but not the other. 2. JSON have no trailing comma. So you can't easily remove an item, add an item or interchange two arbitrary lines in a list. 3. JSON require ugly enquoting both keys and values in object. Javascript require enquoting values only, and YAML doesn't require quotes in most cases. JSON is designed to be written by computers, not humans. Humans could read it easily, but maintaining JSON is a pain. Why YAML? Well, I would certainly not use XML. :) Anyway, YAML it's easier to read and edit than all other widely known serialization formats, and it solves all issues described above. I
Re: [nodejs] How to report errors from streams
On Tue, Jun 18, 2013 at 1:57 AM, Ryan Schmidt google-2...@ryandesign.comwrote: Thanks. Emitting errors is working somewhat. I've read about domains but haven't worked with them before. I tried using them a couple days ago and found that using domains with connect (and therefore express) is not straightforward. I found a module to help with this: https://npmjs.org/package/connect-domain But it behaved strangely: The first time I hit an error page it showed up fine but subsequent error pages would cause the server to hang indefinitely. So I removed connect-domain. One problem with this one is that it doesn't add the request and response to the domain that it creates. In fact, it doesn't add anything; it seems to assume you'll do that yourself, which rather defeats the purpose. Instead, it seems to focus on disposing of the domain explicitly (which I believe is not generally necessary). Today I found another module for this: https://npmjs.org/package/express-domain-middleware I've included it and so far it hasn't done anything weird, though I'm not sure I fully understand how I need to modify my code throughout my project to make it catch all errors. This is better, but if you encounter a problem before your code goes async, it won't be handled by the domain error handler, since that isn't added to the domain until *after* domain.run() (and hence next()) returns. The calls to run() and on() need to be switched. Domains are probably a good thing for me to be using anyway, but I'm not sure if they help with the specific problems I'm having. Domains are primarily for handling uncaught errors and exceptions. Since it looks like you have error handlers in most places, it's not clear that an error from spawn() will reach the domain error handler, if it ends up being caught and handled elsewhere. -- Martin Cooper Here's a simplified example of what I'm working on. This is a small express app that uses request to download an image from a server, pipes it through ImageMagick's convert program to resize it, and pipes that to the http response. https://gist.github.com/ryandesign/5803661 If the request succeeds, and ImageMagick works, then the resized image is displayed in the browser. Good. If there are any errors fetching the image using request, the http response is given that information with a suitable http error code. Good. But if there is an ImageMagick error, the error only ends up in the server log, and the browser receives an empty http code 200 response. For example, in server.js, change -resize to -reesize in the arguments when creating the ProcessStream. This causes ImageMagick to exit with an error code and display a message that -reesize is not a valid option. But I need to be able to send that error (or a sanitized version of it) to the browser. On Jun 18, 2013, at 00:19, Forrest L Norvell wrote: Yes, emit errors instead of throwing them. If there's no error listener attached, EventEmitter is special-cased to throw when errors are encountered. That plus a domain used by the developer consuming the stream (with the stream optionally added to the domain, if it's only going to be used with a single domain) will make sure that the error gets routed to where it needs to go. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] Re: Having trouble replicating with npm repo (couchdb) - anyone tried it lately and/or seen this error?
On Sat, May 18, 2013 at 9:45 AM, Alex Kocharin a...@equenext.com wrote: Why do you want replication at all? I was thinking about it for myself recently, but I found out that there're lots of libraries you won't ever use. One reason for replicating is to protect yourself against an outage of the npmjs.org registry. It doesn't happen often, but it does happen. So isn't it better to write something like proxying repository server that would host your private projects, but proxy all other requests to npm central repository (with caching of course to avoid heavy load)? Something like shadow-npm, for example: https://github.com/dominictarr/shadow-npm (Caveat - I haven't actually used this, I just know it's out there.) -- Martin Cooper On Tuesday, May 14, 2013 7:16:51 AM UTC+4, andy wrote: Based on the awesome feedback I got from https://groups.google.com/d/msg/nodejs/sX4mbsRPwls/WtDDE-To2o4J, we tried replicating the npm repo so we could use it in an offline environment. We're essentially following the instructions at http://clock.co.uk/tech-blogs/how-to-create-a-private-npmjs-repositorybut replication fails after syncing about 17k documents. We've tried reinstalling couch (found one issue that suggested using a patched version of SpiderMonkey) but the same thing keeps happening, even after restarting replication several times. Here's our setup: CentOS 6.4 CouchDB 1.3 SpiderMonkey 1.8.5-7 Replication works fine for over 17,000 documents, then we see this error and can't get past it: [Sat, 11 May 2013 00:55:39 GMT] [error] [0.12970.4] Replicator: couldn't write document `bufferhelper`, revision `19-d339684ee7f5eaf4cc18d84da753832d`, to target database `registry`. Error: `unauthorized`, reason: `Please log in before writing to the db`. Any ideas? Thanks, Andy -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] preferred license for node modules?
On Tue, May 7, 2013 at 8:39 AM, Alex Kocharin a...@kocharin.ru wrote: You can use dual-licensing. Let people choose GPL or commercial license, so anyone who can't use infectious type will be forced to pay... ... or simply choose a different package. It's open source; if people don't like the terms, and there's a need, someone else will write one with more acceptable terms. You won't force anyone to pay. -- Martin Cooper -- // alex 07.05.2013, 16:51, Saleem Abdul Hamid meel...@gmail.com: Is there a license that says most people can do whatever you want with my stuff but if Microsoft (example) uses it to make 100 million dollars, I want to negotiate for a piece of it? That's really the question everyone is asking, although they're too shy to say it, because wanting to make money off of your stuff is considered bad form in certain quarters. Personally, even if a huge company with a lot of money was using one of my projects as an integral part of a moneymaker, I'd be happy with a very, very fair (for them) royalty that they would probably not even consider significant. But if you use the MIT, the question of negotiating anything doesn't even come up. To be clear, I want a license that is not infectious at all. That lets people use, modify, redistribute, all that good stuff. But just leaves open the door that if someone gets really rich using my project, I can benefit from coming up with the idea and doing the work. Is there a license that represents this? On Friday, December 14, 2012 10:38:05 PM UTC-5, Forrest L Norvell wrote: On Fri, Dec 14, 2012 at 7:29 PM, David Herron da...@davidherron.comwrote: I'm curious about the preferred license for modules that are distributed through the npmjs.org repository We discussed this a bit at NodeConf summer camp this year, and the consensus was pretty strongly in favor of BSD or MIT licenses, or at least pretty liberal, commercial-use friendly licenses (including the Perl and Apache licenses). In particular is there any legal barrier to using GPL in such modules? As far as I understand it, the legal barrier would be whether a module which uses a GPL'd module is derivative of that module. I don't think that it would be, but then the LGPL license does exist for a reason. Isaac can speak to this more authoritatively than I can, but npm itself prescribes / proscribes no particular licenses. You could attach GPL3 licenses to your modules if you wanted, but uptake would probably be hampered, especially if there were some kind of associated Canonical-style contributor's agreement. Node is still pretty much the wild west, and it's tough to say if today's random hack project might not become tomorrow's startup idea, and I think most devs want to keep their options open. F -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options
Re: [nodejs] api in npm for getting the number or list of dependent packages?
The simplest way is to grab the package metadata from the registry with this URL: http://registry.npmjs.org/package/latest That will get you a JSON version of the same object you see with 'npm view package', at which point you can just pluck out the 'dependencies' object. -- Martin Cooper On Sat, May 4, 2013 at 12:52 PM, Gregg Caines cai...@gmail.com wrote: Hey all, does anyone know if npm has an API (or couchdb view) for getting the list (or just the count) of dependent packages of a given package ? I suspect it does since npmjs.org has the info. I know there's an npm mailing list, but it mysteriously won't let me post. Thanks! G -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] Re: AngularJS inspired dependency injection in Node (feedback?)
The piece I'm still missing is, how do I inject modules I didn't write? For instance, how would I inject 'fs' or 'http'? Or perhaps 'request'? -- Martin Cooper On Thu, Apr 25, 2013 at 12:04 PM, Scott Corgan scottcor...@gmail.comwrote: Put together a quick blog post describing the problem I am solving and the why behind Injector: http://sctt.cc/6Mue On Saturday, April 20, 2013 10:19:27 AM UTC-7, Scott Corgan wrote: Not sure what kind of backlash I'll get for doing things slightly different than the Node way, but I wrote what I believe is the easiest and lightest solution I've seen for dependency injection for Node. It's call Injector https://github.com/scottcorgan/Injector ( https://github.com/**scottcorgan/Injectorhttps://github.com/scottcorgan/Injector ) The idea is that you add a comment at the top of the file // inject, then these files are automatically loaded and ready for injection. I've found it MUCH easier to inject mocks for tests. Also, when using this module, directory structure is only for visual organization for the coder. No need to worry about where the file is located, especially if you move the file to a different directory. Normally I'd just use another module, but I didn't find anything that was just easy. A lot of how the injection works is based off of the AngularJS source code. Anyways, would love some feedback. Always looking to improve the coding experience for developers. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] extracting a github tarball archive using streams
On Thu, Apr 25, 2013 at 8:40 PM, Glenn Scott glen...@glennsc.com wrote: I'm missing something obvious... when I download a tarball from Github and attempt to stream it to node-tar, the Extract method tells me I have an invalid tar file. Any ideas? var tar = require( 'tar' ) , request = require( 'request' ) , UA = 'test/1.0' , options = { headers: { User-Agent: UA } } , uri = 'https://api.github.com/repos/isaacs/node-tar/tarball/master ' , fs = require('fs') // this works request( uri, options ) .pipe( fs.createWriteStream( 'out.tar' ) ) .on( end, function() { console.log( 'done' ) }) .on( error, function( e ) { console.log( e ) }) /* // this doesn't work ('Error: invalid tar file') request( uri, options ) .pipe( tar.Extract( { path: __dirname + '/extract' } ) ) .on( end, function() { console.log( 'done' ) }) .on( error, function( e ) { console.log( e ) }) Right, because as Ryan mentioned, a tarball isn't a tar file, it's a .tar.gz file. You need something like: .pipe(zlib.Unzip()) .pipe( tar.Extract( { path: __dirname + '/extract' } ) ) (with the requisite error handling, of course). -- Martin Cooper */ -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] NPM - Working around SSH firewall blocks
On Tue, Mar 26, 2013 at 4:15 PM, Nathan White changereal...@gmail.comwrote: Martin you make a valid point. However what if I have a module that is proprietary? Your argument doesn't address this. No, I didn't address that, because it's an anti-pattern for the use of the npm registry. For example, see: https://groups.google.com/forum/#!msg/nodejs/MUxu6u_cjng/oyhpjyewufEJ While Isaac's message doesn't explicitly address non-proprietary packages with proprietary dependencies, I would expect the same rules to apply, since such packages are thereby unusable except to a privileged few. This type of uri reference works well if you don't want to deal with setting up your own npm server. Setting up an npm server is a pain, initial clone is around 40GB. The proposed option definitely allows the node mantra of developing small packages while protecting corporate IP without the cost of maintaining a dedicated npm server. You have at least three options: 1) Setting up your own registry is really quite straightforward, especially if you use a hosting service such as IrisCouch. Space-wise, 40GB is nothing these days. 2) There's at least one hosted npm service now, targeting users with private packages, and saving you the bother of setting it up yourself. See https://www.irisnpm.com/. 3) There are several lightweight registries designed specifically to sit in between your users and the public registry and handle private packages. For one example, see https://github.com/dominictarr/shadow-npm. -- Martin Cooper On Mar 25, 2013, at 8:29 PM, Martin Cooper mfncoo...@gmail.com wrote: My own perspective is that relying on projects that declare their dependencies this way is a really bad idea. They're relying on unreleased versions of packages that aren't necessarily considered stable enough for use by the package author in the first place. If the authors had considered them stable, they would have published to the npm registry, since that takes a matter of seconds. It's even worse when no commit is specified, since the dependency is then a moving target, changing with every commit, and you could be completely broken at any time. If your build servers are partially locked down for security reasons, I'd think you'd want to have the security of knowing that you have reproducible builds - that you'd get the same thing if you build the same project twice. With dependencies like this, you don't have that. I fully realise that this isn't what you're asking, but I submit that this is a bigger issue than just having npm futz around with the specified protocols to see if it can find one that works. -- Martin Cooper On Mon, Mar 25, 2013 at 4:46 PM, Daniel Wabyick dwaby...@gmail.comwrote: We have a build environment where our build servers do not have external SSH access for security reasons. We've got hit by the problem like in the following pull request [0], where an NPM dependency does not specify both the git+https protocol. [0] https://github.com/jsdoc3/jsdoc/pull/352/files Since this was a dependency of another project, we didn't really have an easy way to make this fix, and have to wait until it gets fixed in an NPM exposed repository. It seems like 'a good thing' if NPM either a) had a setting to allow git to imply git+https, or b) just always tried https if the git:// protocol failed. I'm interested in doing the work and making a pull request, but wanted to see if there was a downside to this approach that I'm missing. Personally, I would choose b) to keep settings to a minimum. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs
Re: [nodejs] NPM - Working around SSH firewall blocks
My own perspective is that relying on projects that declare their dependencies this way is a really bad idea. They're relying on unreleased versions of packages that aren't necessarily considered stable enough for use by the package author in the first place. If the authors had considered them stable, they would have published to the npm registry, since that takes a matter of seconds. It's even worse when no commit is specified, since the dependency is then a moving target, changing with every commit, and you could be completely broken at any time. If your build servers are partially locked down for security reasons, I'd think you'd want to have the security of knowing that you have reproducible builds - that you'd get the same thing if you build the same project twice. With dependencies like this, you don't have that. I fully realise that this isn't what you're asking, but I submit that this is a bigger issue than just having npm futz around with the specified protocols to see if it can find one that works. -- Martin Cooper On Mon, Mar 25, 2013 at 4:46 PM, Daniel Wabyick dwaby...@gmail.com wrote: We have a build environment where our build servers do not have external SSH access for security reasons. We've got hit by the problem like in the following pull request [0], where an NPM dependency does not specify both the git+https protocol. [0] https://github.com/jsdoc3/jsdoc/pull/352/files Since this was a dependency of another project, we didn't really have an easy way to make this fix, and have to wait until it gets fixed in an NPM exposed repository. It seems like 'a good thing' if NPM either a) had a setting to allow git to imply git+https, or b) just always tried https if the git:// protocol failed. I'm interested in doing the work and making a pull request, but wanted to see if there was a downside to this approach that I'm missing. Personally, I would choose b) to keep settings to a minimum. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] npm link and global-ness
On Sun, Mar 24, 2013 at 4:21 PM, Phil Jackson p...@apiaxle.com wrote: Hey all, I'm wondering why `npm link` installs modules in the global node path? When you `npm link`, it effectively creates a global install that can be accessed from any other project. You then create a local reference to that when you use `npm link package`. This way, the consumers are decoupled from the source package, via a level of indirection. The location used for this global install is by default the same location as for global installs of packages probably for convenience. There's no need for yet another location to be found in which to put the links. However, you're free to put these wherever you like, since the location is actually based on the configured `prefix` value, which you can change at will. So you're by no means tied to a location that requires sudo. -- Martin Cooper Before I bothered reading the man page I was doing this: $ npm link ../base in a project that depends on base. I was just expecting a symlink to the base package in ./node_modules but instead I get a link to a link in the global node path. The problem with this is that for developers who have installed node via package managers or somewhere under /usr they now need root access to do an `npm link`. Would a -g option to `npm link` make sense instead of being global by default? Cheers, Phil Jackson -- Apiaxle http://apiaxle.com - A free, open proxy for your API. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] [ANN] address-rfc2822
On Mon, Mar 18, 2013 at 8:16 AM, Matt hel...@gmail.com wrote: Travis is great, but covers one OS and one version of Node (from what I can tell). Just FYI, it's 3 versions of Node right now. You can choose one or more of 0.6, 0.8, 0.10. -- Martin Cooper Cpantesters covers about 15 different OS's and over 60 versions of Perl, and scales this way because they distribute the problem to end users. It includes current development versions of Perl as well as current and past stable versions. Travis is pretty weak in comparison. On Mon, Mar 18, 2013 at 9:53 AM, Arunoda Susiripala arunoda.susirip...@gmail.com wrote: Lack of tests Have you seen travis-ci. On Monday, March 18, 2013, Matt wrote: On Mon, Mar 18, 2013 at 6:59 AM, Thomas Shinnick tshin...@gmail.comwrote: editorial So many good old modules, accidentally duplicated by the new and eager, without reference to existing Perl/Python/whatever implementations. So many old mistakes, new again... /editorial I think the biggest mistakes in the node community are the lack of tests for npm modules, and the lack of a standardised output format (TAP) meaning that building something like http://static.cpantesters.org/ will be hard(er). It's pretty amazing in the Perl community to be able to release something and then a day later get a full report of cross platform/version compatibility from an army of build systems. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Arunoda Susiripala @arunoda http://twitter.com/arunoda http://gplus.to/arunodahttps://github.com/arunoda http://www.linkedin.com/in/arunoda -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] Buggy ES3 Code: Never Again!
On Wed, Mar 13, 2013 at 3:49 PM, AJ ONeal coola...@gmail.com wrote: FYI: grunt-init gruntplugin uses 'use strict'; for all grunt plugins. Yay! That's what we need to see more of! It would be nice if npm init would follow suit (or maybe it already does and I just haven't used it in 0.10 yet) npm init only creates the package.json file for you, so I wouldn't anticipate any use strict usage there. :) -- Martin Cooper AJ ONeal (317) 426-6525 On Wed, Mar 13, 2013 at 4:26 PM, Luke Arduini luke.ardu...@gmail.comwrote: Since use strict; is function scoped people should just use it in their modules so you can use both strict/non strict modules together in happiness. On Wed, Mar 13, 2013 at 5:47 PM, AJ ONeal coola...@gmail.com wrote: On Wed, Mar 13, 2013 at 3:22 PM, Adam Crabtree atcrabt...@gmail.comwrote: I would guess almost nobody runs JSHint with strict mode settings on all their dependencies as well. That would be a maintenance nightmare. Regarding slowdown, there's been many many people from Google and others who've seen empirically that there are currently no speed benefits. Here are just the few I was able to find real quick: From http://scriptogr.am/micmath/post/should-you-use-strict-in-your-production-javascript : @paul_irish said: good post. good opportunity to point out you should run your unit tests against your production JS as well … also, last i asked the V8 guys, there is nothing that specifically accelerates strict mode … but of course, avoiding the slow non-strict stuff should keep your code off the slow paths inside the JS engines. From the v8-users list, https://groups.google.com/forum/?fromgroups=#!topic/v8-users/QVXyJKNShJQ : Rohit: Does V8's strict mode implementation offer any performance benefits? Jakob Kummerow: No. Again from the Nicholas Zackas post, http://www.nczonline.net/blog/2012/03/13/its-time-to-start-using-javascript-strict-mode/ : There is no reason to ship “use strict” in your production code. There is no performance gain (verified with V8 team and Brendan a while ago) and I don’t need my users’ VMs doing the extra checks as well. Also, IIRC someone in the previous strict mode discussion here verified that it does indeed run slower. Or how about about a handfull of different jsPerf tests? http://jsperf.com/use-strict-vs-array/3 http://jsperf.com/how-much-performance-is-gained-from-use-strict/3 http://jsperf.com/globalx/5 http://jsperf.com/use-strict-has-overheads-hmm-what Again, I'm not saying that performance isn't possible, which everyone agrees on. I'm talking about whether right now it is actually faster, and I haven't seen any declarations by people working on the project (or with the people) or test cases to indicate it is. Also, 13:30 is talk on callbacks in Dart. :-/ 12:30 is about callbacks in dart. 13:30 is about v8 optimizations. It's like I said: All of the code is run with strict mode optimizations and then bails out when in runs into code isn't complaint. Putting strict mode; in your code is more for the purpose of built-in linting. Except for some weird things - like that eval test from jsfiddle that was just posted, there should be no difference in speed of JSHinted code and formally declared strict mode. The strict mode just ensures that you can't at all accidentally use a particular set of bugs in the language (some of which only affect readability and code quality, some of which affect speed). It makes programming easier. As for the benchmarks, they're mostly testing very strange things - like eval or returning the global object or the creation of a function with use strict and the differences on most of them are less than 1% - which could be than my processor sneezed on the loser. Y'know? You don't generally create 1,000,000 strict mode functions. Rather you create you app in strict mode with a single IIFE and maybe it takes a few extra ops to validate the stricter syntax or whatever. AJ ONeal -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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
Re: [nodejs] Objects in node.js
On Sun, Mar 10, 2013 at 3:10 PM, Venkatesh U venkates...@gmail.com wrote: Hi, I have defined the following class in a .js file and I am trying to create an object of this class, but it is not working. I am getting undefined instead of the object, when I use the new. I am new to both node.js and JavaScript. It will be great help to me, if somebody can give some insights on how to do simple OOP in node.js. Thanks in advance. Did you export DBManager from smailer.js? -- Martin Cooper Venki function DBManager(port, host, dbname) { // Retrieve var MongoClient = require('mongodb').MongoClient; // Connect to the db MongoClient.connect(mongodb://localhost: + port + / + dbname, function( err, db) { if (!err) { console.log(We are connected); this.db = db; this.domainStore = this.db.collection('domain', function(err, result) { if (err) { console.log(unable to get domain store + err); } }); this.emailStore = this.db.collection('email', function(err, result) { if (err) { console.log(unable to get email store + err); } }); } }); }; I am creating the object by using the below code. var z = require('./smailer.js') var k = new z.DBManager(27017, 'localhost', 'dev') k {} -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] Re: learning NodeJS and looking for something similar to Apache Wicket (or similar component framework)
On Thu, Mar 7, 2013 at 11:28 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi, On Thu, Mar 7, 2013 at 4:44 PM, greelgorke greelgo...@gmail.com wrote: well most of node template engines don't want to copy desktop gui frameworks, because html is already a gui framework. what your examples do, is solved in engines like jade via partials et al. Jade supports reusability of template componentes via partials, inheritance and mixins. in jade it is handled like this: 1. its a layout and your wicket components here are *block* statements 2. it's a partial, that implements a component 3. its a normal view, which extends the layout and includes the partials or mixings Yes mixings are some form of components... But not as powerful as I was hoping for: IMHO this is far away from what Wicket component models offer. i think it's not that hard to use the components from Component wrapped in partials : I would like everything (e.g. my extended mixings) to behave as components as well. Maybe I should give it a try and create want I want myself;-) You might want to take a look at Mojito: https://github.com/yahoo/mojito -- Martin Cooper -- Regards - Ernesto Reinaldo Barreiro -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [nodejs] fs.createWritestream change path dynamically
On Thu, Mar 7, 2013 at 6:35 AM, Thorsten Moeller tmoel...@fastmail.fmwrote: Hi, i am creating a writestream on a server connection event using a path join of a fix path and a variable for the filename. As the filename is not known on server connection event (sent later via connection data event) , it is empty and therefore not working afterwards, producing errors (connot open file). Be *very* careful about using any filename, or portion of a filename, that was provided to you by a client. Using that as part of a filename or path on the server is a potentially major security hole, and best avoided. I'd agree with greelgorke that using a temp file on the server is a better approach. If you need to retain a mapping between uploaded data and a client filename, do that elsewhere (e.g. a database), and not by trying to use the same file system naming and / or structure as the client. -- Martin Cooper Is there a way to handle this more dynamically?? Perhaps creating the stream first like an global object and later set the filename and then using the stream via something like a method??? Regards Thorsten -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups nodejs group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[nodejs] [ANN] mockery 1.4.0, now with cache control
One of the issues people ran into with earlier versions of mockery has been updating the Node module cache. In particular, caching of mocks beyond their intended usage, and caching of previously 'require'd modules causing problems with mocks being picked up. The recently-released mockery 1.4.0 has a new option specifically to allow some control over this. It's called the clean cache option, and allows you to run your tests as if Node had an empty module cache. See: https://github.com/mfncooper/mockery#controlling-the-module-cache For mockery in general: npm install mockery https://npmjs.org/package/mockery https://github.com/mfncooper/mockery Note: Please don't confuse 'mockery' with 'Mockery', which someone else created a few months after 'mockery' was released and then deprecated but which is still in the registry. -- Martin Cooper -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] [Idea]: npm as a dependancy injector.
On Sat, Jan 19, 2013 at 8:15 PM, Athan Clark athan.cl...@gmail.com wrote: Hello everyone. I'd like to make unit testing a practice difficult to evade in Node.js. One of the requirements, though, is that you need to be able to test a module's functionality independently of it's dependencies (say that 10 times fast!). This is what mockery is designed to help with: https://github.com/mfncooper/mockery Especially with the recently-added clean cache option, you can mock out dependencies of your modules or even of your dependencies, and test with the isolation you're looking for. -- Martin Cooper My idea is to make node more flexible in the directories it chooses to look for node modules by providing an alternative mode for it to look in - ie if *NODE_MODE* is set to test, then npm will first try to look in ./test_node_modules for a package before looking in ./node_modules. That way we can provide *alternative *modules for a package - ie mock ones. Or if you were trying to make a package that was compatible with similar modules, you could have a 3rd party testing package, like a simple blog, that uses the similar package in one mode, then your package in another. Imagine being able to do a *`npm run-scripts test --deep`*, and then see each and every module complete a unit test before progressively walking up the dependance tree making scenario tests along the way. It makes my continuous integration senses salivate. What do you all think? Could someone could direct me to where/how npm / node implements `require();`? Where should I start? Thanks in advance!! -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] [ANN] middler - an embeddable middleware runner
On Wed, Jan 16, 2013 at 8:49 PM, carlos8f carlo...@gmail.com wrote: Connect is great, it can be nested as you say, but it doesn't have a router. This is a little ironic since connect 1.x did have a router built in, but it was pulled out so that connect would have fewer baked-in dependencies, and be less opinionated about how routes should be done. That is, the router was pulled out of connect partly to make connect more like what you're targeting middler to be, as I understand it. :-) In any case, that original connect router is still available as middleware: https://npmjs.org/package/connect_router so you can choose to use that, or you can choose to do routing some other way and just not include the code. Express has a router, but gives away the embeddability. Middler aims at giving the best of both worlds, in a slim package. Basically, what is different about middler is it unites what were previously two separate development workflows: writing middleware, and constructing an app, which uses the middleware, defines routes, and attaches to or listens on a server. With middler, you can write your app **as** a collection of nestable route-aware middleware, or you can write your middleware as a miniature app, using the built-in router (but exporting a middleware handler instead of a server). The former is what I've been doing with connect, using nesting to create a tree of middleware that is the app. The other perk is that middler has no dependencies, which can help minimize your app breaking by changes introduced in upstream modules (a fairly common occurrence with npm-deployed code). Well, yes, but as soon as you start introducing the middleware that does the real work, you start introducing dependencies anyway, unless you're going to write all your own middleware. :-) That said, I accept that this will minimise dependencies that you won't be using. -- Martin Cooper It's also worth saying that the middleware included in connect is a great companion to a middler-driven app, and likewise middler can be used to build advanced middleware for use with connect. The two are not competitors, rather, they complement each other. On Sunday, January 13, 2013 3:26:49 PM UTC-8, Martin Cooper wrote: On Thu, Jan 10, 2013 at 4:27 PM, carlos8f carl...@gmail.com wrote: Hi, I'd like to announce the availability of middler, a project I started last summer. https://github.com/carlos8f/**node-middlerhttps://github.com/carlos8f/node-middler Basically, you might think of it as a mini express which allows you to easily attach a middleware stack to an http server, with a chainable routing interface and parameter parsing. What makes it unique is that your middleware stack can be turned into a super middleware handler, to add to another middleware stack -- this is the embeddable concept. Perhaps I'm misunderstanding, but this isn't unique. I can do the same thing with connect: var nested_chain = connect() .use(nested_1) .use(nested_2); var outer = connect() .use(outer_1) .use(nested_chain) .use(outer_2); outer.listen(port); In keeping with separation of concerns, I wanted middler to **not** come with batteries included - it doesn't want to create a server for you, or handle configuration, or provide you with a bunch of starter middleware. This makes it a great choice for writing compact modules which simply use middler's API and export a middleware handler. It also performs well as a leaner express if you decide to build an app around it. And of course, it's compatible with existing connect/express/flatiron middleware, especially using the expres shim: https://github.com/**cpsubrian/node-expreshttps://github.com/cpsubrian/node-expres I think I'm missing what really distinguishes middler from connect, since they look very much alike to me. Could you say some more about when it would benefit me to pick middler over connect? -- Martin Cooper Other nice things: - used in production ~5 months, with great results - tested on travis-ci - very fast - benchmarks included - no dependencies - middleware stack can be manipulated at runtime - supports weights, to control the order of handler execution Feedback welcome! Cheers, Carlos -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/**node/wiki/Mailing-List-* *Posting-Guidelineshttps://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 nod...@googlegroups.com To unsubscribe from this group, send email to nodejs+un...@**googlegroups.com For more options, visit this group at http://groups.google.com/**group/nodejs?hl=en?hl=enhttp://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki
Re: [nodejs] [ANN] middler - an embeddable middleware runner
On Thu, Jan 10, 2013 at 4:27 PM, carlos8f carlo...@gmail.com wrote: Hi, I'd like to announce the availability of middler, a project I started last summer. https://github.com/carlos8f/node-middler Basically, you might think of it as a mini express which allows you to easily attach a middleware stack to an http server, with a chainable routing interface and parameter parsing. What makes it unique is that your middleware stack can be turned into a super middleware handler, to add to another middleware stack -- this is the embeddable concept. Perhaps I'm misunderstanding, but this isn't unique. I can do the same thing with connect: var nested_chain = connect() .use(nested_1) .use(nested_2); var outer = connect() .use(outer_1) .use(nested_chain) .use(outer_2); outer.listen(port); In keeping with separation of concerns, I wanted middler to **not** come with batteries included - it doesn't want to create a server for you, or handle configuration, or provide you with a bunch of starter middleware. This makes it a great choice for writing compact modules which simply use middler's API and export a middleware handler. It also performs well as a leaner express if you decide to build an app around it. And of course, it's compatible with existing connect/express/flatiron middleware, especially using the expres shim: https://github.com/cpsubrian/node-expres I think I'm missing what really distinguishes middler from connect, since they look very much alike to me. Could you say some more about when it would benefit me to pick middler over connect? -- Martin Cooper Other nice things: - used in production ~5 months, with great results - tested on travis-ci - very fast - benchmarks included - no dependencies - middleware stack can be manipulated at runtime - supports weights, to control the order of handler execution Feedback welcome! Cheers, Carlos -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] comments in package.json
On Sat, Jan 5, 2013 at 5:36 PM, Alex Kocharin a...@kocharin.ru wrote: Hi Dick, I explained that in an initial message. Well... it won't hurt to repeat though. 1. This is not highlighted by editors properly 2. This is too long, dozen characters instead of two or three //: shorter 3. No multiline comments comment: [ This, is, a, multiline, comment ] -- Martin Cooper 4. Isn't allowed by strict javascript (so, we might expect some trouble in the far future) 5. Looks ugly -- Regards, Alex 06.01.2013, 02:21, Dick Hardt dick.ha...@gmail.com: Or you could add a comment property to the JSON , comment: Here is a comment npm will ignore it, or may use it in the future for showing comments in some way On Jan 5, 2013, at 1:54 PM, Eric Mill konkl...@gmail.com wrote: It can often be a good idea to add comments for yourself and others around your dependencies, especially on a large project. It doesn't mean you made bad choices about your dependencies. When stuff gets large, it helps to group things, label them, etc. As package.json's get used for more and more things (for example, my deploys to my app host involve setting custom fields in package.json that they use to govern DNS and stuff), it'll become handier to have the ability to comment things. Also, to comment things in and out at will, during development. We all do that with things. Plus, yes, being able to drop the quotes around keys is nice too. This is why when I make config files for myself, I make them .js files instead of .json. Preface the object with a module.exports = , and you can say var config = require(./config) very easily. It's a lot more convenient. -- Eric On Sat, Jan 5, 2013 at 3:44 PM, Rick Waldron waldron.r...@gmail.comwrote: I'd be more concerned with having configuration options that were obtuse enough to require in-line comments. Rick On Sat, Jan 5, 2013 at 3:35 PM, Ilya Dmitrichenko errordevelo...@gmail.com wrote: Why cannot you add a section on dependencies in the README file? There you can explain in plain-english whatever you wanna say about those dependencies! Cheers, -- Ilya On 5 January 2013 18:22, Alex Kocharin a...@kocharin.ru wrote: Hello, everybody. TL;DR: I think that JSON is not a suitable config file format, and I want npm to be able to read configs stored in some other way by default. It might be just javascript, or yaml, I don't really care as long as it better for configuration files than json. So, there is a dependency list in package.json, and it would be a good practice to have a comment for every line describing why we require that package, why we require that version of that package, what known problems we have and so on. But there's a small issue. JSON format doesn't allow comments in any way. Right now there are a couple of different ways around it of course: 1. Non-standard JSON entries like @comment: blablabla. Unfortunately, javascript editors doesn't highlight it as a comment, and it's just plain ugly. Also this violates strict javascript mode, so God knows what trouble it'll cause in the future. 2. Keep a commented dependency list in a separate file. This violates DRY principle, so we could update one file and forget to update another. The same goes for /**package **/ hack I believe. 3. Use some kind of build system. Just for damn comments in one file? Also, there's another wrong thing with JSON, it's too strict. You can't omit double quotes from keys, you can't leave a trailing comma, etc. JSON is human-readable, but it's just not damn human-writable. Well... I went for 3rd option for a very long time. We used package.js file and a Makefile that compile js to json. Yes, that's three damn files instead of one. That's an example of our package.js file. https://gist.github.com/4462764 . But a number of supported packages grew, and compiling this slowly became a major pain in the ass. I recently got an issue when I updated package.js, but forgot to compile it, and debugging this one was a quite interesting experience. So, I'm now in a mood of forking things and making all my public packages incompatible with mainstream npm... So, there's a couple of alternatives. For example, Travis use YAML, and there is CSON (it's coffeescript version with blackjack and hookers). And I think there was a couple of discussions about it. So, did anybody come up with more or less sane idea how to deal with this? What happened to package.json.js? Happy New Year! -- 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+unsubscr...@googlegroups.com For more options, visit
Re: [nodejs] Manually install module that isn't in NPM
On Sun, Dec 30, 2012 at 8:13 AM, hashi101 krzyszczukka...@gmail.com wrote: I try to install Socket.io 1.0,so I downloaded socket.io-1.0 and socket.io-client-1.0 packages. And put it in node_modules folder. What's the reason you're not just using npm to install this? It sounds like you are downloading the tarballs manually and then just expanding them. That's not enough for many packages. Even if you download the tarballs, you'll still need to use npm to install the packages (i.e. 'npm install tarball'), so that npm can run all the right scripts at the right points in the installation process, etc. -- Martin Cooper Changed socket.io-client to socket.io.client-1.0 in some files, because they except the first name. And then I run sample application: var io = require('socket.io-1.0')(7001); io.on('connection', function(socket){ socket.on('event', function(data){}); socket.on('disconnect', function(){}); }); output was full of not installed modules, so I installed them up, and now, when I run code above, get this: io.on('connection', function(socket){ ^ TypeError: Object #Server has no method 'on' at Object.anonymous (/usr/home/user/programs/soc10/soc.js:3:4) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.runMain (module.js:492:10) at process.startup.processNextTick.process._tickCallback (node.js:244:9) it should work. What i've done wrong? -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Manually install module that isn't in NPM
On Sun, Dec 30, 2012 at 8:55 AM, Kamil Krzyszczuk krzyszczukka...@gmail.com wrote: Nuno, read posts. Socket.io 1.0 isn't present in NPM yet. As I said in my previous post, you can use npm to install it from the tarball. That is, use npm, as Nuno said, or npm install gitrepostiroy#branch, as Jose said, are *not* the same as install from the registry. We understand you can't install from the registry. We're trying to give you workable alternatives. :) -- Martin Cooper 2012/12/30 Nuno Job nunojobpi...@gmail.com Use npm. Nuno Sent from my iPhone On Dec 30, 2012, at 4:13 PM, hashi101 krzyszczukka...@gmail.com wrote: I try to install Socket.io 1.0,so I downloaded socket.io-1.0 and socket.io-client-1.0 packages. And put it in node_modules folder. Changed socket.io-client to socket.io.client-1.0 in some files, because they except the first name. And then I run sample application: var io = require('socket.io-1.0')(7001); io.on('connection', function(socket){ socket.on('event', function(data){}); socket.on('disconnect', function(){}); }); output was full of not installed modules, so I installed them up, and now, when I run code above, get this: io.on('connection', function(socket){ ^ TypeError: Object #Server has no method 'on' at Object.anonymous (/usr/home/user/programs/soc10/soc.js:3:4) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.runMain (module.js:492:10) at process.startup.processNextTick.process._tickCallback (node.js:244:9) it should work. What i've done wrong? -- 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+unsubscr...@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+unsubscr...@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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Manually install module that isn't in NPM
On Sun, Dec 30, 2012 at 9:31 AM, Kamil Krzyszczuk krzyszczukka...@gmail.com wrote: Sry for my missunderstanding :) didn't know that there is official registry and options for others. So i tried it: npm install git://github.com/LearnBoost/socket.io.git but this installed just a 0.9.11 version. Maybe I copied wrong link, this is 1.0 branch: https://github.com/LearnBoost/socket.io/tree/1.0 can someone look at it and say where is a link that should be to copied? You need to add the tag to the URL. You'll also need to install the client first. Try this: $ npm install git://github.com/LearnBoost/socket.io-client.git#1.0 $ npm install git://github.com/LearnBoost/socket.io.git#1.0 It worked for me. -- Martin Cooper 2012/12/30 Martin Cooper mfncoo...@gmail.com On Sun, Dec 30, 2012 at 8:55 AM, Kamil Krzyszczuk krzyszczukka...@gmail.com wrote: Nuno, read posts. Socket.io 1.0 isn't present in NPM yet. As I said in my previous post, you can use npm to install it from the tarball. That is, use npm, as Nuno said, or npm install gitrepostiroy#branch, as Jose said, are *not* the same as install from the registry. We understand you can't install from the registry. We're trying to give you workable alternatives. :) -- Martin Cooper 2012/12/30 Nuno Job nunojobpi...@gmail.com Use npm. Nuno Sent from my iPhone On Dec 30, 2012, at 4:13 PM, hashi101 krzyszczukka...@gmail.com wrote: I try to install Socket.io 1.0,so I downloaded socket.io-1.0 and socket.io-client-1.0 packages. And put it in node_modules folder. Changed socket.io-client to socket.io.client-1.0 in some files, because they except the first name. And then I run sample application: var io = require('socket.io-1.0')(7001); io.on('connection', function(socket){ socket.on('event', function(data){}); socket.on('disconnect', function(){}); }); output was full of not installed modules, so I installed them up, and now, when I run code above, get this: io.on('connection', function(socket){ ^ TypeError: Object #Server has no method 'on' at Object.anonymous (/usr/home/user/programs/soc10/soc.js:3:4) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.runMain (module.js:492:10) at process.startup.processNextTick.process._tickCallback (node.js:244:9) it should work. What i've done wrong? -- 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+unsubscr...@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+unsubscr...@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+unsubscr...@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+unsubscr...@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+unsubscr...@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
Re: [nodejs] new concept for structured asynchronous programming
On Sat, Dec 29, 2012 at 8:45 PM, Tatumizer tatumi...@gmail.com wrote: What you describe as small and simple, but also idiomatic, can be said also about assembly language. Basically, what is the reason for having high-level languages? Everything can be done more efficiently in assembly, for sure. The problem of this logic is that it discounts the costs, and there's more than one type of costs (though all of them eventually have $$ expression). Imagine writing program consisting of 300 async calls in the idiomatic way you propose. Handling correctly all exceptions... Debugging such program... MAINTAINING it (300 is a number of async calls in a modest size project I saw recently). One of the issues you're facing right now, I think, is that many people here already have large systems built on Node, so they know exactly what's involved, from direct experience. But with Circuit, all we have today is a readme with some examples of adding and squaring numbers. There's a huge gulf between those two things. What would be very helpful to your cause, I think, is one or more of the following: * An example of a real Node app built using Circuit, so that people can see how it would be used to do real work (as opposed to adding numbers). * An explanation, with an example, of how (if at all) this fits in with Node's event model, and how it can help with common scenarios such as stream processing. * Some code that people can actually play around with to see how it works. Right now, we don't have any of those, so we can only speculate about what it might look like if we tried to use it for something real. -- Martin Cooper I don't know. If nodejs team believes current solutions are optimal, so be it. -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Load Html file.
On Fri, Dec 28, 2012 at 6:31 AM, Rodrigo Fonseca fonsecaa...@gmail.comwrote: *You haven't mentioned CSS before, and you haven't shown us the HTML content, so it's a little hard to know what's going on. However, I should point out that you are responding to *every* request to your server with the contents of the HTML file. So if your CSS URL is also pointing to the same server, it's going to retrieve HTML content and not CSS content. That would not be good! You would need to look at the request, in your server, to determine what you should be sending back. Again, the tutorials should help you understand this better.* * * * *Sorry, i'm doing a mcv app in node, i have a layout, so all i do is to put the content in this layout, so, if the url is test, this call test_controller, that render layou/layout and call layout_controller where is send to a function layout the object from test_controller, see: Since you're already working within a framework, it is extremely unlikely that you'll either need or want to create another server, especially inside a controller. What you describe above sounds like the routing part of the existing server, so you should be working within that. I see now that you mentioned Locomotive in your original message here. I'm not familiar with that, but I see that it has a Google Group of its own. I'd suggest you ask in that group how you should be addressing your problem within the context of that framework. You'll likely get more appropriate responses there, from people who know the framework you're using. -- Martin Cooper LayoutController.layout = function(obj) { var http = require('http'), fs = require('fs'); var html = fs.readFileSync('./app/views/'+ obj.__action+'/'+obj.fileName); http.createServer(function(request, response) { response.writeHeader(200, {Content-Type: text/html}); response.write(html); response.end(); }).listen(); obj.content = html; obj.render('layout/layout'); } As can be seen, this function read in on single place every different obj that comes here, but, as you can see, the layout is all the page with css and javascript, it's always static, only the content changes. So, as you can see again, the listen obj is empty, and it's works perfectly, but when i put some port happens what i said before. -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: require() MODULE_NOT_FOUND - yet it does exist
On Thu, Dec 27, 2012 at 12:43 AM, Jonathan Chayce Dickinson jonathand...@gmail.com wrote: In a nutshell you need to have the .js file in a directory node_modules either in the directory that contains the .js that is 'requiring', or a ancestor directory. For example, assuming the file that is 'requiring' lives at: /users/thatguy/dev/foo/bar/baz/myscript.js, the following paths would be checked for require('fob'). All of that is bypassed, though, if the value passed to require() is an absolute path. With an absolute path, the target can be anywhere, and no search / path walk is required. -- Martin Cooper - /users/thatguy/dev/foo/bar/baz/node_modules/fob.js - /users/thatguy/dev/foo/bar/baz/node_modules/fob/index.js - /users/thatguy/dev/foo/bar/node_modules/fob.js - /users/thatguy/dev/foo/bar/node_modules/fob/index.js - /users/thatguy/dev/foo/node_modules/fob.js - /users/thatguy/dev/foo/node_modules/fob/index.js - /users/thatguy/dev/node_modules/fob.js - /users/thatguy/dev/node_modules/fob/index.js - /users/thatguy/node_modules/fob.js - /users/thatguy/node_modules/fob/index.js - /users/node_modules/fob.js - /users/node_modules/fob/index.js - /node_modules/fob.js - /node_modules/fob/index.js Note that you can override the 'index.js' with a package.json: http://nodejs.org/api/modules.html#modules_folders_as_modules What I suspect may be catching you off-guard is that you assume that global modules are checked as well. The name is 'global modules' entirely misleading, it's more along the lines of 'global node binaries'. When you install a package with -g npm creates a script that invokes it and nothing more (allowing you to e.g. 'jake build' from anywhere). 'require' does *not *look in the global modules (you can get npm to symlinkhttps://npmjs.org/doc/link.html from the global modules into your local modules, but that is mostly 'superficial'). Jonathan On Thu, Dec 27, 2012 at 2:44 AM, Isaac Schlueter i...@izs.me wrote: Yeah, share the actual example code. require() works fine with absolute paths. $ cat b.js console.log('hello from b', __filename) ^D $ cat a.js require(require('path').resolve('b.js')) ^D $ node a.js hello from b /Users/isaacs/dev/js/node-master/b.js On Wed, Dec 26, 2012 at 4:33 PM, Domenic Denicola dome...@domenicdenicola.com wrote: I don't believe `require` works with absolute paths, like those generated by path.resolve. (Could be wrong.) If I'm correct, then you may find path.relative to be a useful method. Also note that of course path.resolve without a second argument will resolve relative to process.cwd(), not relative to __filename. This is rarely what you want. On Wednesday, December 26, 2012 10:12:13 AM UTC-5, dar...@darrenwhitlen.com wrote: Hi, Trying to simply require() in a .js file seems to be failing for me here, raising a MODULE_NOT_FOUND error. However - a fs.readFileSync() on the file does work. My current failing debug code: // Fails require(require('path').resolve(module_file)); // Works require('fs').readFileSync(require('path').resolve(module_file), 'UTF8'); Since the readFileSync() call works I can rule out any file/directory permissions leaving me with absolutely no ideas left as to why require() cannot find the file? Anyone have any debugging pointers to share? Darren -- 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+unsubscr...@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+unsubscr...@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+unsubscr...@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
Re: [nodejs] Inconsistent method names?
On Thu, Dec 27, 2012 at 1:06 PM, Rick Waldron waldron.r...@gmail.comwrote: Inline... On Thursday, December 27, 2012, Mark Hahn wrote: Why not also allow readDir? It would cause no harm to do so. This isn't node, but what also bugs me is typeof and instanceof. I cringe every time I type them. Completely irrelevant to the discussion... but you have my attention now—I'm curious to know what sort of program scenarios you've found yourself in where instanceof was the go to solution (but painful to use?), aside from useful type checking (types as in object types, not as in data-types). If you want to know if x has Foo constructor in its prototype chain, instanceof has you covered. Unless you're working with VMs, that is. Then you might not get the results you expect. For example, this: var vm = require('vm'), sandbox = {}; vm.runInNewContext(myDate = new Date(), sandbox); console.log(sandbox.myDate instanceof Date); will output 'false', because Date in the new context is not the same as Date in the original context. Just one of those little things to be aware of. -- Martin Cooper Rick On Thu, Dec 27, 2012 at 11:47 AM, David Habereder david.habere...@gmail.com wrote: That clears that up. Thanks. Am Donnerstag, 27. Dezember 2012 20:36:30 UTC+1 schrieb Matt Sergeant: I think you'll likely find where it isn't the case (such as readdir) the name comes from the POSIX function name. There's no readfile function in POSIX, but there is readdir(). The only other case seems to be readlink, which is the same issue. http://linux.die.net/man/2/readdir http://linux.die.net/man/2/readlink On Thu, Dec 27, 2012 at 1:02 PM, David Habereder david.h...@gmail.com wrote: Hi, I am quite new to node.js. As far as I can see the method names aren't very consistent. Take the methods from File System for example: http://nodejs.org/api/fs.html It is .readFile (Camelcase) But it is .readdir (all lowercase) There are a few more such cases where I don't see a pattern when camelcase is used and when not. You could say that this is absolutely irrelevant and you would be right. But it annoys me :-( And it reminds me of PHP syntax garbage. Is there any interest in getting all method names either camelcase or lowercase, or will this just stay as is? ~dave -- 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 nod...@googlegroups.com To unsubscribe from this group, send email to nodejs+un...@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+unsubscr...@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@go -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Load Html file.
On Thu, Dec 27, 2012 at 12:21 PM, Rodrigo Fonseca fonsecaa...@gmail.comwrote: No, the server is* created once*, and the (anonymous) function that was passed to createServer is called each time a request is handled. That function sends back the contents of the file that was read earlier. Ok, it´s created once, but, if there is another server that was created? I have to put the same port? Another thing interesting, when i put the same port or any other port in listen() is that when i reload in the first time my view is rendered normally, on the second time my view lose the css and on the third time i lost the contact with the server, but when i don´t put anything in listen, the view render normally, why? I'm reading these tutorial, understanding a bit the node, but this is really curious for me... You haven't mentioned CSS before, and you haven't shown us the HTML content, so it's a little hard to know what's going on. However, I should point out that you are responding to *every* request to your server with the contents of the HTML file. So if your CSS URL is also pointing to the same server, it's going to retrieve HTML content and not CSS content. That would not be good! You would need to look at the request, in your server, to determine what you should be sending back. Again, the tutorials should help you understand this better. -- Martin Cooper It might be a good idea for you to work through one or two tutorials on Node, so that you get a clearer picture of how it all works. You'll find pointers to several of those in the archives of this list. Those at http://www.nodetuts.com/ and http://www.nodebeginner.org/ seem to be fairly frequently referenced here. I started with nodebeginner, i'm really enjoying, thanks again. -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Load Html file.
On Wed, Dec 26, 2012 at 7:31 PM, Rodrigo Fonseca fonsecaa...@gmail.comwrote: I've to create a server just to read a file??? No, of course not. But your original code indicated that you want to read a file and then serve it. That's what Jose's code does - it reads the file (in one line of code), and then creates a server that serves the contents of that file each time a new request is made. I'm getting trouble with this, because always when i call a URL i create a server, because i put this inside of s function: No, the server is created once, and the (anonymous) function that was passed to createServer is called each time a request is handled. That function sends back the contents of the file that was read earlier. It might be a good idea for you to work through one or two tutorials on Node, so that you get a clearer picture of how it all works. You'll find pointers to several of those in the archives of this list. Those at http://www.nodetuts.com/ and http://www.nodebeginner.org/ seem to be fairly frequently referenced here. -- Martin Cooper http.createServer(function(request, response) { response.writeHeader(200, {Content-Type: text/html}); response.write(html); response.end(); }).listen(8000); -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] describe is not defined
On Mon, Dec 24, 2012 at 12:18 AM, Artur Vinogradov artur.drako...@gmail.com wrote: I installed mocha with -g parameter, though it's not been working for me with other modules: I always had to link them, so that i can require them. It looks like you're not starting mocha properly. You shouldn't have that require of 'mocha' in there, and you need to be starting this using 'mocha' on the command line. The thing with mocha is that it doesn't just require your test module. It loads it into a special context, which is where global functions like 'describe' come from. In your case, 'describe' is not defined almost certainly because mocha was not started properly. -- Martin Cooper This is my code: var Mocha = require('mocha'); var assert = require(assert) describe('Array', function(){ describe('#indexOf()', function(){ it('should return -1 when the value is not present', function(){ assert.equal(-1, [1,2,3].indexOf(5)); assert.equal(-1, [1,2,3].indexOf(0)); }) }) }) ReferenceError: describe is not defined at Object.anonymous (/home/user/mocha/prog.js:3:1) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.runMain (module.js:492:10) at process.startup.processNextTick.process._tickCallback (node.js:244:9) -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] execute child process as root user?
On Mon, Dec 24, 2012 at 1:17 AM, kuno neok...@gmail.com wrote: I am building a node module that interact with ejabberdhttp://ejabberd.im's control command line utlity `ejabberdctl`. Unfortunately, on most systems, you need a root user permission to running `ejabberdctl`, becuse it either locates at /usr/sbin or /usr/local/sbin dirctory. It seems to use this module, the whole process need to be running as a super user on *nix system. I wonder is there other way to resolve this issue? Check out the uid and gid options described here: http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options -- Martin Cooper --regards --kuno -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] preferred license for node modules?
On Sat, Dec 15, 2012 at 4:47 PM, David Herron da...@davidherron.com wrote: On Sat, Dec 15, 2012 at 1:16 PM, Jake Verbaten rayn...@gmail.com wrote: The virality of *GPL licenses as node modules has never been tested in court, so it's unclear what the ramifications are. To clarify, if I were to release a MIT module onto github or npm or some other distribution channel which has a dependency on an GPL module checked into node_modules into git. (so it's in my code). There would have to be a court case to determine whether or not I am allowed to licence my top level code under MIT instead of being forced to use GPL because a dependency is GPL? Earlier Martin Cooper raised the question of what does it mean to link in JavaScript. That wasn't just an idle question, because IIRC the GPL viralness kicks in when you link code together. In JavaScript there's no linking involved (because it's not compiled) and with Node.js modules there's no subclassing ... etc .. s... The problem with that statement - that there is no linking - is that you're speaking as a technologist, not as a lawyer. It is not at all clear from a legal perspective that there is no linking involved, and it won't be until, as Isaac pointed out, this lands up in the courts and a legal precedent is set. Many consumers of open source, individual and corporate, are not willing to be guinea pigs in that legal experiment, when it eventually happens, so they elect to avoid using ?GPL licensed software and avoid the risk. And they also avoid ?GPL when they license their own code. Are you sure it's a good idea to check dependencies into your own source tree? That doesn't sound like a good practice to me. Why not let npm take care of the dependencies? I would think that when you npm install a package, and npm installs all the dependencies, that the binding is loose enough to not trigger any actual concern. Again, though, you're speaking as a technologist. You shouldn't assume that lawyers would come to the same conclusions. My suggestion is simple: Choose whatever license meets your needs, but make sure you actually understand your goals, and make sure you fully understand the license you choose. -- Martin Cooper But, yeah, okay, it's not terribly well a clear-cut thing. Ah.. maybe an analogy could be drawn from packaging policies in, say, the Debian/Ubuntu projects? + David Herron, nodejs.davidherron.com -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] preferred license for node modules?
On Fri, Dec 14, 2012 at 7:29 PM, David Herron da...@davidherron.com wrote: I'm curious about the preferred license for modules that are distributed through the npmjs.org repository In particular is there any legal barrier to using GPL in such modules? As far as I understand it, the legal barrier would be whether a module which uses a GPL'd module is derivative of that module. I don't think that it would be, but then the LGPL license does exist for a reason. The question of GPL / LGPL / AGPL licensing for JavaScript is a complicated one. So complicated, in fact, that many companies simply prohibit the use of ?GPL licensed JavaScript code (and other code), in order to avoid the legal risks. In terms of legal barriers, you can certainly specify the license on a package; but many people who do that, don't actually understand what it means when they do it. Take the regular GPL, for example. What does it mean to link in JavaScript? A legal definition of that would be at the heart of any question of violating the license, because linking is at the heart of the GPL. To a large extent, the choice of license comes down to the goals in providing an open source package. If the goal is widespread adoption, ease of adoption, ease of contribution, or the like, the permissive licenses like MIT or BSD are a great fit. Those are the prevalent licenses in the Node.js community, and I firmly believe that has been a significant factor in the broad adoption of Node.js and of the many available packages made available for it under the same licenses. On the other hand, if freedom in the sense of the GPL is more important to the author than how much adoption they get, they might choose to use one of the ?GPL licenses. One final point I'll add is that many people who choose a ?GPL license do so under the mistaken belief that it will lead to more contributions back and more control over the code they open source. They think that using a permissive license will cause everyone to go off and maintain their own fork instead of contributing back to the project. But in actual fact, it's much more common that people want to contribute back, and _don't_ want to have to keep maintaining their own version. And with a permissive license, they have more freedom to modify the code and provide back their changes to the original author, rather than get tangled up in complex license terms. Hope that helps. -- Martin Cooper + David Herron - nodejs.davidherron.com -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] preferred license for node modules?
On Fri, Dec 14, 2012 at 8:28 PM, David Herron da...@davidherron.com wrote: Okay, my early grok of the answers is that there isn't an actual legal hurdle .. someone else using the module won't be subject to the viral effect of the GPL in other words. I wouldn't be too sure of that, unless you can point to actual legal precedent. That's one of the problems; until the terms of the GPL are tested in court in a JavaScript case, to the point where someone can point to case law and demonstrate that, the viral nature can be argued amongst us non-lawyers, but we don't really *know*. Again, what is the legal definition of linking in JavaScript? It's more of a community dislike. Am I reading the reaction correctly? Which reminds me of a quip I read a long time ago, which went something like:- I want everyone else's code to be under the BSD license, but I want my code to be under the GPL .. Basically meaning the tendency is to want do as much as possible with other peoples code while putting as much protection around my code. Maybe there's a license I don't know about that's a good happy medium between the extremes of BSD and GPL? Well, first, you'll need to explain why you consider those extremes. :-) If you're looking for a license that is not either of those, what is it that you want to achieve with the license, and how do you anticipate enforcing your choice? -- Martin Cooper + David Herron -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] ReadableStream from Buffer
On Wed, Dec 12, 2012 at 5:36 PM, dhruvbird dhruvb...@gmail.com wrote: Hello, Is there a module that creates a ReadableStream given a Buffer, or something like if I write to the stream, it emits the 'data' event every time someone writes to it. This one might fit the bill: https://github.com/mjijackson/bufferedstream -- Martin Cooper I found 2 modules, both of which seem unrelated: https://github.com/dodo/node-bufferstream https://github.com/bnoordhuis/node-buffertools Regards, -Dhruv. -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Waiting for multiple runs of Mongoskin
On Sat, Dec 8, 2012 at 10:02 AM, Jimmy Haver mcha...@gmail.com wrote: Here is the none working format, this is in a function that should return results when db is finished. Since the code is async, you can't actually *return* when the results have been collected. You'll need to update your code such that it calls a callback when you have the results. See below. var results = []; dependencies.forEach(function(dependency) { db.collection('parts_relations').find(query).toArray(function(err, relations) { relations.forEach(function(relation) { results.push(relation); }); }); }); I have tried two things without success: (this returns before finishing) var results = []; var counter = 0; dependencies.forEach(function(dependency) { counter++; db.collection('parts_relations').find(query).toArray(function(err, relations) { relations.forEach(function(relation) { results.push(relation); }); if (counter = dependencies.length) { return results; Here, you are returning the results from the callback passed to toArray(), not the function you're thinking you're returning from, I think. However, if you modify your enclosing function to take in a callback, as mentioned above, then you can call that callback here, instead of trying to return. -- Martin Cooper } }); }); I also tried wrapping db.collection in a function and passing it to async.parallel without luck. Any suggestions? -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: Should stream.pipe forward errors?
On Wed, Nov 28, 2012 at 2:05 PM, Jeff Barczewski jeff.barczew...@gmail.comwrote: Agreed. Especially if the error happens after the initial connection (which is probably when most would occur), then it won't be caught by any try/catch so it would have to rely on domains. If you have setup an error handler then it is just nice to deal with it there in one spot. That depends on what you're going to do with it. As a simple example, if I create a read stream on a tarball, pipe it through Gunzip, and pipe that through Untar, I may well be interested in reporting to the user which one of those things messed up if something went wrong. What I *don't* want to have to do is muddle through inconsistently constructed Error objects to try to figure that out for myself, if there's only one place to put my error handler. In other words, I *like* the fact that the error handlers are interspersed within my pipe setup, because it gives me flexibility in both determining, and reporting, what went wrong. If I don't want to make use of that flexibility, then I can reuse the same handler, as in your example. But I have that choice. -- Martin Cooper -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Streams Pipes for non Buffer / String use cases?
On Fri, Nov 23, 2012 at 6:14 AM, Darach Ennis dar...@gmail.com wrote: Hi guys, Are there any plans to further generalize streams and pipes? Are you perhaps looking for something like this? https://github.com/dominictarr/event-stream -- Martin Cooper I would like to use them in process and with node cluster, but without having to serialise to/from Buffer or Strings. For example, node cluster with streams and pipes would enable continuous streaming map reduce. Is it just me who'd find this useful or would there be general need/interest for streams and pipes being further generalised? Cheers, Darach. -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: [EARLY ANN] V8 clone exposed to node.js
On Thu, Nov 22, 2012 at 4:56 AM, Alexey Kupershtokh alexey.kupersht...@gmail.com wrote: Also deep cloning can be done by shallow cloning + replacing values in-place. This will help to avoid hidden classes creation and is going to be way faster too. A fast deep clone seems like it would be useful. Even better would be if deep equal came with it. (There's a deep equal buried in assert, but not exposed other than as an assertion.) Note that the original frameworks you mentioned run in the browser as well as in Node, so people writing code to run in both environments would still use those, even if Node has a fast clone built in. -- Martin Cooper четверг, 22 ноября 2012 г., 18:05:18 UTC+7 пользователь Alexey Kupershtokh написал: I see that almost every framework (underscore, lodash, moo, etc) creates its own clone function. But v8 engine already has it. So I've created a module that exposes v8's clone function. Just as a proof of concept. It needs assertions and currently fails with a segmentation fault on inputs like null values. https://github.com/**AlexeyKupershtokh/node-v8-**clonehttps://github.com/AlexeyKupershtokh/node-v8-clone According to the benchmarks it's: 8x faster (50x on 1000-key obj) than this approach: var result = {}; for (i in obj) result[i] = obj[i]; 12x faster (450x on 1000-key object) than this approach: var result = {}; for (i in obj) if (obj.hasOwnProperty(i)) result[i] = obj[i]; So I wonder if the community needs this module. Also node's core developers are welcome to criticize. Is it ok to expose this function? What are possible drawbacks? Or maybe it's worth to include this into the node.js core? -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: find path of module require()ing
On Mon, Nov 12, 2012 at 3:22 AM, boden bodensem...@gmail.com wrote: doesn't *have* to, but does for ease of use -- it defaults some paths relative to the caller's (the module require()ing) module location... obviously there are other approaches such as forcing the require()er to pass in those paths rather than defaulting them. i'm not all that seasoned in the node space, but i haven't gotten a whiff of hell yet... anything in particular that drums up the smell of hell for you that I should be aware of? If you're making assumptions about your caller, you're likely asking for trouble, now or in the future. For an example, see: https://github.com/joyent/node/issues/4233#issuecomment-10046241 -- Martin Cooper On Monday, November 12, 2012 3:46:29 AM UTC-5, greelgorke wrote: guess there is no other way. but the whole task smells like hell to me. why does your module need to know who required it? Am Samstag, 10. November 2012 15:02:50 UTC+1 schrieb boden: hi all, trying to find the proper way to determine the path of the module requiring my module given the following requirements: * must be strict mode complaint * cannot depend on node arguments (i.e. process.argv) * must work when being required from different modules in the same execution (i.e. my module is already cached) i ended up patching Module._load() to capture the request and then wrapping it in a closure like shown here: https://github.com/** bodenr/expose/blob/master/**index.jshttps://github.com/bodenr/expose/blob/master/index.js however this doesn't feel right -- i must be missing something. thx in advanced -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: require
On Thu, Nov 15, 2012 at 6:20 AM, Angelo Chen angelochen...@gmail.comwrote: Hi, Thanks for the direction, but I found it at beg of module.js, it has a line: var NativeModule = require('native_module'); is the require here refers to: Module.prototype.require = function(path) { return Module._load(path, this); }; ? I'm afraid you're going to have to keep reading. :-) You'll discover that ultimately 'require' is a function that is unique for each module, and is passed in to the wrapper that executes the module. See: https://github.com/joyent/node/blob/master/lib/module.js#L377 https://github.com/joyent/node/blob/master/src/node.js#L726 https://github.com/joyent/node/blob/master/lib/module.js#L453 NativeModule.require() is used to get at those modules that are baked into Node itself; a regular 'require' is used for everything else. -- Martin Cooper On Nov 15, 8:21 pm, Вадим Барышев vadimbarys...@gmail.com wrote: This is node.js function. You can start herehttps://github.com/joyent/node/blob/master/lib/module.js#L361 четверг, 15 ноября 2012 г., 16:17:32 UTC+4 пользователь Angelo Chen написал: Hi, var fs = require('fs'); I'd like to understand this a little more, require is part of v8 JS? or nodejs function? if yes, where can I find it in Nodejs's source code? thanks, Angelo -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Error: spawn EMFILE
On Thu, Nov 15, 2012 at 8:24 AM, James Weston jawon...@gmail.com wrote: I was running into the same problem and wrote a package to queue up the spawn requests. It can be found at https://github.com/jaw187/queueit The 'async' package already has: https://github.com/caolan/async#queue -- Martin Cooper On Friday, February 10, 2012 12:25:00 PM UTC-5, JoshK wrote: Actually I found out that ulimit is only a modification for the shell session. If I run `ulimit -n 1` in the same session as the node process it works (or appears to). Regards, –Josh __**__ Joshua Kehn | @joshkehn http://joshuakehn.com On Feb 10, 2012, at 12:21 PM, Ben Noordhuis wrote: On Fri, Feb 10, 2012 at 18:15, Joshua Kehn josh...@gmail.com wrote: And even if I assume it *is* setting something, ulimit -n 1 doesn't change the error I'm seeing. Let me guess, you're working on a Mac? You need to log in again after changing the ulimit on OS X, don't ask me why. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/**node/wiki/Mailing-List-** Posting-Guidelineshttps://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 nod...@googlegroups.com To unsubscribe from this group, send email to nodejs+un...@**googlegroups.com For more options, visit this group at http://groups.google.com/**group/nodejs?hl=en?hl=enhttp://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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Please provide feedback as to best practice for reading files from a specific directory
You were doing fine right up until that assuming. :-) At that point, you've kicked off the process of reading in the template files, but that has not yet completed. It's only complete when the last (in time, but not necessarily in sequence) fs.readFile() call has called its callback. There are lots of options for managing this, but if it was my code, I'd be using async.forEach(), instead of the raw JavaScript forEach: https://github.com/caolan/async#forEach Something like this, assuming 'files' came out of fs.readdir(): async.forEach(files, function (file, callback) { // load one template file here // call callback(err) when fs.readFile() calls you back }, function (err) { // now you can call templatesLoaded, since they're all done loading (or something bad happened) }); I should point out here that since this is code that's running at application startup, it's not strictly necessary for you to do all this with async code. Since you haven't started handling requests yet, you could just use synchronous calls instead if you wanted to. By the way, don't confuse file system paths with URL paths. I see you've named a variable 'url' but used it for a file system path and not a URL. Keep those separate so you don't trip yourself up later. -- Martin Cooper On Mon, Nov 12, 2012 at 4:07 AM, kinghokum butt...@gmail.com wrote: Hi all, Just wondering if this is any better. I've tried to implement what Martin has suggested best to my knowledge. Any further feedback is appreciated. Thanks // Set up the app var express = require('express') , app = express() , fs = require('fs') , path = require('path'); // Define the path to the templates and set it to 'dir' var url = path.resolve('./templates/'); // Get all files from the template dir and send them to readFile() to be read var readDir = function(){ fs.readdir(url, function (err,files){ if (err) { console.log(err.message); return; } // for each of the files... files.forEach(function (file) { var filePath = path.join(url, file); // Get a files stats fs.stat(filePath, function (err, stat) { // If the file is not a directory, read it if (stat stat.isFile()) { fs.readFile(filePath, 'utf8', function (err,data) { if (err) { console.log(err.message); return; } console.log('read this ' + data); }); } }); }); // Assuming the readdir() is complete, lets call templatesLoaded(); templatesLoaded(err); }); }; // when readdir() is complete, call templatesLoaded() var templatesLoaded = function (err) { // Check err and bail out if something bad happened. if (err) { console.log(err.message); return; } app.listen(3001); console.log('Listening on port 3000'); }; // Default route app.get('/', function(req, res){ res.send('Styleguide'); }); // Call readDir(); readDir(); On Monday, November 12, 2012 8:23:16 AM UTC+11, kinghokum wrote: Thanks Martin, I appreciate it. I'll look into how to implement your suggestions. On Monday, November 12, 2012 5:42:39 AM UTC+11, Martin Cooper wrote: A few things: * You're loading all of the files each time you process a request. Assuming you want to load them on startup only, and make sure they're loaded before you start handling requests, you should do the loading in your mainline code, before you call listen. Something like: loadTemplates(function (err) { // Check err and bail out if something bad happened. // App Listen app.listen(3000); console.log('Listening on port 3000'); }); * The fs.readdir() and fs.readFile() functions are async. You should never be throwing from their callbacks, since you won't be around (in the call stack) to catch them. You need to be calling your own callback with any errors instead. * Since your readDir() function will complete asynchronously, its work is not yet complete when you call res.send(). (Addressing the first point above will address this, though.) * You should use the 'path' module to resolve the paths to your directories and files, instead of gluing them together as strings. Hope that helps. -- Martin Cooper On Fri, Nov 9, 2012 at 9:56 PM, Chris Buttery but...@gmail.com wrote: Hi Everyone, I'm a long time reader, first time poster. I'm wondering if you guys could provide some feedback on this code I've written, for my first attempt at an app. My intention is to read the contents of files from a specific directory. So when you load this 'app' it iterates all the files in 'templates' and sends them to my
Re: [nodejs] Please provide feedback as to best practice for reading files from a specific directory
A few things: * You're loading all of the files each time you process a request. Assuming you want to load them on startup only, and make sure they're loaded before you start handling requests, you should do the loading in your mainline code, before you call listen. Something like: loadTemplates(function (err) { // Check err and bail out if something bad happened. // App Listen app.listen(3000); console.log('Listening on port 3000'); }); * The fs.readdir() and fs.readFile() functions are async. You should never be throwing from their callbacks, since you won't be around (in the call stack) to catch them. You need to be calling your own callback with any errors instead. * Since your readDir() function will complete asynchronously, its work is not yet complete when you call res.send(). (Addressing the first point above will address this, though.) * You should use the 'path' module to resolve the paths to your directories and files, instead of gluing them together as strings. Hope that helps. -- Martin Cooper On Fri, Nov 9, 2012 at 9:56 PM, Chris Buttery butt...@gmail.com wrote: Hi Everyone, I'm a long time reader, first time poster. I'm wondering if you guys could provide some feedback on this code I've written, for my first attempt at an app. My intention is to read the contents of files from a specific directory. So when you load this 'app' it iterates all the files in 'templates' and sends them to my readFile() function to be read. This script works as I expected, but I'd like to see how some of your more experienced developers would have attempted this. Thanks Chris // Set up the app var express = require('express') , app = express() , fs = require('fs'); // Define the path to the templates and set it to 'dir' app.set('templates', __dirname + '/templates'); var dir = app.get('templates'); // Get all files from the template dir and // send em to readFile() to be read var readDir = function(){ fs.readdir(dir, function (err,files){ if(err) throw err; files.forEach(function(file) { readFile(file); }); }); }; // Read the files var readFile = function (file) { fs.readFile(dir+'/'+file, 'utf8', function (err,data) { if(err) throw err; console.log(read this + data); }); }; // Default route app.get('/', function(req, res){ readDir(); res.send('Styleguide'); }); // App Listen app.listen(3000); console.log('Listening on port 3000'); -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] fs.read'ing a stream.fd
You're mixing up two different approaches to reading the file. When you use fs.createReadStream(), the file will be read automatically as a stream, and you'll start seeing 'data' events with chunks of data as they're read. With this model, you don't do the reading, the stream does it for you. On the other hand, if you want to read the file manually, you'll need to open it using fs.open() first. Then you can use fs.read() calls to get the data. I'd recommend the stream approach, unless there's some reason you can't do that. -- Martin Cooper On Sat, Nov 10, 2012 at 12:00 PM, Volkan Yazıcı volkan.yaz...@gmail.comwrote: Hi! I am having trouble while *fs.read*'ing from fd of a stream. For instance, below script produces no outputs. What am I missing? var fs = require(fs), s = fs.createReadStream(__filename), l = 8192, b = new Buffer(l); s.on(open, function() { fs.read(s.fd, b, 0, l, function (err, nbytes) { console.log( err: + err + , + nbytes: + nbytes + , + buf: + b.toString(0, nbytes)); });}); -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Socket.io, answer WELL, don't lock.
On Wed, Oct 31, 2012 at 7:31 AM, Andreas Backx dree...@gmail.com wrote: I'm sorry for the attitude, but I didn't even know what a mailing list is. I found it through Google after about 40min On the Node.js home page, the Community link says Mailing lists, blogs, and more. Clicking on it takes you to a page with a section named Mailing List. That said, the original error log you posted contains this: ERR! Failed at the ws@0.4.22 install script. ERR! This is most likely a problem with the ws package, ERR! not with npm itself. ERR! Tell the author that this fails on your system: ERR! node install.js ERR! You can get their info via: ERR! npm owner ls ws which should have sent you to the 'ws' issue tracker right away. -- Martin Cooper and I also didn't know much about the path variable. Op woensdag 31 oktober 2012 15:22:29 UTC+1 schreef Dan Milon het volgende: You didnt post any issues, but posted a plz help me question on node's issue tracker. Issues are bugs/unexpected behaviour/new features/proposals, not questions. That's why there's this mailing list for questions/discussions, but this attitude wont get you a long way. danmilon. On 10/31/2012 04:11 PM, Andreas Backx wrote: I have been posting 2 issues on the nodejs GitHub page and both of them people reply to like do this, do this without explanation and lock the thread. Really? https://github.com/joyent/node/issues/4222 Answer the question and don't be like oh no this doesn't belong here or whatever, I try Google and every other single coding website to solve the issue, none of them help. -- 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 nod...@googlegroups.com To unsubscribe from this group, send email to nodejs+un...@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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] npm and NodeJS versions: got rid of package hell, now have node version hell?
That is until I hit some packages that just *must* use a different (usually older) version of NodeJS than the one which I'm using. In many cases, the package author just needs a nudge to get the compatibility spec updated. That said, note that the newest versions of npm treat an engine mismatch as a warning rather than an error, so you may be able to ignore it, assuming the package actually works. If you've tried that, and it's not happening (and you need to use an old version of npm for some reason), it's possible that the package is unmaintained or obsolete. In that case, you don't want to be using it anyway. If the package really is tied to a specific version of Node, that could be because it's no longer needed in later versions, or it's something that will take work to make compatible with newer versions of Node. In this case, you're either stuck, or in for some additional work, if you want to take it on yourself. That said, if you feel you really need to build a check into your app, you can do that very simply, unless I'm missing what you're trying to do: if (!require('semver').satisfies(process.version, MY_VER_RANGE)) { console.error(Incompatible Node.js version); process.exit(1); } -- Martin Cooper On Sun, Oct 21, 2012 at 12:16 PM, ack a.c.kal...@gmail.com wrote: First off, I'm new to Node.js and npm, but I like it quite a lot already. I installed and tinkered with quite a few packages and tools, and I must say, I'm quite impressed with what npm can pull off in terms of package management. Local package versions per project, user-global packages by doing `npm set prefix $HOME/.local/` and then doing `npm install package -g`, system global installs with `sudo npm install package -g`, all really nice and dandy. No mucking about with Python's `virtualenv`, renaming script host executables, patching paths in scripts, none of that stuff. That is until I hit some packages that just *must* use a different (usually older) version of NodeJS than the one which I'm using. 'n', 'nvm', 'nave' all come to assist, but to me they just seem to introduce YAVE (Yet Another VirtualEnv), with all the troubles (activating, deactivating, keeping track of which shell you're in, etc.) I'm wondering if the following scheme could help out in all this Have an app.js check the version of Node.js it is running in, and have itself restarted using the correct version if mismatch, or bomb out if no match at all: --[app.js]-- // Yes, I know that the 'node' package was used for installing Node.js itself // but it's deprecated now, anyway. require(node).version(=0.6, 0.8); // Yes, ignore the return value, we want the side-effects :-) // Do some cool stuff --[end of app.js]-- This would introduce a Perl-like syntax for version requirement. It would be even better if node itself or a wrapper could read version info straight from the app's package.json, then the check could be done implicitly on startup. I'm not yet really clear yet on how to implement the node package, but as I see it, it could just export the function 'version', which checks its only argument against the running node version, and if it doesn't match, spawns the right version of node, passing it the original app script name and commandline parameters. The parent node process can then just exit. Maybe even better is to pass the required node version back to a node wrapper script, and have that exec() the right node version with the original app.js. An interesting bonus would be that scripts will not accidentally be executed using Windows Script Host or any other non-Node.js script hosts, as long as they don't have a 'node' package or script in their search path. Any ideas on whether my idea is feasible at all? Anyone interested in (helping me with) implementing this? Kind regards, Alain -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Stop readline Writing Input to the Output
On Sun, Oct 14, 2012 at 12:18 PM, Volkan Yazıcı volkan.yaz...@gmail.com wrote: Yeah, I can make it point to /dev/null, but isn't there a better way of doing this? The output stream is required with 'readline', so you have to give it something. Depending on your use case, you can probably do what you want by using 'read' instead: https://github.com/isaacs/read -- Martin Cooper On Sunday, October 14, 2012 10:16:11 PM UTC+3, Alex Kocharin wrote: Replace process.stdout with a custom stream? -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Why there's no callback for opening stream?
On Sun, Oct 7, 2012 at 5:54 PM, Alexey Petrushin alexey.petrus...@gmail.com wrote: Tried to copy files using streams and pipe and got funny results. Let's consider following code (highlighted version https://gist.github.com/3850106 ): var copy = function(from, to, cb){ var fromStream = fs.createReadStream(from) fromStream.on('error', cb) var toStream = fs.createWriteStream(to) toStream.on('error', cb) fromStream.on('end', cb) } copy('non existing file a', 'non existing dir/file b', function(err){ console.log(err) }) There are errors in both streams (non existing source file and no parent directory for destination file) - so, both of them will emit 'error' event, and the callback will be called twice with both errors. // Error will be reported twice: // // { [Error: ENOENT, open 'non existing file a'] errno: 34, //code: 'ENOENT', path: 'non existing file a' } // { [Error: ENOENT, open 'non existing dir/file b'] errno: 34, //code: 'ENOENT', path: 'non existing dir/file b' } I found the solution by looking at the source of `util.pump` - it does it by wrapping callback into function that calls callback only once - for the fist error and ignoring others. But maybe it would be nice to have a callback for `createXxxStream` or something like 'ready' or 'success' events to know that it created successfully? I'm missing how this would help. If there was such an event, either stream could still emit an error before it (e.g. open error) or after it (e.g. read or write error), so you'll still need to attach the two error handlers, and you'll still need to handle the possibility of multiple notifications. What would be the benefit of having another event to listen for? -- Martin Cooper -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: Request for feedback- Yet another client-side module loader (it's different, I promise:))
GPLv3? Really? That seems like an odd choice in Node's predominantly MIT / BSD world, especially if you're looking for adoption. -- Martin Cooper On Fri, Oct 5, 2012 at 10:24 AM, Saleem Abdul Hamid meel...@gmail.com wrote: More updates :) I added a plugin api, and wrote two example plugins. Now you can use those plugins to include coffee-script and jade files. So you can include jade template views in your bundles and then render the pre-compiled function client-side as much as you want. There's a demonstration screencast of both plugins in the readme. I also forgot to mention that I added a lot of caching to the server and cleaned up some performance bottlenecks in the proof-of-concept version, so it now serves files faster than connect (even without taking into account the optimizability advantages). The crude, but sufficient ;), benchmarks are available in the readme. https://github.com/meelash/Mundlejs On Saturday, March 24, 2012 5:04:52 PM UTC-7, Saleem Abdul Hamid wrote: tl;dr - Client-side require with a server-side component that caches dependencies, bundles them, and caches the bundles. Need feedback on the concept, syntax. Need suggestions/contributions on implementation. Although, this works for me, it is almost just a proof-of-concept, needs work. As part of a project I'm working on, I spent a few hours writing a little client-side module loader with a server-side component enabling what I think is a pretty neat meaning to CommonJS module syntax. This morning I pulled it out of the rest of my project and attempted to package it in a useful way for others to use. The basic idea is this- in your client-side code, you can use require in either a synchronous or asynchronous fashion- module1 = require('some/path.js'); require('some/other/path.js', function(err,result){module2 = result;}); An asynchronous require makes a call to the server component to get the file in question, but before returning the file, the server parses it, finds all the synchronous require calls, loads those files as well and returning the whole thing as a package. That way, when the original file that was asynchronously loaded is executed and comes to one of those synchronous require calls, that file is already there, and the require is actually synchronous. At this point, maybe this screencast demo will help to clarify how it works: http://screencast.com/t/nOU53BRYUAX Put another way: If I async require fileA, and fileA has synchronous dependencies on fileB, and fileC, and an asynchronous dependency on fileD, the server- side component will return (in a single bundle) and keep in memory fileA, fileB, and fileC, not fileD, and it will execute fileA. The client-side also separates fetching the files and eval'ing them (the method of getting files is xhr+eval). So, let's say fileA has require('fileB'); that executes when the file is parsed and executed on the client, but require('fileC') is inside a function somewhere. Then fileA will first be eval'ed, then fileB when it comes across that, and the text of fileC will just be in memory, not eval'ed until that function is called or some other require to it is called by any other part of the program. Another example- fileA has dependencies fileB, fileC, fileD, fileE, fileF fileG has dependencies fileC, fileE, fileH When I call require('fileA', function(err,result){return 'yay';});, the module loader will load fileA, fileB, fileC, fileD, fileE, and fileF all in a single bundle. If I, after that, call require('fileG', function(err,result){return 'yay';});, the module loader will only load fileG and fileH! Hopefully, that's clear The advantages- Being aware of the difference in synchronous and asynchronous require in your client-side code make it extremely natural to break all your client-side code into small reusable chunks- there is no penalty and you don't have to optimize later by deciding what to package together and what to package separately. Handling dependencies becomes nothing. You don't have to think about it. The server can have a deployment mode, where it caches what the dependencies of a file are and doesn't ever need to parse that file again. In deployment mode, the server can also cache bundles of multiple files that are requested together, so when another client requests that same bundle, it is already in memory. To sum up: xhr+eval-when-necessary client-side module loader both synchronous-ish and asynchronous require in your client side-code --the synchronous require is actually a command to the server-side component to bundle server-side component --parses for dependencies and bundles them together --can cache dependency parsing results and whole bundles So- thoughts? Is this a horrible idea? Are there some gotchas that I'm missing? Specific advice needed- • How to package this in a way that it can be easily used in other projects? How can I make
Re: [nodejs] NPM without https-proxy
On Mon, Sep 17, 2012 at 12:29 AM, Malcolm Ryan malcolm.r...@gmail.com wrote: My local network has an http-proxy but no https-proxy. The npm tool seems to assume you either have neither or both. I can't find any way to set 'proxy' without setting 'https-proxy' to the same value. If I try setting https-proxy to it complains that it must be a full url. is there a way around this? Have you updated the registry URL to specify http instead of https? npm config set registry http://registry.npmjs.org/ -- Martin Cooper Malcolm -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
[nodejs] Creating zip files
Any good packages out there for creating zip files? I found adm-zip, but that seems to create invalid archives, is synchronous, and requires the entire archive contents to be buffered in memory. I also found zipstream, but it doesn't look like it supports directories, and it's not clear that it's being maintained. Anything else out there that I've missed? -- Martin Cooper -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Creating zip files
On Thu, Sep 6, 2012 at 4:37 PM, Scott González scott.gonza...@gmail.com wrote: We did a bunch of testing for jQuery UI and came to the same conclusion. However, we're successfully using a patched zipstream with success. Of course there is the concern of using something that is clearly not being maintained as the PR for this fix was sent 5 months ago and still hasn't landed. As far as I know we haven't run into any issues, but I can check with Rafael since he's the one working with it right now. The package seems small enough that it probably wouldn't be too hard to take over if the lack of maintenance continues. Thanks. With zipstream, do you know if there's a way to create directories, and thus nest files? I don't see any support, looking at both the API and the code, but I guess I could be missing it. That's crucial for us. As it turns out, we need to read zip files too, and I thought adm-zip was working for that, but I just discovered that there's a showstopper bug in the inflate code, so I'm stymied on that side too now. zipstream only creates but doesn't read. On Thu, Sep 6, 2012 at 4:34 PM, José F. Romaniello jfromanie...@gmail.com wrote: would a tgz work for you? No, unfortunately. That would simplify things, for sure. The consumer of these files needs them to be zips, though. -- Martin Cooper On Thu, Sep 6, 2012 at 7:24 PM, Martin Cooper mfncoo...@gmail.com wrote: Any good packages out there for creating zip files? I found adm-zip, but that seems to create invalid archives, is synchronous, and requires the entire archive contents to be buffered in memory. I also found zipstream, but it doesn't look like it supports directories, and it's not clear that it's being maintained. Anything else out there that I've missed? -- Martin Cooper -- 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+unsubscr...@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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Analyzing All Require Calls
On Tue, Aug 21, 2012 at 4:01 PM, Azer Koçulu a...@kodfabrik.com wrote: Hi All, Is there any library that can list all the require calls in a project? (Already checked out require-analyzer, it looks like a dependency-analyzer rather than require) Ideas? It sounds like you're probably looking for static analysis, but 'mockery' can help you with runtime analysis, if that would be helpful for you. It won't locate the source of the require() calls, but it will tell you what was require()d. https://github.com/mfncooper/mockery If you require('mockery'), enable() it, but don't register anything, by default you'll get a warning on the console for every module that's subsequently require()d. What it reports will depend on your code path, and it might miss conditional require() calls because of that, but otherwise it'll catch every module require()d. As a simple experiment, you can try this and see if the output might help you: node -pe require('mockery').enable();require('your-lib') (This is a long way from what 'mockery' was designed for, but may just help!) -- Martin Cooper Best, Azer -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: Choose an extension is suit for nodejs ?
On Sat, Aug 11, 2012 at 3:15 AM, bo b seaso...@gmail.com wrote: NO, .js IS refer to static brower javascript . if you choose .js as page extension it would be great problem ! It seems that perhaps you're trying to replicate a rather old web development model here. In general, people don't expose mappings from page extensions to implementation engines any more. Instead, probably the most common pattern is route mapping in the style of Express and others. You may want to take a look at that. -- Martin Cooper -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Counting on Object Insertion Order
On Thu, Aug 9, 2012 at 5:13 PM, Alan Gutierrez a...@prettyrobots.com wrote: Have you ever written Node.js code that counts on the implementation specific Object behavior that mantains the insertion order of properties? It could be useful in configuration, for example, to specify fallbacks if the first choice isn't available. var conf = { database: { pg: psql://localhost/database , mysql: mysql://localhost/database } }; I'm probably missing something in what you're trying to achieve, but at least in this case, why not just use an array? var conf = { database: [ { id: pg, url: psql://localhost/database }, { id: mysql, url: mysql://localhost/database } ] }; -- Martin Cooper for (var type in conf.database) { try { useDatabase(require(type), conf.database[type]); } catch (e) { if (e.code != 'MODULE_NOT_FOUND') throw e; } } Great idea or *Greatest* idea? Possibly related: http://code.google.com/p/v8/issues/detail?id=164 -- Alan Gutierrez - http://twitter.com/bigeasy - http://github.com/bigeasy -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] How do you handle if/else with async inside
On Tue, Aug 7, 2012 at 9:35 AM, Dan Milon danmi...@gmail.com wrote: I am wondering which are the different patterns to handle cases like var results if (cond) { async1(function (err, res) { results = res }) } else { async2(function (err, res) { results = res }) } // here need to do something with results. The problem is obvious, but i cannot see any good way to overcome it. It'll depend on the individual case, but what I'd probably do in the specific case above is: var asyncFn = cond ? async1 : async2 var results asyncFn(function (err, res) { // here need to do something with results. }) -- Martin Cooper -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] CraftyJS, Node.js, SocketIO, V8 woes.
On Sat, Aug 4, 2012 at 11:40 AM, Brian Stahly brian.sta...@gmail.com wrote: I am trying to build a small, online card game with NodeJS. Having C# and javascript experience, I am having way more trouble than I expected. Using node-static, I set up an http server (server.js) that successfully serves client.html and any requested assets. I am starting to build the basics of the card game using the CraftyJS library in client.js (running on the client.html page). Using Socket.io, I can successfully send information from server.js to my client.js file. My next step was to generate an array of cards in server.js, splice one out randomly, and send it to client.js. My hope was: var deck = new Array(); deck.push(new Array(card1 info, more info)); deck.push(new Array(card 2 info, more info)); deck.push(new Array(card 3 info, more info)); function drawCard(){ return deck.splice(1,1); } I've spent the whole day reading, but I can't find a clear concise answer. Question 1: Why doesn't this work? It does. You created an array of arrays, then you used splice to get the middle one. In the repl, after setting up deck as above: deck [ [ 'card1 info', 'more info' ], [ 'card 2 info', 'more info' ], [ 'card 3 info', 'more info' ] ] deck.splice(1,1) [ [ 'card 2 info', 'more info' ] ] deck [ [ 'card1 info', 'more info' ], [ 'card 3 info', 'more info' ] ] Presumably this isn't what you expected, but you didn't say what you're looking for. The V8 compiler sees arrays as string values? This is not the javascript I know, is there a tutorial for this new way of dealing with arrays? After more reading, I got it working a this way: var deck = []; deck[0] = {info:test, moreInfo:test}; deck[1] = {info:test, moreInfo:test}; deck[2] = {info:test, moreInfo:test}; However: console.log(deck[0]) yields {info: 'test', moreInfo:'test'} console.log(deck.splice(0,1)) yields [{info: 'test', moreInfo:'test'}] Question 2: Why does splice return the square brackets, but calling the value directly does not? Because, as Karl mentioned, that's what splice does. :) It returns an array containing the elements that were spliced out of the original array. -- Martin Cooper Any answers or additional links are really appreciated. When I search for javascript help, I end up on HTML javascript pages, which obviously doesn't work as I expect. -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] how to do performance test of my POST service
On Fri, Aug 3, 2012 at 9:57 AM, josh macmillan.jos...@gmail.com wrote: I am trying to improve our existing file upload API (using sinatra) and see if Node can be a better alternative. i am using formidable to upload the file, than I stream(read) the file from disk into put request that saves it on our cloud servers, and finally, I save some meta data into a mysql. I make sure nothing is blocking and never load the file into memory, by using streaming. It seems to me that you'd be better off by streaming the file content directly from the incoming request to your cloud servers, instead of writing it to disk first and then immediately reading it back just so that you can stream it out again. I'm not sufficiently familiar with formidable to know how this capability is exposed in the API, but I see the low-level events in the parser, so I'm assuming there's a way. -- Martin Cooper please review my code and let me know what can I improve. also, i tested it with jmeter and here are the results: http://i.imgur.com/PSWjH.png?1http://i.imgur.com/PSWjH.png?1 I set it up with 20 concurrent connections for 1 minute. the problem with my test is it relies on the network connection and i don't really know how much time was spent on the server itself, how much memory, cpu and bandwidth was used? what is the speed of disk writes my server can handle? one idea i can think of is taking samples from top command on the server to figure out the memory and cpu. any tips/tools ideas or other things i should do? here is most of the code (with syntax highlight) and I also pasted it here: // server.js process.env.TMP = '/tmp/upload'; // core modules var http = require('http'); var util = require('util'); // non-core packages var formidable = require('formidable'); // easy handling of file uploads var mysql = require('mysql'); // my modules var saveMeta = require('./saveMeta.js'); // save name in mysql var saveFile = require('./saveFile.js'); // save file on my private cloud var connection = mysql.createConnection({ host : 'localhost', database : 'test', user : '', password : '', }); connection.connect(); http.createServer(function(req, res) { // curl -F myupload=@/pic.JPG 0.0.0.0:3001/api -v if (req.url == '/api' req.method.toLowerCase() == 'post') { // parse a file upload var form = new formidable.IncomingForm(); form.parse(req, function(err, fields, files) { res.writeHead(200); res.end(); }); form.on('file', function(name, file) { //save file in private cloud and save meta info in mysql saveFile(connection, file.name, file.path, saveMeta); }); return; } }).listen(3001); // - // saveFile.js module.exports = saveFile; var fs = require('fs'); var request = require('request'); // get file size and send to my cloud // // arguments: // connection - mysql connection // name - original file name // path - path on temp directory // saveMeta - callback for saving into mysql function saveFile(connection, name, path, saveMeta) { //adding a random number to file name. my cloud require unique names var rand = Math.floor(Math.random()*1).toString(); var url = 'http://my-private-cloud.com:5000/test-' + rand; function getFileSize(cb) { fs.stat(path, function(err, stats) { if(err) { console.log('error while reading the file:' + path, err); } else { if(cb) { cb(stats.size); } } }); }; // stream(read) the file from hardrive into put request that saves it on our cloud // // curl -sSf -T file1 http://my-private-cloud.com:5000/test // 200 - file was saved // anything else - file was not saved function sendFileToCloud(fileSize) { var file = fs.createReadStream(path) .pipe(request.put({url: url, headers:{'Content-Length': fileSize}}, function(err, res, body){ if(err) { console.log('error in PUT request to my cloud:', err); } else { // console.log('status from cloud:', res.statusCode); // console.log('file url:', url); if(res.statusCode === 200) { saveMeta(connection, name, path, url) } } })); file.on('data', function(chunk) { }) file.on('end', function() { }); file.on('error', function(e) { console.log('error:', e); }); }; getFileSize(sendFileToCloud); }; -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group
Re: [nodejs] Any library for getting NPM version from a module?
On Sun, Jul 29, 2012 at 11:40 AM, Azer Koçulu a...@kodfabrik.com wrote: Hi all, I'm looking for a library to print out the current version of my application You can just load your package.json using 'require' and get it from there: var pkg = require(./package.json); console.log('v' + pkg.version); -- Martin Cooper , like following; var currentVersion = require('current-version'); currentVersion(function(error, v){ console.log( 'v'+ v); }); Azer -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] sending a file using HTTP PUT
On Mon, Jul 23, 2012 at 7:53 PM, josh macmillan.jos...@gmail.com wrote: I try to make an HTTP PUT to an API. this endpoint allow sending a file and it saves it somewhere for later retrieval. If you want to simply upload a file, you don't want to be making a multipart request, which is what your Node code is doing. Instead, if you have a small amount of data, just provide that as 'body' (not inside 'multipart') in the request options. Better, though, is to stream the body data, as in one of the earlier examples in the request library readme. -- Martin Cooper Here is the way I do it (successfully) with curl: curl -sSf -T file1 http://api.my-server/file1 (PUT)andcurl -O -L http://api.my-server/file1 (GET) Here is a verbose PUT: (the unique name of my file will be test-file-7) curl -sSf -T file1 http://api.my-server.com:3000/test.bla/test-file-7 -v PUT /test.bla/test-file-7 HTTP/1.1 User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5 Host: api.my-server.com:3000 Accept: */* Content-Length: 12 Expect: 100-continue HTTP/1.1 100 Continue HTTP/1.1 200 OK Server: nginx/0.6.34 Date: Tue, 24 Jul 2012 02:10:18 GMT Content-Type: text/html Transfer-Encoding: chunked Connection: close Vary: Accept-Encoding Status: 200 OK * Closing connection #0 here is my node code that is trying to imitate the curl: module.exports = saveFile; var request = require('request'); // Mikeal's request package var rand = Math.floor(Math.random()*1).toString(); // curl -sSf -T file1 url/file-name function saveFile() { request({ method: 'PUT', uri: 'http://api.my-server.com:3000/file-' + rand, multipart: [ { 'content-type': 'application/json', body: JSON.stringify({ foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }} }) }, { body: 'I am an attachment' } ] } , function (error, response, body) { if(response.statusCode == 200){ console.log('ok); } else { console.log('error: '+ response.statusCode) console.log(body) } }); }; the difference between this code and the curl version is i am not loading a file from the file system in the node version. if this is the issue, can anyone guide me about doing it? i probably need to change the content type and might not need the multipart? i am not sure. here is the output i see in the terminal: // boundary D0F5DF48-E3F9-4C8B-93F2-2A7EFA47F7C4 // ok // when i retrieve the file from the server using curl -O -L http://api.my-server/file1 // i see: cat file1 = --D0F5DF48-E3F9-4C8B-93F2-2A7EFA47F7C4 content-type: application/json {foo:bar,_attachments:{message.txt:{follows:true,length:18,content_type:text/plain}}} --D0F5DF48-E3F9-4C8B-93F2-2A7EFA47F7C4 I am an attachment any idea why do i see so many lines instead of only the last one? is it the multipart or maybe the content-type? Also, I can talk to the guy that created the API i am using. i am just not sure what questions should I ask him. Also, any insight about mutiparts, mime-types and encoding would be appreciated. this stuff is confusing! Thanks! -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Best practices for sharing code and data between the server and client
On Wed, May 30, 2012 at 4:58 AM, Amjad isst...@gmail.com wrote: Hello everybody! I'm new to the great world of Node.js and have been playing around with different modules and frameworks. However, there seems a lot of methods for sharing server code with the client, and there are no default way for doing that. That's in part because it rather depends on what you're trying to do. For example, you might be: * trying to take existing code written for Node and run it in the browser * trying to take existing code written for the browser and run it in Node * trying to write a new codebase that will run in both places As has been mentioned, browserify is probably the best solution for the first of these. I think it's safe to say that it garners the most attention, in part because it's good at what it does. For the last case, you might want to take a look at YUI, which provides the abstractions to let you write your code once and run it in both places. Yahoo! has built Mojito on top of YUI and is using that to create multi-device apps that transparently share code between client and server. (BTW, you'll likely find that YUI is much more lightweight and modular than you think.) -- Martin Cooper I have come across many ideas: express-expose: this is a nice replacement for parsing JSON objects rendered by the the server. https://github.com/visionmedia/express-expose This article exposes a hack to share backbone models on the Node server, and they are trying to neat their hack with their Capsule and Thoonk frameworks: http://andyet.net/blog/2011/feb/15/re-using-backbonejs-models-on-the-server-with-node/ Syncrhonizing Backbone model using socket.io https://github.com/scttnlsn/backbone.io DNode and RPC as a method to use server methods on the client and vice versa https://github.com/substack/dnode I know I've mixed a lot of topics, I thought sharing my confusion would help to get more clarification, especially that there are a lot of production projects based on Node, andI think that the community certainly have reached a good collection of concepts and tools for sharing code between the server and client. I would be very grateful for sharing your thoughts about that. Best regards, Amjad -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] NPM can't install appjs. Error: Cannot find module 'graceful-fs'
On Wed, May 30, 2012 at 11:19 AM, Zephlon Arphanosh zephlon...@gmail.com wrote: I installed node.js and npm already, but when I try to install appjs I get this error: That looks to me like npm hasn't been installed successfully, since the error is coming from npm itself trying to load graceful-fs, not from any install targets. How did you install node and npm, and what versions do you have? Can you run any npm commands (e.g. npm -v or npm view ini) successfully? -- Martin Cooper zephlon@zephlon-T5254:~$ npm install appjs node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: Cannot find module 'graceful-fs' at Function._resolveFilename (module.js:334:11) at Function._load (module.js:279:25) at Module.require (module.js:357:17) at require (module.js:368:17) at Object.anonymous (/usr/share/npm/lib/utils/ini.js:32:10) at Module._compile (module.js:432:26) at Object..js (module.js:450:10) at Module.load (module.js:351:31) at Function._load (module.js:310:12) at Module.require (module.js:357:17) I get similar errors on any attempt to install graceful-fs. I am using Ubuntu 12.04 LTS. Here's the link to the appjs website: http://appjs.org/ -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Get latest version
On Mon, May 28, 2012 at 12:22 PM, Alan Hoffmeister alanhoffmeis...@gmail.com wrote: Hello there! Is there a clean way for getting the last stable version of Node.js? I would really like to GET http://nodejs.org/versions and retrieve a list of versions like: { latest-stable : 0.6.18, latest-unstable : 0.7.9, versions : [ 0.7.9, 0.7.8, etc... ] } The best way I have found so far is $('.version').text() at http://nodejs.org DOM's, but that's ugly as hell :P You can get a list of tags using the Github API: http://github.com/api/v2/json/repos/show/joyent/node/tags That doesn't include the specification of which version is the latest, but deriving that from the keys should be pretty straightforward. -- Martin Cooper -- Att, Alan Hoffmeister -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] hamljs issues with node 0.6.17
On Fri, May 11, 2012 at 8:30 PM, kowsik kow...@gmail.com wrote: npm version is 1.1.21. Did an 'npm install hamljs' and require('hamljs') gives me this: Error: Cannot find module 'hamljs' at Function._resolveFilename (module.js:332:11) at Function._load (module.js:279:25) at Module.require (module.js:354:17) at require (module.js:370:17) at repl:1:2 at REPLServer.eval (repl.js:80:21) at Interface.anonymous (repl.js:182:12) at Interface.emit (events.js:67:17) at Interface._onLine (readline.js:162:10) at Interface._line (readline.js:426:8) Any ideas? I see a bunch of pull requests in various states but nothing that points to me in the right direction. When I install it, I see this on the console: npm WARN excluding symbolic link index.js - lib/haml.js After manually recreating index.js as a symlink, it works. Alternatively, requiring the target of the symlink also works, as in: var haml = require('hamljs/lib/haml.js'); -- Martin Cooper Thanks, K. --- http://blitz.io @k0ws1k -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: mocking across tests
Unfortunately, there's actually a bug in mockery.js which prevents the node module cache from being cleared. The bug has been fixed in Mockery 1.1.2, now available via npm. The cause was a change in the Node module loader starting in Node v0.6.10. The latest Mockery now works with both older and newer versions of Node. -- Martin Cooper On Mon, Mar 12, 2012 at 12:12 AM, Aneil Mallavarapu an...@blipboard.com wrote: Hi Bryan - The way mockery suggests you handle this issue is by calling mockery.registerAllowable(modulePath,true); Where the second argument is unhook, a signal which tells mockery.deregisterAll() to remove the module from the node module cache. Unfortunately, there's actually a bug in mockery.js which prevents the node module cache from being cleared. I've committed a fix to my fork: https://github.com/amallavarapu/mockery Details of the bug are in this pull request: https://github.com/mfncooper/mockery/pull/6 I've also added functions to ensure ALL modules are cleared from the module cache after tests are run in this commit. Just call: mockery.registerAllAllowableStart(true) In the before() block before you load the modules required for the test. Then call: mockery.registerAllAllowableEnd(); mockery.deregisterAll(); In the after() block. This removes from the cache all the modules loaded between the start and end calls. Aneil On Monday, December 19, 2011 6:33:55 PM UTC-8, Bryan Donovan wrote: I'm currently using Mocha with Mockery for unit testing. I can't figure out a good way to deal with this situation: Test A requires a real module. Test B and mocks that same module. Running Test A in isolation passes. Running Test B in isolation passes. Running both at once: Test B fails every time. In the third scenario, Test B fails because the real module has already been loaded (even if Test A hasn't run yet). This occurred with Gently as well, and with nodeunit instead of Mocha, so I don't think it's an issue with Mockery or Mocha. But I'm still guessing there's an easy solution to what is a trivial problem in other languages, and I'm just missing it. I'm fine with using a different mocking library if that's the solution, as long as it's simple to use and doesn't require me to pollute source files with weird statements like Gently does. I have a repeatable set of source code and tests here: https://github.com/BryanDonovan/nodejs-mock-test Any advice would be greatly appreciated. Thanks, Bryan -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] travis-ci with node
On Tue, Apr 3, 2012 at 6:24 AM, john.tiger john.tigernas...@gmail.com wrote: on the site it says node (I guess Joyent) is using travis-ci is there any write up on this ? which testing package is being used ? Here's Node's config file for Travis: https://github.com/joyent/node/blob/master/.travis.yml and here's the Makefile target it looks like that's firing off: https://github.com/joyent/node/blob/master/Makefile#L51 -- Martin Cooper (travis site says it can use vovs or espresso) experiences ? -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Getting started with testing and using stubs
On Fri, Mar 23, 2012 at 3:35 PM, Martin Lundberg martin.lundb...@gmail.com wrote: Hi! I'm having problems getting up and running with testing my node.js code. There are many ways to do this, depending, to some extent, on how you choose to write your tests. One option would be to use Mockery with your choice of unit testing framework: https://github.com/mfncooper/mockery Let's assume that your auth.js module looks more or less like this: var users = require(./users.js); exports.authenticate = function(email, password, callback) { // ... } Then in your unit test module (say auth.test.js), you might create a super-simple mock / stub and use it something like this. (The actual code will depend on which unit test framework you're using.) var usersMock = { get: function (userObj, cb) { // Do whatever you need in your mock 'get' } }; // Then in your test case code: setup: function () { mockery.enable(); mockery.registerMock(./users.js, usersMock); } teardown: function () { mockery.deregisterAll(); mockery.disable(); } testAuthGet: function () { var auth = require(path/to/auth.js); // whatever other prep work you need auth.authenticate(email, pwd, function (err, user) { // whatever assertions you need to verify the results }); } This works because Mockery will load your mock / stub when auth.js tries to require() the users.js module, so when your test calls authenticate(), that invocation will be using your mock users.get() instead of the real one. Hope that helps. -- Martin Cooper I've got a file called auth.js with a function that looks like: authenticate(email, password, callback). The authenticate function tries to fetch a user with the given e-mail using a collaborator UserRepository object. It runs a function like: user = users.get({ email: email }, function(user) { ... }) where users is the UserRepository object. If it gets a user and the password is correct it calls the callback function like: callback(null, user) but if it don't get a user or if the password is incorrect it calls the callback sending an error as the first parameter. When writing unit tests the authenticate method (and all the other functions in auth.js) I don't want to use the real UserRepository (which in turn uses a database library like node-mysql) object and a real database. I believe I should create a stub and define return values so I can see that authenticate returns correct values when it gets a user and when it don't. The problems is that I've read a lot of tutorials and articles about mocking and testing but I still don't understand how I should do this in a good way. I hope the text isn't too confusing. I would really appreciate some guiding in this area so I can get started testing my apps in a good way. Regards, Martin Lundberg -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] local npm mirror not behaving
On Tue, Mar 20, 2012 at 2:44 PM, Troy yortnos...@gmail.com wrote: snip I don't know why npm is dropping the /registry/_design/app/_rewrite/ from the path. Or what configuration I'm missing to fix this problem. If you haven't already, you might try adding a vhost config, as described under top-of-host urls here: https://github.com/isaacs/npmjs.org/ -- Martin Cooper Any help is appreciated. Thank You Troy Dawson -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] which one is correct ?
On Fri, Mar 9, 2012 at 2:30 AM, Angelo Chen angelochen...@gmail.com wrote: Hi, Struggling to change coding practice, following has two samples, which one is correct? or any other approaches available? For this particular use case, it would be more convenient if 'users' was an object instead of an array, since you could then simply reference users[id] instead of having to walk the array. In fact, even if you do need an array for other use cases, it may be worth considering keeping an object as well, especially if the number of users gets long and / or get_user is called a lot. -- Martin Cooper exports.get_user = function (id, func) { var found = false for (var i = 0; i users.length; i ++) { if (users[i].id === id) { found = true func(null, users[i]) break; } } if (!found) func(NOT_FOUND, null) } exports.get_user = function (id, func) { for (var i = 0; i users.length; i ++) { if (users[i].id === id) { func(null, users[i]) break; } if (i == users.length) func(NOT_FOUND, null) } } -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Error: failed to fetch from registry: tower on windows 7 x64
The error log you posted asks you to mail to a different list: npm ERR! or email it to: npm ERR! n...@googlegroups.com :-) Have you tried setting an https-proxy config value? See 'npm help config' for more on how to do that. Even though you can visit the web sites you mention, that could be because your browser is auto-configured with the appropriate proxy settings. -- Martin Cooper On Mon, Feb 27, 2012 at 5:32 PM, Liu Yongjian ggd...@gmail.com wrote: Here is the log message printed on the screen : npm http GET https://registry.npmjs.org/tower npm ERR! Error: failed to fetch from registry: tower npm ERR! at C:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\npm-registry-client\get.js:139:12 npm ERR! at cb (C:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\npm-registry-client\request.js:32:9) npm ERR! at Request._callback (C:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\npm-registry-client\request. js:137:18) npm ERR! at Request.callback (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\request\main.js:109:22) npm ERR! at Request.anonymous (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\request\main.js:198:58) npm ERR! at Request.emit (events.js:88:20) npm ERR! at ClientRequest.anonymous (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\request\main.js:1 95:10) npm ERR! at ClientRequest.emit (events.js:67:17) npm ERR! at CleartextStream.anonymous (http.js:1137:11) npm ERR! at CleartextStream.emit (events.js:67:17) npm ERR! You may report this log at: npm ERR! http://github.com/isaacs/npm/issues npm ERR! or email it to: npm ERR! n...@googlegroups.com npm ERR! npm ERR! System Windows_NT 6.1.7600 npm ERR! command C:\\Program Files (x86)\\nodejsnode.exe C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\ \npm-cli.js install tower -g npm ERR! cwd e:\nodejsworkspace npm ERR! node -v v0.6.11 npm ERR! npm -v 1.1.1 npm ERR! message failed to fetch from registry: tower npm ERR! npm ERR! Additional logging details can be found in: npm ERR! e:\nodejsworkspace\npm-debug.log npm not ok PS: I am behind the company firewall but I can visit google.com , baidu.com etc -- Thank you -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] can you install cloud9 ide now?
On Sat, Feb 25, 2012 at 7:57 AM, 李白字一日 calid...@gmail.com wrote: i was trying with npm -g install cloud9 and i got messages : npm WARN jsftp@0.1.6 package.json: bugs['web'] should probably be bugs['url'] npm WARN streamer@0.2.0 package.json: bugs['web'] should probably be bugs['url'] Those are warnings that the package owners need to know about, but they are not installation errors, and won't cause any subsequent problems. . it is not able to install the two packages. is there a way to solve the problem? Perhaps if you can tell us what errors you are seeing? -- Martin Copper thx. -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: NodeJS downloadable Docs
On Fri, Feb 24, 2012 at 9:17 AM, Ryan Schmidt google-2...@ryandesign.com wrote: On Feb 24, 2012, at 00:52, Jeremy Rudd wrote: But .markdown files cannot be natively viewed on usual computers. HTML/ CHM is a more friendly format. I would think that finding a markdown viewer would not be difficult. Yup. One great option is Showdown, which will render Markdown in the browser. The original domain went away, but the code is on Github here: https://github.com/coreyti/showdown -- Martin Cooper -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: Version 0.7.4
On Fri, Feb 17, 2012 at 8:38 AM, Dean Landolt d...@deanlandolt.com wrote: On Fri, Feb 17, 2012 at 11:19 AM, Mark Miller erig...@gmail.com wrote: [+dherman, +samth, +brendan] cc'ing David and Sam who are the champions of the module proposal. And cc'ing Brendan. I was not aware that module was common in Node code, just that it was present. I'm not sure any of us knew that it was common. Regardless, I have repeatedly raised the suggestion that ES6 adopt package for the role currently played by module, since package is already reserved in strict mode. However, IIRC not a single other person on the committee voiced any support for this -- for an understandable reason. The term package is in use by Java for something different, but similar enough to create confusion. Our latest agreement is that it be a context sensitive keyword, triggered by syntax that today is necessarily rejected. So, technically at least there is no conflict with Node *code*. Whether the co-existence of both uses of this identifier in Node code makes this confusing is another matter. Once ES6 rolls out, is it likely that both uses would co-exist in the same source file? Or would it be more likely that source files using ES6 modules would typically not need Node's existing use of module in that same file? AFAIK `module` has three uses in node: module.exports for setting the exports object; module === require.main for main module testing; and perhaps most rarely, module.require for contextual requires. I'm sure someone will set me strait if I missed any, but I wouldn't say module is all that common, and where it is used it's used is idiomatic. I don't see how `module` as a contextually reserved would be much of a problem. It's provided to your code as an arg to the wrapper that your module's code is executed within, viz: (function (exports, require, module, __filename, __dirname) { // your module's code here }); so as far as your code is concerned, it's really a local variable (a reference to your Module), with the normally associated scope. I'd agree with the three main uses of 'module' in normal Node code. The first (module.exports) is very widely used. I'd also add a fourth: module.paths. -- Martin Cooper -- 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] how to write for-each loop in JavaScript properly
On Sun, Feb 12, 2012 at 12:09 PM, Marcel Laverdet mar...@laverdet.com wrote: This is one of those old Crockfordisms that I definitely don't agree with. How about instead you just don't add garbage to Object.prototype? Depends on how much control you have over all the code in your environment. Things are somewhat better in Node land, but in browser land, all it takes is some library you're using that augments Object.prototype and you're hosed unless you protect your own enumerations from such augmentation. -- Martin Cooper Or if you do make them DontEnum. Do you really write two-line loop headers every time you want a loop?? On Sun, Feb 12, 2012 at 6:42 AM, Shimon Doodkin helpmep...@gmail.com wrote: for (var key in myobj) must be accompanied with if(Object.hasOwnProperty.call(myobj,key)) example: for (var key in myobject) { if(Object.hasOwnProperty.call(myobject,key)){ ... } } myobject.forEach(function(){...}) already does this. more: You could do : myobj.hasOwnProperty(key) But then if myobj is NULL it will throw an error. So you use the method hasOwnProperty from the prototype object. and you call it with changing the this object of it to your object. Object.hasOwnProperty.call(myobj,key) Most of you probably know this, but sometimes I encounter modules that don't do this. And they do unexpected errors. -- 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+unsubscr...@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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en