-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (30 loc) · 978 Bytes
/
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
const express = require("express");
const apiRoutes = require("./routes/apiRoutes");
const pageRoutes = require("./routes/pageRoutes");
const partialRoutes = require("./routes/partialRoutes");
const { config } = require("./config");
const cookieParser = require("cookie-parser");
const hbs = require("express-handlebars");
const helpers = require("./helpers/helpers");
const PORT = config.port || 8080;
const app = express();
app.use(express.static("public"));
app.use(cookieParser());
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.engine(
"handlebars",
hbs({
extname: "handlebars",
defaultLayout: "main",
helpers: helpers,
layoutsDir: __dirname + "/views/layouts/",
partialsDir: __dirname + "/views/partials/",
})
);
app.set("view engine", "handlebars");
app.use("/api", apiRoutes);
app.use("/modal", partialRoutes);
app.use("/", pageRoutes);
app.listen(PORT);
console.log(`Listening on http://localhost:${PORT}`);