You have to make sure when exposing app (or any object or value) via exports that it is initialized prior to being required by any other module. So in this case the routing module would break if it were required by server.js prior to app having been initialized. I use this technique a lot. It allows routing modules to act as controllers. Combined with common.js ability to modularize whole folders through index.js then allows encapsulating all your controllers in a structured manner. I wrote an article on this very subject which can be found at http://jefftschwartz.wordpress.com/2012/09/10/taming-those-unruly-routes/. This article was a follow up to another article which explores using folders for encapsulation in common.js and that article can be found at http://jefftschwartz.wordpress.com/2012/08/23/use-express-route-specific-middleware-to-access-mongodb/.
-- 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
