63. This is such a relief, and makes big projects conceivable http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml http://portawiki.abnoctus.com/view/Object_Oriented_Event_Handlers.html
70. Project layout Node and npm in the system path /home/me/node_workspace/... .../node_modules/sax /dom /my_funky_mod /my_proj1 /my_proj2
71. Module files ./README.md ./package.json ./index.js ./lib/ ./test/ ./example/ ./deps/ (or NOT) N.B. There is no ./target or ./classes or ./out needed
72. Application files ./src/js ./src/client ./src/server ./src/conf ./bin/ (still run from source) ./test/js ./test/data ./foo ./bar ./../node_modules The aim is that the following should be painless var foo = require('foo');
73.
74. Half you code relies on relative directories , then nodeunit blows the theory.
75. Dont have relative paths for resources e.g. ../conf/config.xml is becoming a problem
76.
77. WebSockets these are built in to http core in node for an obvious reason.
78. haml + sass early options , there are many more templates now but this is “cool”
106. Good for “model 3”, I know its not cool, but you need templating in the real world for division of labour
107. Depends on your legacy, libs integrate well, but most services will not integrate with node, existing code uses threads, managing JMS is somehow difficult
108. That 50% validation code saving is very tempting! (talking mostly about webapps)
Hinweis der Redaktion
Chrome v8 is an open source google sponsored JavaScript runtime http://code.google.com/p/v8/ API here http://nodejs.org/docs/v0.5.0/api/all.html
You need to install git the version control system by Linux himself, its a ballache you get used to it. “joyent” is the company that sponsors node development.
If you Have certificate errors try env GIT_SSL_NO_VERIFY=true git clone https://github.com/joyent/node.git you need open ssl and c++ build tools Copy the hello world from the node home page http://nodejs.org/
Npm installs with curl http://npmjs.org/install.sh | sh If you are lucky Then man npmn Or Npnm install nodeunit
Lots of too technical stuff on t'internet basically even drivven means evtsrc.on('someEvent' , function(data) { // this happens when the event is fired }); All IO in node is event driven ie. not String data = readFile(); More like fs.readFile(name, 'utf-8', function(data) { });
Node is good at doing nothing no swapping threads around in the background, when it is idle it really is idle. When something happens ALL the code is executed until the end of the function or functions responding to the event.
Look into web sockets, if you are using web sockets you should be using node as the server probably. Node can handle many concurrent connections as long as they are not doing much.
N.B. Node is single threaded so if you do somewthing that takes a very long time in the thread you hang the system completely, for example if you process some very large JPEG image that takes a few seconds to do, nothing else happens. To do that sort of thing push a job onto a rabbitMQ queue for processing on a separate thread and put an event listener on the reply.
Reiterate a file IS a module. “import” the module with var xxx = require(“../../somejsfile.js”); Only exported functions are visible e.g. you must call module.exports.addUp = function(a, b) { return a + b; }
If you require('someModule') Node looks for ./node_modules/someModule.js ./node_modules/someModule/index.js And a bunch of other places Including ../../../node_modules Right back to /node_modules/ A bit simple, but it works.
This is just my tips there is no obligatory project structure like there is in maven.
README.md is a markdown text file for github, not needed if you don't host at github package.json is an npm thing RTFM it is pretty simple ./lib is a recommended standard, not a requirement ./example/ is polite ./deps/ is probably a bad idea use npm
Have a think about where your client side and server side files reside, because you might want to share code between the two. Sharing code needs some hacking like if(module.exports) { Module.exports.funktion= funktion; } else { var ns = new Object(); ns.funktion = funktion; }
Again. Just a tip, relative paths for resources turns out nasty, I plan to fix this in nodeunit for eclipse, I have submitted a pull request.
Node is cool and has a community that is into the hip stuff going on at the mo, kind of railsy type people. Read up on these things they are funky but also functional. (treble pun there, gedit? ed.)
Node has some serious limits, so you can do everything in node, it is not C++ or Java. It is good at what it is good at and bad at everything else.
Model3 is a me term, Model 1 is servlet returning HTML Model 2 is a servlet processing then forwarding to a JSP Model 3 is a HTML page talking JSON to the server RPC style with no Java2HTML at all.