-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
65 lines (57 loc) · 1.29 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
62
63
64
65
/*
* zmgr: Manage noki.zorque.xyz web services
*
* DEVELOPERS: Lewis Watson
* DATE: 17.06.2018
* PURPOSE: Serve as the application entry point
* FILE: index.js
*/
"use strict";
/*
* Node environment
*/
require("dotenv").config();
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = "dev";
}
console.log("You are running in " + process.env.NODE_ENV + " environment");
/*
* Configuration
*/
const port = process.env.PORT || 3000;
/*
* Libraries
*/
const pug = require("pug");
const express = require("express");
const session = require("express-session");
const favicon = require("serve-favicon");
/*
* Express
*/
const app = module.exports = express();
app.use(session({
secret: process.env.SECRET,
saveUninitialized: false,
resave: false
}));
app.engine("pug", pug.__express);
app.set("view engine", "pug");
app.use("/i", express.static(process.env.WORKING_DIR + "/i")); // serve images
app.use("/u", express.static(process.env.WORKING_DIR + "/u")); // service files
app.use("/assets", express.static("assets"));
app.use(favicon(__dirname + "/assets/img/favicon.ico"));
/*
* Middleware
*/
app.use(require("./logic/middleware.js"));
/*
* Routes
*/
require("./logic/routes.js");
/*
* Listen
*/
app.listen(port, () => {
console.log("Listening for incoming connections on port " + port);
});