-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
40 lines (35 loc) · 1.03 KB
/
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
35
36
37
38
39
40
require("./models/db.js");
const express = require("express");
const path = require("path");
const employeeController = require("./controllers/employeeController");
// import package
const expHbs = require("express-handlebars");
// used to allow Insecure Prototype Access
const Handlebars = require("handlebars");
const {
allowInsecurePrototypeAccess,
} = require("@handlebars/allow-prototype-access");
// import package parser
const bodyParser = require("body-parser");
var app = express();
//add parameteres to req with bodyparser
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
//init layouts
app.set("views", path.join(__dirname + "/views/"));
app.engine(
"hbs",
expHbs({
extname: "hbs",
defaultLayout: "mainlayout",
layoutsDir: __dirname + "/views/layouts/",
handlebars: allowInsecurePrototypeAccess(Handlebars),
})
);
app.set(" views engine", "hbs");
//port of server
app.listen(3011, () => {
console.log("server started");
});
//call controller
app.use("/employee", employeeController);