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