-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (27 loc) · 791 Bytes
/
index.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
const express = require('express');
const app = express();
const hbs = require('hbs');
const routing = require('./routing');
const bodyParser = require('body-parser');
var PORT_NUMBER = process.env.PORT || 3020;
app.set('view engine','hbs');
app.set('view options', {
layout:'layouts/layout.hbs'
});
app.use(bodyParser.urlencoded({
extended:true
}));
app.use(bodyParser.json());
app.use(express.static(__dirname + '/public'));
app.enable('trust proxy')
app.use((req, res, next)=>{
if(req.protocol != 'https'){
res.redirect("https://" + req.headers.host + req.url);
}
next();
})
hbs.registerPartials(__dirname + '/views/partials');
app.use('/', routing);
app.listen(PORT_NUMBER, function(){
console.log('listening on port : ', PORT_NUMBER);
});