thanks guys. both ways works. i prefer the module.export.foo way since i don't need to pass the variable to multiple functions.
On Tuesday, July 3, 2012 2:47:58 PM UTC-7, josh wrote: > > I have a variable in server.js. how to access it from within a function > that is exported from a module? > I use mapletree as my routes library that provide me define function - > > var usersCollections = {}; > router.define( '/user', require('./routes/user.js') > > //routes/user.js > > module.exports = user; > > function user (req, res) { > console.log('collection', usersCollection); // not defined > return res.end(); > }; > > http://pastebin.com/SLHM85Xt > > here is the complete project - > https://github.com/oren/Y-U-NO-BIG > -- 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 nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en