forked from rahulshukla-rs/node-express-adminlte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
41 lines (28 loc) · 1001 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
36
37
38
39
40
41
// Required System Module Files
const express = require('express')
const bodyParser = require('body-parser');
const port = process.env.PORT || 3000;
// Required Module Files
var {mongoose} = require('./db/mongoose');
const app = express()
const hbs = require('hbs')
// registerPartials for Admin
hbs.registerPartials(__dirname+'/views/partials/')
// registerPartials for User
//hbs.registerPartials(__dirname+'/views/user/partials/')
// To print Json object in HBS file using {{json this}}
hbs.registerHelper('json', function(obj) {
return JSON.stringify(obj);
});
// Set View Engine
app.set('view engine', 'hbs')
app.use(bodyParser.json()); // support json encoded bodies
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
//Public Content (css, js, images)
app.use(express.static(__dirname+'/public'))
// Route to /routes/index.js
app.use(require('./routes'))
// Start server
app.listen(port, () => {
console.log(`Server Started at port ${port}`)
})