-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (49 loc) · 1.64 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
const express = require("express");
const session = require("express-session");
const bodyParser = require("body-parser");
const path = require("path");
const localization = require("./languages/locales");
const cookieParser = require("cookie-parser");
const crypto = require("crypto");
const mongoSanitize = require("express-mongo-sanitize");
//const localesMW = require("./middleware/localesMW");
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(cookieParser());
app.set("view engine", "ejs");
app.use("/css", express.static(path.join("node_modules", "bootstrap", "dist", "css")));
app.use("/css", express.static(path.join("node_modules", "bootstrap-icons", "font")));
app.use("/js", express.static(path.join("node_modules", "bootstrap", "dist", "js")));
app.use("/js", express.static(path.join("node_modules", "jquery", "dist")));
app.use("/js", express.static(path.join("node_modules", "chart.js", "dist")));
app.use(express.static("static"));
//Multi language framework setup
localization.config({
languages: ["en", "hu"],
defaultLang: "en",
});
// Session setup
app.use(
session({
name: crypto.randomBytes(16).toString("hex"),
secret: crypto.randomBytes(128).toString("hex"),
httpOnly: true,
resave: false,
saveUninitialized: true,
path: "/",
sameSite: "strict",
expires: 86400,
}),
);
app.use(mongoSanitize());
app.use(localization.placeTexts());
require("./route/index")(app);
app.use((err, req, res, next) => {
res.end("Problem...");
console.log(err);
});
const PORT = process.env.WEBPORT || 3000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});