-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
executable file
·66 lines (55 loc) · 1.25 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
var express = require('express');
var app = express();
var session = require('express-session');
var bodyParser = require('body-parser');
/**
* Static stuff
*/
app.use(express.static('public'));
app.set('view engine', 'ejs');
/**
* Session above all
*/
app.use(session({
secret: 'keyboard cat',
cookie: {
maxAge: 60000
},
resave: true,
saveUninitialized: false
}));
/**
* Parse parameters in POST
*/
// for parsing application/json
app.use(bodyParser.json());
// for parsing application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({
extended: true
}));
/**
* Let's creat the .tpl and .error on the res object
*/
app.use(function (req, res, next) {
res.tpl = {};
res.tpl.error = [];
return next();
});
/**
* Include all the routes
*/
require('./routes/outside')(app);
require('./routes/employeelist')(app);
require('./routes/itemlist')(app);
require('./routes/inventorylist')(app);
/**
* Standard error handler
*/
app.use(function (err, req, res, next) {
res.status(500).send('Houston, we have a problem!');
//Flush out the stack to the console
console.error(err.stack);
});
var server = app.listen(3000, function () {
console.log('Hello :3000');
});