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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)