source: Dev/trunk/src/server/server.js @ 452

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

Completed separation of client and server.

File size: 1.0 KB
RevLine 
[451]1var express = require("express");
2var fs = require("fs");
3var https = require("https");
4var path = require("path");
5var proxy = require("simple-http-proxy");
6var _ = require("underscore");
[443]7
[452]8function clientPath(relativePath) {
9    return path.resolve('../client/'+relativePath);
[451]10}
[443]11
[451]12var httpsOptions = {
[452]13    key: fs.readFileSync(path.resolve('../qed-server.key')),
14    cert: fs.readFileSync(path.resolve('../qed-server.pem'))
[451]15};
16
17var app = express();
18app.use(express.logger());
19app.use(express.compress());
20app.use(express.favicon());
21app.get('/', function(request, response){
[452]22    response.sendfile(clientPath('index.html'));
[443]23});
[452]24app.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]30app.use('/data/couch', proxy('http://localhost:5984/qed'));
31
32var server = https.createServer(httpsOptions, app).listen(8443);
33
34console.log("Listening on https://localhost:8443/");
Note: See TracBrowser for help on using the repository browser.