-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
64 lines (55 loc) · 1.7 KB
/
app.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
55
56
57
58
59
60
61
62
63
64
"use strict";
var express = require('express')
, routes = require('./routes')
, http = require('http')
, path = require('path')
, stylus = require('stylus')
, nib = require('nib')
, redis = require('redis')
, favicon = require('serve-favicon')
, morgan = require('morgan')
// , bodyParser = require('body-parser')
// , methodOverride = require('method-override")
if (process.env.REDISTOGO_URL) {
var url = require('url'),
redisUrl = url.parse(process.env.REDISTOGO_URL),
redisAuth = redisUrl.auth.split(':'),
redisClient = redis.createClient(redisUrl.port, redisUrl.hostname);
redisClient.auth(redisAuth[1],function(){
// redisClient.select(redisAuth[0]);
});
} else {
var redisClient = redis.createClient();
}
var app = express();
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(morgan('dev', {
skip: function (req, res) { return res.statusCode < 400 }
}));
// app.use(bodyParser.urlencoded({extended: false}));
// app.use(express.methodOverride());
app.use(stylus.middleware(
{ "src" : __dirname + '/public'
, "compile" : function(str, path) {
return stylus(str)
.set('filename', path)
// .set('compress', true)
.use(nib());
}
}
));
app.use(express.static(path.join(__dirname, 'public')));
// development only
if ('development' == app.get('env')) {
// app.use(express.errorHandler());
}
//Include the routes
require('./routes/index')(app);
var server = app.listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
module.exports = server;