Nodejs: Where or How to write complicated business logic?

Not quite sure what most of these folks are talking about.

A "vast ocean of libraries" is something the community is actively working on. Check this: http://search.npmjs.org/#/_analytics -- there were 8 packages published yesterday

Its not going to solve your software design for you. As for where and how to write business logic, many of us embrace mvc or mvvm or something close to it. If you're building an application and like how Rubyists (for example), structure their code you might look at doing something just like that -- aint nobody going to tell you how to structure your code.

Check https://github.com/joyent/node/wiki/modules

Some of the more popular libraries for doing the day to day:

  • Express: http://expressjs.com/ - https://github.com/visionmedia/express
    • Sinatra inspired, use it to build a typical web app
    • Stats: 3407 watchers, 286 forks, on pull request 778
    • Compare that to Sinatra itself! 2529 watchers, 366 forks
    • With connect, it supports all kinds of middleware:
      • sessions,
      • all kinds of routing,
      • static files
      • some 15 different templating engines
      • validation, form handling, etc, etc
  • Socket.io: http://socket.io/ - make it 'real-time'
  • DNode: https://github.com/substack/dnode - do rpc between anything
  • Backbone.js: http://documentcloud.github.com/backbone/ - MVC
    • Variety of techniques for re-using your models on the server:
    • http://andyet.net/blog/2011/feb/15/re-using-backbonejs-models-on-the-server-with-node/
  • Spine.js: http://maccman.github.com/spine.tutorials/index.html - MCV
    • Techniques for re-using code on the server:
    • http://maccman.github.com/spine.tutorials/node.html
  • caolan/async: https://github.com/caolan/async - Help manage your async business logic
  • Database, pick your poision
    • node_redis, https://github.com/mranney/node_redis - or one of the eight other clients
      • "This is a complete Redis client for node.js. It supports all Redis commands"
    • node-mysql, https://github.com/felixge/node-mysql - or one of eleven other clients/orms
    • node-mongodb-native, https://github.com/christkv/node-mongodb-native
    • node-postgres, https://github.com/brianc/node-postgres

There's also a host of ORMs out there, if thats your bag. Things like http://mongoosejs.com/, http://sequelizejs.com/ and friends

Test-driven development is at the core of node. There are 15 different TDD packages to choose from that range from full code coverage analysis to custom assert modules.

Saying all modules are incomplete is silly. There is an incredibly dedicated group of people building and maintaining tons working open-source in this community every day.

There might be reasons to pass over node, but its not for an inactive community or lack of libraries.


I would say you missed something - more specifically, the core purpose of Node.js, that is, the asynchronous I/O model.

I started a little pet project to test Node.js - how it "feels" and how to program on it. I became impressed by the ease of working in such ecosystem: Node.js code is easy to write (although its asynchronous paradigm is not that straightforward for the conventional programmer), libraries are easy to build etc. etc. Even npm is amazingly easy: I just found the most straightforward way to provide code of your own as a library is to make a public package of it - and it is absurdly easy!

However, there is not much good tools to work with Node.js. Maybe because it is too easy to do anything, most libraries are partially-implemented, undocumented solutions.

Also, note that the relevant difference of Node.js is not the JavaScript language, but the asynchronous I/O model. It is the most interesting aspect of Node.js, but the asynchronous programming style is not as well tested as the conventional way of web development. Maybe it is really the marvel that is propagandized - or perhaps, it is not as good as promised.

Even in the case it pays off, will you have enough developers to maintain such an (at least still) unusual codebase? If you can get a lot of advantages from the asynchronous "way of life" of Node.js, you can use more consolidated languages and frameworks, such as Twisted for Python (which is my preferred languabe, so take care with my opinion :) ). There may be something like this for Java, too. Anyway, I suspect that you do not have a lot of interest in this model for now, since your question focuses more on languages than in the programming paradigm, so Node.js does not have much to offer to you anyway.

So... no, I would not develop something professonaly in Node.js for now, although I think it is both fun and instructive to study. You can do it, however - just do not do it without having in mind the main purpose of Node.js: asynchronous-IO, event-driven programming. If it is what you want, Node.js is a good alternative.