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
Line 
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");
7
8function clientPath(relativePath) {
9    return path.resolve('../client/'+relativePath);
10}
11
12var httpsOptions = {
13    key: fs.readFileSync(path.resolve('../qed-server.key')),
14    cert: fs.readFileSync(path.resolve('../qed-server.pem'))
15};
16
17var app = express();
18app.use(express.logger());
19app.use(express.compress());
20app.use(express.favicon());
21app.get('/', function(request, response){
22    response.sendfile(clientPath('index.html'));
23});
24app.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});
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.