3 ms·
I am not a seasoned node.js developer, but have been playing around with a small node.js + socket.io + mongodb based application over the last month or so. Don
by m0hit 15y ago
I am not a seasoned node.js developer, but have been playing around with a small node.js + socket.io + mongodb based application over the last month or so.
Don't think I have direct answers to your question, but here is how I have been learning:
- the node.js boilerplates available on github are a useful starting point for organizing your code https://github.com/robrighter/node-boilerplate https://github.com/robrighter/node-boilerplate, https://github.com/mape/node-express-boilerplate https://github.com/mape/node-express-boilerplate There are differences in how the code is structured, but they are great to learn from.
- Break up your project into libraries. In many cases the very basic examples do not break out the code appropriately for simplicity. However, there are some great examples within express source (i can't remember the exact name) that organize web applications routes into multiple files (and modules).
- node.js has tons of well written code on github. I've been pouring over the source code of express, socket.io-node, hummingbird and many other applications. Especially lookout for TJ Holowaychuk, Guillermo Rauch, Isaacs, ry.
- the #node.js channel on irc is just amazing. There are interesting conversations, and I have had a lot of help regarding not just problems I've run into, but also style. I've pasted bits of code, that looked ugly to me and others have helped me think through it.
Hope this helps a bit.
Of course look at all the great guides and books about node.js such as howtonode.org , mastering node and others. There is a good list on: https://github.com/joyent/node/wiki/Resources https://github.com/joyent/node/wiki/Resources
- michael_miller 15y agoThanks for the suggestions and links! I will definitely read up on some "production" node.js code; this is something I really have not done at all. I've pretty much learned node.js based on a few simple examples, and the API docs. This is probably part of the reason why I'm having trouble writing elegant node.js code.
- cezary 15y ago> - Break up your project into libraries. In many cases the very basic examples do not break out the code appropriately for simplicity. However, there are some great examples within express source (i can't remember the exact name) that organize web applications routes into multiple files (and modules). Sounds like route separation: https://github.com/visionmedia/express/tree/master/examples/route-separation https://github.com/visionmedia/express/tree/master/examples/...