[451] | 1 | var express = require("express"); |
---|
| 2 | var fs = require("fs"); |
---|
| 3 | var https = require("https"); |
---|
| 4 | var path = require("path"); |
---|
| 5 | var proxy = require("simple-http-proxy"); |
---|
| 6 | var _ = require("underscore"); |
---|
[443] | 7 | |
---|
[452] | 8 | function clientPath(relativePath) { |
---|
| 9 | return path.resolve('../client/'+relativePath); |
---|
[451] | 10 | } |
---|
[443] | 11 | |
---|
[451] | 12 | var httpsOptions = { |
---|
[452] | 13 | key: fs.readFileSync(path.resolve('../qed-server.key')), |
---|
| 14 | cert: fs.readFileSync(path.resolve('../qed-server.pem')) |
---|
[451] | 15 | }; |
---|
| 16 | |
---|
| 17 | var app = express(); |
---|
| 18 | app.use(express.logger()); |
---|
| 19 | app.use(express.compress()); |
---|
| 20 | app.use(express.favicon()); |
---|
| 21 | app.get('/', function(request, response){ |
---|
[452] | 22 | response.sendfile(clientPath('index.html')); |
---|
[443] | 23 | }); |
---|
[452] | 24 | app.get('/*.html', function(request, response) { |
---|
| 25 | response.sendfile(clientPath(request.path)); |
---|
[451] | 26 | }); |
---|
[452] | 27 | _.each(['/dojo', '/dijit', '/dojox', '/qed', '/qed-client'], function(dir){ |
---|
| 28 | app.use(dir, express.static(clientPath(dir))); |
---|
| 29 | }); |
---|
[451] | 30 | app.use('/data/couch', proxy('http://localhost:5984/qed')); |
---|
| 31 | |
---|
| 32 | var server = https.createServer(httpsOptions, app).listen(8443); |
---|
| 33 | |
---|
| 34 | console.log("Listening on https://localhost:8443/"); |
---|