forked from hebertsilva/roller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (32 loc) · 929 Bytes
/
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
var express = require('express');
var configurations = module.exports;
var app = express();
var server = require('http').createServer(app);
var nconf = require('nconf');
var settings = require('./settings')(app, configurations, express);
var redis = require('redis');
var client = redis.createClient();
nconf.argv().env().file({ file: 'local.json' });
/* Filters for routes */
var isLoggedIn = function(req, res, next) {
if (req.session.email) {
next();
} else {
res.redirect('/');
}
};
require('express-persona')(app, {
audience: nconf.get('domain') + ':' + nconf.get('authPort')
});
// routes
require("./routes")(app, client, nconf, isLoggedIn);
app.get('/404', function(req, res, next) {
next();
});
app.get('/403', function(req, res, next) {
next();
});
app.get('/500', function(req, res, next) {
next(new Error('something went wrong!'));
});
app.listen(process.env.PORT || nconf.get('port'));