
/**
 * Module dependencies.
 */
require('nodetime').profile({
    accountKey: 'e471874f4f721e3103e7d6a420f27dedebf70f14',
    appName: 'ten20 homepage'
});

var express = require('express'),
    routes = require('./routes'),
    api = require('./routes/api'),
    dbs = require('./app/db');
    http = require('http'),
    https = require('https'),
    options = require('./http-options');



var app = module.exports = express();

// Configuration

function requireHTTPS(req, res, next) {
    if (!req.secure) {
        //FYI this should work for local development as well
        return res.redirect('https://' + req.get('host') + req.url);
    }
    next();
}

app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  if (options) {
      app.use(requireHTTPS);
  }
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.cookieParser('&*(j#$84nui$%'));
  app.use(express.session());
  app.use(express.static(__dirname + '/public'));
  app.use(express.favicon(__dirname + '/public/favicon.ico'));
  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(/\/\w?/, routes.index);
app.get('/partials/:name', routes.partials);
app.post('/contact', routes.form);

// JSON API
app.get('/api/name', api.name);

dbs(function(db) {
    routes.setDb(db);
    if (options) {
        https.createServer(options, app).listen(4433);
    }
    http.createServer(app).listen(3000);
});

@@ -1614,16 +1614,42 @@
 .listen(
+process.env.HTTPS_PORT %7C%7C 
 4433);%0A 
@@ -1691,15 +1691,77 @@
 ten(
-3000);%0A%7D
+process.env.HTTP_PORT %7C%7C 3000);%0A%7D);%0A%0Aconsole.log(process.env.HTTP_PORT
 );%0A

Allow ports to be specified via environment variables