-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
54 lines (45 loc) · 1.36 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var http = require('http');
var express = require('express');
var stylus = require('stylus');
var app = module.exports = express();
var server = http.createServer(app);
// Configuration
function compile(str, path) {
return stylus(str)
.set('filename', path)
.set('compress', true);
}
app.configure(function() {
this.set('views', __dirname + '/views');
this.set('view engine', 'jade');
// bodyParser without multipart
this.use(express.json());
this.use(express.urlencoded());
this.use(express.logger());
this.use(express.methodOverride());
this.use(express.cookieParser('Eah4tfzGAKhr'));
this.use(express.session());
this.use(stylus.middleware({
src: __dirname + '/views',
dest: __dirname + '/public',
compile: compile
}));
this.use(express.favicon(__dirname + '/public/favicon.ico', { maxAge: 2592000000 }));
this.use(express.compress());
this.use(express.static(__dirname + '/public'));
this.use(this.router);
});
app.configure('development', function() {
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function() {
app.use(express.errorHandler());
});
require("./lib/search")(app);
// Only listen on $ node app.js
if (!module.parent) {
var port = 6660;
server.listen(port, function() {
console.log("Express server listening on port %d", port);
});
}