forked from shoel-uddin/Gamers_Paradise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
73 lines (60 loc) · 1.81 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
66
67
68
69
70
71
72
73
require("dotenv").config();
const http = require("http");
const express = require("express");
const helmet = require("helmet");
const morgan = require("morgan");
const es6Renderer = require("express-es6-template-engine");
const session = require("express-session");
const FileStore = require("session-file-store")(session);
const app = express();
const server = http.createServer(app);
const bcrypt = require("bcryptjs");
const { Op } = require("sequelize");
const { User, Comment, Post, Game } = require("./models");
const { requireLogin, logout } = require("./auth");
const UPLOAD_URL = "/uploads/media/";
const multer = require("multer");
const upload = multer({ dest: "public" + UPLOAD_URL });
const Sequelize = require("sequelize");
const { layout } = require("./utils");
const { homeRouter,userRouter, memberRouter } = require("./routers");
const logger = morgan("dev");
const hostname = "0.0.0.0";
const port = 3500;
//Register Middleware
app.use(logger);
app.use(helmet());
app.use(
express.urlencoded({
extended: true,
})
);
app.use(express.static("public"));
app.use(
session({
store: new FileStore(), // no options for now
secret: process.env.SESSION_SECRET,
saveUninitialized: false,
resave: true,
rolling: true,
cookie: {
maxAge: 1000 * 60 * 60 * 24 * 7,
},
})
);
app.engine("html", es6Renderer);
app.set("views", "templates");
app.set("view engine", "html");
const {
errorController
}= require('./controllers')
app.use('/', homeRouter) //Has all home items
app.use('/user', userRouter) // Has SignUp, LogIn, and logOut
app.use("/members", memberRouter)
//catch all if website doesn't
app.get("*", (req, res) => {
res.status(404).send("<h1>Page not found</h1>");
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}`);
});