-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.js
59 lines (50 loc) · 1.59 KB
/
app.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
require('dotenv').config();
const path = require("path");
const helmet = require('helmet');
const express = require("express");
const compression = require('compression');
const app = express();
const connectDB = require("./config/db");
const schedule = require('./utils/schedule');
const indexRoute = require('./routes/index');
const homeRoute = require("./routes/home");
const playRoute = require("./routes/play");
const searchRoute = require("./routes/search");
const apiRoute = require("./routes/api");
const authRoute = require('./routes/auth');
const favRoute = require('./routes/fav');
const maintainanceRoute = require('./routes/maintainance');
const editProfileRoute = require('./routes/editProfile');
const resetRoute = require('./routes/reset');
//Connecting To Database
connectDB();
//Running Scheduler
schedule();
//View engine setup
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "ejs");
//Encoding
app.use(compression());
app.use(helmet({
contentSecurityPolicy: false
}));
app.use('/favicon.ico', express.static('./public/imgs/favicon.ico'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, "public")));
//Routes
app.use("/",indexRoute);
app.use("/home", homeRoute);
app.use("/movie", playRoute);
app.use("/search",searchRoute);
app.use("/edit-profile",editProfileRoute)
app.use("/maintainance",maintainanceRoute);
app.use('/reset',resetRoute);
app.use(favRoute);
app.use(authRoute);
//API Route
app.use("/api",apiRoute);
app.use((req,res)=>{
res.status(404).render('404')
})
module.exports = app;