-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
36 lines (26 loc) · 942 Bytes
/
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
const express = require('express');
const mongoose = require("mongoose");
const homeRoutes = require("./routes/homeRoutes.js");
const dashboardRoutes = require("./routes/dashboardRoutes.js");
const cookieParser = require("cookie-parser");
app = express();
app.set('view engine', 'ejs');
app.use(express.static('public'));
app.use(express.urlencoded({ extended: true }));
app.use(cookieParser());
const dburi = process.env.MONGODB_URI || "------------------------DBURL"------------------------";
const port = process.env.PORT || 3300;
mongoose.connect(dburi, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true })
.then((res) => {
app.listen(port);
console.log(`Listening on ${port}`);
})
.catch((err) => console.log(err))
//Routes for home pages
app.use(homeRoutes);
// User dashboard
app.use(dashboardRoutes);
//404 page
app.use((req, res) => {
res.status(404).render("404");
})