-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
37 lines (32 loc) · 926 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
37
require("./database/connection");
const express = require("express");
const app = express();
const usersRoutes = require("./routes/user");
const cookieParser = require("cookie-parser");
const sessions = require("express-session");
app.use(express.static("public"));
app.set("view engine", "ejs");
app.use(express.json());
app.use(
sessions({
secret: "donttellanyone",
saveUninitialized: true,
cookie: { maxAge: 1000 * 60 * 60 * 24 },
resave: false,
})
);
app.use(cookieParser());
// parse incoming post request's body
app.use(express.urlencoded({ extended: false }));
app.use("/user", usersRoutes);
app.get("/", function (req, res) {
res.render("pages/index");
});
app.get("/design", (req, res) => {
res.render("pages/design");
});
app.use((req, res) => {
res.render("pages/templates/404");
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`Listening on ${PORT}`));