-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
33 lines (26 loc) · 810 Bytes
/
main.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
var serverData = require("./config.json");
var router = require("./router");
var path = require("path");
var express = require("express");
var cookieParser = require("cookie-parser");
var bodyParser = require('body-parser');
var session = require("express-session");
function randomString() {
return Math.random().toString().replace("0.", "");
}
var root = __dirname;
var staticPath = path.join(root, "static");
var app = express();
app.set("view engine", "ejs");
app.use(express.static(staticPath));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(cookieParser(randomString()));
app.use(session({
secret: randomString(),
resave: true,
saveUninitialized: true
}));
app.use("/", router);
app.listen(serverData.port);
console.log('Server running');