-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (26 loc) · 961 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
const path = require("path");
const express = require("express");
const bodyParser = require("body-parser");
// const expressHbs = require("express-handlebars");
const app = express();
// app.engine(
// "hbs",
// expressHbs({
// layoutsDir: "views/layouts/",
// defaultLayout: "main-layout",
// extname: "hbs",
// })
// );
app.set("view engine", "ejs"); //using handlebars engine as hbs
app.set("views", "views"); //where to find those templetes
const adminData = require("./routes/admin");
const shopRoutes = require("./routes/shop");
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, "public")));
app.use("/admin", adminData.routes); // go to /admin/add-product
app.use(shopRoutes);
app.use((req, res, next) => {
// res.status(404).sendFile(path.join(__dirname, 'views', '404.html'));
res.status(404).render("404", { pageTitle: "Page Not Found" , path: ''});
});
app.listen(3000);