diff --git a/project/server.js b/project/server.js index 2a78978b..47513018 100644 --- a/project/server.js +++ b/project/server.js @@ -4,7 +4,11 @@ const express = require('express'); const path = require('path'); const exphbs = require('express-handlebars'); const bodyparser = require('body-parser'); +//to add if on view all we can not see the data +const Handlebars = require('handlebars') +const {allowInsecurePrototypeAccess} = require('@handlebars/allow-prototype-access') +// const employeeController = require('./controllers/employeeController'); var app = express(); @@ -13,11 +17,14 @@ app.use(bodyparser.urlencoded({ })); app.use(bodyparser.json()); app.set('views', path.join(__dirname, '/views/')); -app.engine('hbs', exphbs({ extname: 'hbs', defaultLayout: 'mainLayout', layoutsDir: __dirname + '/views/layouts/' })); +//app.engine('hbs', exphbs({ extname: 'hbs', defaultLayout: 'mainLayout', layoutsDir: __dirname + '/views/layouts/' })); +//this instead previous one +app.engine('hbs', exphbs({ extname: 'hbs', handlebars: allowInsecurePrototypeAccess(Handlebars), defaultLayout: 'mainlayout', layoutsDir: __dirname + '/views/layouts/' })); + app.set('view engine', 'hbs'); app.listen(3000, () => { console.log('Express server started at port : 3000'); }); -app.use('/employee', employeeController); \ No newline at end of file +app.use('/employee', employeeController);