-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
37 lines (28 loc) · 943 Bytes
/
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
const express = require("express");
const session = require("express-session");
const bodyParser = require("body-parser");
const expressValidate = require("express-validator");
const config = require("./app/config/" + (process.env["NODE_ENV"] || "Production"));
const port = config.PORT;
const app = express();
app.set("view engine", "ejs");
app.set("views", "./views");
app.use(
session({
secret: config.SECRET_SESSION,
resave: false,
saveUninitialized: true,
cookie: {
maxAge: 1000 * 60 * 60 * 2 //2 hours
}
})
);
app.use(express.static("public"));
app.use(bodyParser.json());
app.use(expressValidate());
app.use("/api", require("./app/controllers/LoginController"));
app.use("/api", require("./app/controllers/ModuleController"));
app.use("/*", require("./app/controllers/IndexController"));
app.listen(port, () => {
console.log("Server started on port " + port);
});