-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
71 lines (61 loc) · 1.4 KB
/
index.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
65
66
67
68
69
70
71
var express = require('express');
var app = express();
const fileUpload = require('express-fileupload');
var session = require('express-session');
var bodyParser = require('body-parser');
var moment = require('moment');
/**
* Access to the static pages and public files
*/
app.use('/static', express.static('static'));
app.use(express.static('public'));
app.use(fileUpload());
app.set('view engine', 'ejs');
/**
* Session
*/
app.use(session({
secret: 'random titok',
cookie: {
maxage: 60000
},
resave: true,
saveUninitialized: false
}));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: false
}));
/**
* Create .error and .tpl on res
*/
app.use(function (req, res, next) {
res.tpl = {};
res.tpl.error = [];
res.tpl.func= {
moment: moment
};
res.tpl.user= {
isadmin: false
};
return next();
});
/**
* Include all route
*/
require('./routes/app')(app);
require('./routes/judge')(app);
require('./routes/news')(app);
require('./routes/tender')(app);
require('./routes/user')(app);
require('./routes/general')(app);
/**
* Error handler
*/
app.use(function (err, req, res, next) {
res.status(500).send("Error"); // sends a http err msg
console.error(err.stack); // write the err to std:err
});
var server = app.listen(3000, function () {
console.log("On :3000")
});