var express = require('express'); var proxy = require('http-proxy-middleware'); var path = require('path'); var url = require('url'); var fs = require('fs'); var morgan = require('morgan') var logger = require('./logger'); // Setup the root application. Everything will actually be under a // mount point corresponding to the specific user. This is added in // each of the routes when defined. var app = express(); var uri_root_path = process.env.URI_ROOT_PATH || ''; // Add logging for request. var log_format = process.env.LOG_FORMAT || 'dev'; app.use(morgan(log_format)); // In OpenShift we are always behind a proxy, so trust the headers sent. app.set('trust proxy', true); // Setup handlers for routes. function install_routes(directory) { if (fs.existsSync(directory)) { var files = fs.readdirSync(directory); for (var i=0; i