-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
32 lines (26 loc) · 880 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
const express = require("express");
const mongoose = require("mongoose");
const expressHbs = require("express-handlebars");
const hbs = require("hbs");
const app = express();
app.use(express.static("public"));
const productRouter = require("./routes/productRouter.js");
app.set("view engine", "hbs");
app.set("view options", { layout: "layouts/layout" });
hbs.registerPartials(__dirname + "/views/partials");
app.use(express.urlencoded({ extended: false }));
app.use("/products", productRouter);
app.use("/", productRouter);
app.use(function (request, response, next) {
response.status(404).send("Not found");
});
mongoose.connect(
"mongodb://127.0.0.1:27017/usersdb",
{ useUnifiedTopology: true },
function (err) {
if (err) return console.log(err);
app.listen(3000, function () {
console.log("Server awaits for connection at http://localhost:3000");
});
}
);