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"); |
---|
7 | |
---|
8 | function clientPath(relativePath) { |
---|
9 | return path.resolve('../client/'+relativePath); |
---|
10 | } |
---|
11 | |
---|
12 | var httpsOptions = { |
---|
13 | key: fs.readFileSync(path.resolve('../qed-server.key')), |
---|
14 | cert: fs.readFileSync(path.resolve('../qed-server.pem')) |
---|
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){ |
---|
22 | response.sendfile(clientPath('index.html')); |
---|
23 | }); |
---|
24 | app.get('/*.html', function(request, response) { |
---|
25 | response.sendfile(clientPath(request.path)); |
---|
26 | }); |
---|
27 | _.each(['/dojo', '/dijit', '/dojox', '/qed', '/qed-client'], function(dir){ |
---|
28 | app.use(dir, express.static(clientPath(dir))); |
---|
29 | }); |
---|
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/"); |
---|