var express = require('express'),
  routes = require('./routes'),
  socket = require('./routes/socket.js');

var app = module.exports = express.createServer();

// Hook Socket.io into Express
var io = require('socket.io').listen(app);

// Configuration
var jsonfile = require('jsonfile');
//surround to catch file not found error...
try {
  var authConfig = jsonfile.readFileSync('./basicauth.json', {throws: false})
} catch(e) {
  authConfig = null;
}

app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.set('view options', {
    layout: false
  });

  //Basic Auth
  if (authConfig && authConfig.enabled) {
    app.use(express.basicAuth(function(user, pass) {
      return pass === authConfig.credentials[user];
    }));
  }

  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.static(__dirname + '/public'));
  app.use(app.router);
});

app.configure('development', function(){
  app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

app.configure('production', function(){
  app.use(express.errorHandler());
});

// Routes
app.get('/', routes.index);
app.get('/server/', routes.server);
app.get('/partials/:name', routes.partials);

// redirect all others to the index (HTML5 history)
app.get('*', routes.index);

// Socket.io Communication

io.sockets.on('connection', socket);

// Start server

//TODO: in production: NODE_ENV=production

app.listen(8000, function(){
  console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
});

@@ -282,16 +282,22 @@
 file');%0A
+try %7B 
 //surrou
@@ -336,14 +336,8 @@
 ...%0A
-try %7B%0A
   va

load of basicauth.json by jsonfile (not require)