title: Global variable express node.js
body: <p>I am trying to get variables that I can get everywhere in my code
  I found a solution but that's not very clean</p>
  
  <pre><code>//environment.js    
  module.exports.appName = "appName";
  </code></pre>
  
  <p>and my app.js</p>
  
  <pre><code>var express = require('express')
  , routes = require('./routes/main')
  , user = require('./routes/user')
  , http = require('http')
  , path = require('path');
  
  var app = express();
  
  environment = require('./environment');
  
  app.configure(function(){
  app.set('port', process.env.PORT || 3000);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.favicon());
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.cookieParser('your secret here'));
  app.use(express.session());
  app.use(app.router);
  app.use(require('stylus').middleware(__dirname + '/public'));
  app.use(express.static(path.join(__dirname, 'public')));
  });
  
  app.configure('development', function(){
    app.use(express.errorHandler());
  });
  
  
  app.get('/', routes.home);
  app.get('/users', user.list);
  
  http.createServer(app).listen(app.get('port'), function(){
    console.log("Express server listening on port " + app.get('port'));
  });
  </code></pre>
  
  <p>In this way my var works, I can access environment.appName everywhere, but Y would have better solution</p>
  
  <p>Thanks </p>