-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
59 lines (50 loc) · 1.29 KB
/
server.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
//Installed Modules
const express = require("express");
const mongoose = require("mongoose");
const cookie = require("cookie-parser");
const cors = require("cors");
const path = require("path");
const { productionURI } = require("./config.js");
//calling express...
const app = express();
app.use(express.json());
app.use(
express.urlencoded({
extended: false,
})
);
//middlewares
app.use(cors());
app.use(cookie());
app.use(express.static("./frontend/css"));
app.use(express.static("./frontend/images"));
app.use(express.static("./frontend/js"));
//connect to db
/*mongoose.connect(
productionURI,
{
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true
},
(err) => {
if (err) {
console.log(`Server error : ${err}`);
} else {
}
}
);*/
//Import Routes
const webRoutes = require("./routes/page");
const authRoute = require("./routes/user");
const admin = require("./routes/admin");
const fileUpload = require("./middleware/file-upload");
const { isNotLoggedIn } = require("./middleware/auth");
//Route Middlewares
app.use("/user", isNotLoggedIn, authRoute);
app.use("/admin", admin);
app.use("/", webRoutes);
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server is up, and connected to filmhub on port ${PORT}`);
});