forked from kav137/beautifulKimai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
50 lines (41 loc) · 1.11 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
var express = require("express");
var morgan = require("morgan");
var cookie = require("cookie-parser");
var parser = require("body-parser");
var session = require("express-session");
var app = express();
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header(
"Access-Control-Allow-Headers",
"X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept"
);
res.header("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE");
res.header("Access-Control-Allow-Credentials", false);
res.header("Access-Control-Max-Age", "86400");
res.header("X-HTTP-Method-Override, Content-Type, Accept");
next();
});
app.use(morgan("combined"));
app.use(cookie());
app.use(
session({
secret: "keyboard cat",
resave: true,
saveUninitialized: true,
cookie: {
maxAge: 2000000
}
})
);
app.use(
parser.urlencoded({
extended: true
})
);
app.use(parser.json());
app.use(express.static(__dirname + "/public"));
const serverPort = process.env.PORT || 1488;
app.listen(serverPort, function() {
console.log("Server is on " + serverPort + " port.");
});