source: Dev/trunk/src/qed-server/server.js @ 443

Last change on this file since 443 was 443, checked in by hendrikvanantwerpen, 12 years ago

Reorganized for Node --- the SVN gods hate us all!

Lost all historical info on moved files, because SVN is a f *.

Also we have Node now, serving both the static content and forwarding
database requests.

File size: 1.1 KB
Line 
1define([
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});
Note: See TracBrowser for help on using the repository browser.