var express = require("express"); var fs = require("fs"); var https = require("https"); var os = require("os"); var path = require("path"); var proxy = require("simple-http-proxy"); var _ = require("underscore"); function clientPath(relativePath) { return path.resolve('../client/'+relativePath); } var httpsOptions = { key: fs.readFileSync(path.resolve('../qed-server.key')), cert: fs.readFileSync(path.resolve('../qed-server.pem')) }; var app = express(); app.use(express.logger()); app.use(express.compress()); app.use(express.favicon()); app.get('/', function(request, response){ response.sendfile(clientPath('index.html')); }); app.get('/*.html', function(request, response) { response.sendfile(clientPath(request.path)); }); _.each(['/dojo', '/dijit', '/dojox', '/qed', '/qed-client'], function(dir){ app.use(dir, express.static(clientPath(dir))); }); app.use('/data/couch', proxy('http://localhost:5984/qed')); var server = https.createServer(httpsOptions, app); server.listen(8443); console.log( "Listening on " + _.chain(os.networkInterfaces()) .map(function(value,key){ return value; }) .flatten() .filter(function(intf){ return intf.family === "IPv4" && !intf.internal; }) .reduce(function(urls, intf){ return urls+', http://'+intf.address+':8443/'; }, "http://127.0.0.1:8443/") .value() + ".");