-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
30 lines (27 loc) · 1.04 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
require('./models/db');
const Handlebars = require('handlebars');
const express = require('express');
const dotenv = require('dotenv');
const path = require('path');
const exphbs = require('express-handlebars');
const bodyparser = require('body-parser');
const { allowInsecurePrototypeAccess } = require('@handlebars/allow-prototype-access');
const employeeController = require('./controllers/employeeController');
dotenv.config();
var app = express();
app.use(express.static("public"));
app.use(bodyparser.urlencoded({
extended: true
}));
app.use(bodyparser.json());
app.set('views', path.join(__dirname, '/views/'));
app.engine('hbs', exphbs({ extname: 'hbs', defaultLayout: 'mainLayout', layoutsDir: __dirname + '/views/layouts/',handlebars: allowInsecurePrototypeAccess(Handlebars) }));
app.set('view engine', 'hbs');
app.get("/", function(req, res){
res.redirect("employee")
})
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`Express server started at port : ${port}`);
});
app.use('/employee', employeeController);