forked from openspending-archive/os-import
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (32 loc) · 1.01 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
var express = require('express')
, path = require('path')
, nunjucks = require('nunjucks')
, routes = require('./routes/index.js')
, config = require('./lib/config.js')
;
var app = express();
app.configure(function(){
app.set('port', process.env.PORT || 5000);
app.set('views', __dirname + '/views');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('TODO os-upload random secret'));
app.use(express.static(path.join(__dirname, 'public')));
});
var env = new nunjucks.Environment(new nunjucks.FileSystemLoader('views'));
env.express(app);
app.listen(app.get('port'), function() {
console.log("Listening on " + app.get('port'));
});
app.all('*', function(req, res, next) {
if (config.mode === 'testing') {
req.cookies.apikey = config.apikey;
}
next();
});
app.get('/', routes.home);
app.post('/', routes.uploadPost);
app.get('/login', routes.login);
app.post('/login', routes.loginPost);
app.post('/api/1/check', routes.checkFile);
exports.app = app;