text: /**
   * Module dependencies
   */
  var express = require('express'),
    bodyParser = require('body-parser'),
    methodOverride = require('method-override'),
    errorhandler = require('errorhandler'),
    morgan = require('morgan'),
    routes = require('./routes'),
    api = require('./routes/api'),
    http = require('http'),
    path = require('path'),
    disconnect = require('disconnect');
  
  var app = module.exports = express();
  
  /**
   * Configuration
   */
  
  // all environments
  app.set('port', process.env.PORT || 3000);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  // app.use(morgan('dev'));
  app.use(bodyParser.urlencoded({
    extended: true
  }));
  app.use(bodyParser.json());
  app.use(methodOverride());
  app.use(express.static(path.join(__dirname, 'public')));
  
  var env = process.env.NODE_ENV || 'development';
  
  // development only
  if (env === 'development') {
    app.use(errorhandler());
  }
  
  // production only
  if (env === 'production') {
    // TODO
  }
  
  
  /**
   * Routes
   */
  
  // serve index and view partials
  app.get('/', routes.index);
  app.get('/partials/:name', routes.partials);
  
  // JSON API
  app.get('/api/collection/:name', api.collection);
  app.get('/api/users/:name', api.users);
  app.get('/api/release/:name', api.release);
  app.get('/api/marketplace/prices/:releaseid', api.marketplace);
  app.get('/api/authorize', api.authorize);
  app.get('/api/callback', api.callback);
  // redirect all others to the index (HTML5 history)
  app.get('*', routes.index);
  
  /**
   * Start Server
   */
  
  http.createServer(app).listen(app.get('port'), function () {
    console.log('Express server listening on port ' + app.get('port'));
  });