On Jul 3, 5:47 pm, josh <[email protected]> wrote:
> I have a variable in server.js. how to access it from within a function
> that is exported from a module?

One way is to pass it to your function like so:

var usersCollections = {};
router.define( '/user', require('./routes/user.js')(usersCollections))

//routes/user.js

module.exports = function(usersCollection) {
  return function(req, res) {
    console.log('collection', usersCollection);
    return res.end();
  };
};

-- 
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

Reply via email to