title: Make require() variables global?
body: <p>I am very new to node and I would like to know if there is something like automatic dependency-injection. The reason is that I see many packages (for example in Sails.js) have these global variables that can be used anywhere and I want to know how to do that.</p>
  
  <p>Right now I'm passing my DB connection and ORM for every model and I wonder how can I avoid it. Also, for example I want lodash <code>_</code> to be global so I won't have to require it in every file I'm using it.</p>
  
  <h3>Example of what I have now</h3>
  
  <p>app.js</p>
  
  <pre><code>var sequelize = require('sequelize');
  var db = new sequelize('mysql://root:password@localhost/testDb');
  
  var models = require('./models')(db, sequelize); // I don't want to pass them around
  </code></pre>
  
  <p>models/index.js</p>
  
  <pre><code>'use strict';
  
  module.exports = function(db, sequelize) {
      return {
          users: require('./schemas/_user')(db, sequelize) // again I'm passing here, I don't want to
      };
  };
  </code></pre>
  
  <p>models/schemas/_user.js</p>
  
  <pre><code>'use strict';
  
  module.exports = function(db, sequelize) { // And here I finally actually am *using* those variables
      return db.define('users', {
          id: {
              field: 'id',
              type: sequelize.INTEGER(11).UNSIGNED,
              primaryKey: true,
              autoIncrement: true
          },
          email: {
              field: 'email',
              type: sequelize.STRING,
              allowNull: false,
              unique: true
          }
      });
  };
  </code></pre>