Yes, the 'app' global will be available in every file you require in.
Here's an example of my usual pattern, using express: https://github.com/ryancole/node-simple-upload/tree/master/n...
The routes are not namespaced like you'd see with something like Python's Flask does, but it still allows me to group all my similar routes.
Re:Ace - Sinatra for Node with Fibers
by furtivefelon on Tuesday February 14, 2012 @07:04PM
(#3592379)
this works for me:
include it in routes/index.js, and everything in your routes dir will be exposed if you do var routes = require('./routes')
var files = fs.readdirSync('./routes') files.forEach(function(file){ if(file != 'index.js'){ var exp = require('./'+file); _.extend(exports, exp); } });
I didn't see a way by just skimming the docs - is there an easy way?