-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.js
59 lines (34 loc) · 1.28 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var express = require('express');
var app = express();
var fs = require('fs');
var environment = require('dotenv');
var APIS = require('./apis')(app)
app.set('trust proxy', 1) // trust first proxy
environment.config();
app.set('port', (process.env.PORT || 5000));
app.use(express.static(__dirname + '/public'));
// views is directory for all template files
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
// // Allow only https connections
// // Comment this function if you are using on localhost
app.get('*', function(req, res, next) {
console.log(req.secure);
if(!req.secure && process.env.environment == "Production")
res.redirect('https://' + req.headers.host + req.url);
else
next();
})
// Configure Routes to all the components using their respective routers
app.use(require('./app/site/router'));
app.use(require('./app/study_material/router'));
app.use(require('./app/upload/router'));
app.use(require('./app/feedback/router'));
app.use(require('./app/admin/router'))
// For increasing time on the site, to be implemented in future releases
app.get('/driver', function(request, response) {
response.render('pages/driver');
});
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});