-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
43 lines (35 loc) · 1.12 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
const config = require("./config/config.json");
const express = require("express");
const session = require("express-session");
const fileUpload = require("express-fileupload");
const path = require("path");
const route = require("./routes/main");
const chalk = require("chalk");
const PORT = process.env.PORT || config.SERVER.PORT;
const HOST = config.SERVER.HOST;
var app = express();
app.set("views", "./views");
app.set("view engine", "ejs");
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(fileUpload());
app.use(
session({
secret: config.SESSION.SECRET,
resave: false,
saveUninitialized: false,
})
);
app.use("/static", express.static(path.join(__dirname, "static")));
app.use("/pictures", express.static(path.join(__dirname, "data", "gallery")));
app.use("/data", express.static(path.join(__dirname, "data")));
app.use(
"/favicon.ico",
express.static(path.join(__dirname, "static", "images", "favicon.ico"))
);
app.use("/", route);
app.listen(PORT, () => {
console.log(
chalk.green.inverse(` Started server ${HOST} on port ${PORT} `)
);
});