-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathserver.js
32 lines (27 loc) · 868 Bytes
/
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
31
32
// init project
const AmazonCognitoIdentity = require('amazon-cognito-identity-js');
const express = require('express');
const hbs = require('hbs');
const app = express();
app.set('view engine', 'html');
app.engine('html', hbs.__express);
app.set('views', './views');
app.use(express.json());
app.use(express.static('public'));
app.use((req, res, next) => {
if (req.get('x-forwarded-proto') &&
(req.get('x-forwarded-proto')).split(',')[0] !== 'https') {
return res.redirect(301, `https://${process.env.HOSTNAME}`);
}
req.schema = 'https';
next();
});
// http://expressjs.com/en/starter/basic-routing.html
app.get('/', (req, res) => {
res.render('view.html');
});
// listen for req :)
const port = 8080;
const listener = app.listen(port || process.env.PORT, () => {
console.log('Your app is listening on port ' + listener.address().port);
});