forked from namandureja/ojingeo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (23 loc) · 928 Bytes
/
app.js
File metadata and controls
28 lines (23 loc) · 928 Bytes
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
const express = require("express");
const cookieParser = require("cookie-parser");
const bodyParser = require("body-parser");
const accessCode = require("./middleware/accessCode.js");
const {callBack} = require("./db");
require("dotenv").config();
const app = express();
app.set("view engine", "ejs");
app.use(express.static("public"));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser(process.env.COOKIE_SECRET));
app.use(accessCode);
app.use("/auth", require("./routes/auth.js"));
app.use("/frontman", require("./routes/frontman.js"));
app.use("/vip", require("./routes/vip.js"));
app.get("/",(_,res) => res.redirect("/vip"));
const isProduction = process.env.NODE_ENV == "production";
if (!process.env.PORT) process.env.PORT = isProduction ? 80 : 3000;
callBack(() => {
app.listen(process.env.PORT, () => {
console.log(`server is listening on port ${process.env.PORT}`);
});
});