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
RevLine 
[451]1var express = require("express");
2var fs = require("fs");
3var https = require("https");
[459]4var os = require("os");
[451]5var path = require("path");
6var proxy = require("simple-http-proxy");
7var _ = require("underscore");
[443]8
[452]9function clientPath(relativePath) {
10    return path.resolve('../client/'+relativePath);
[451]11}
[443]12
[451]13var httpsOptions = {
[452]14    key: fs.readFileSync(path.resolve('../qed-server.key')),
15    cert: fs.readFileSync(path.resolve('../qed-server.pem'))
[451]16};
17
18var app = express();
19app.use(express.logger());
20app.use(express.compress());
21app.use(express.favicon());
22app.get('/', function(request, response){
[452]23    response.sendfile(clientPath('index.html'));
[443]24});
[452]25app.get('/*.html', function(request, response) {
26    response.sendfile(clientPath(request.path));
[451]27});
[452]28_.each(['/dojo', '/dijit', '/dojox', '/qed', '/qed-client'], function(dir){
29    app.use(dir, express.static(clientPath(dir)));
30});
[451]31app.use('/data/couch', proxy('http://localhost:5984/qed'));
32
[462]33var server = https.createServer(httpsOptions, app);
[459]34server.listen(8443);
[451]35
[459]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.