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

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

Fixed for jshint and allow clean of the build directory.

File size: 1.3 KB
Line 
1var express = require("express");
2var fs = require("fs");
3var https = require("https");
4var os = require("os");
5var path = require("path");
6var proxy = require("simple-http-proxy");
7var _ = require("underscore");
8
9function clientPath(relativePath) {
10    return path.resolve('../client/'+relativePath);
11}
12
13var httpsOptions = {
14    key: fs.readFileSync(path.resolve('../qed-server.key')),
15    cert: fs.readFileSync(path.resolve('../qed-server.pem'))
16};
17
18var app = express();
19app.use(express.logger());
20app.use(express.compress());
21app.use(express.favicon());
22app.get('/', function(request, response){
23    response.sendfile(clientPath('index.html'));
24});
25app.get('/*.html', function(request, response) {
26    response.sendfile(clientPath(request.path));
27});
28_.each(['/dojo', '/dijit', '/dojox', '/qed', '/qed-client'], function(dir){
29    app.use(dir, express.static(clientPath(dir)));
30});
31app.use('/data/couch', proxy('http://localhost:5984/qed'));
32
33var server = https.createServer(httpsOptions, app);
34server.listen(8443);
35
36console.log(
37    "Listening on " +
38    _.chain(os.networkInterfaces())
39     .map(function(value,key){ return value; })
40     .flatten()
41     .filter(function(intf){ return intf.family === "IPv4" && !intf.internal; })
42     .reduce(function(urls, intf){ return urls+', http://'+intf.address+':8443/'; }, "http://127.0.0.1:8443/")
43     .value() + ".");
Note: See TracBrowser for help on using the repository browser.