-
Notifications
You must be signed in to change notification settings - Fork 36
/
server.js
44 lines (37 loc) · 1.1 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
// init project
const AmazonCognitoIdentity = require('amazon-cognito-identity-js');
require('dotenv');
const express = require('express');
const cookieParser = require('cookie-parser');
const hbs = require('hbs');
const authn = require('./libs/authn');
const helmet = require('helmet');
const app = express();
app.use(helmet());
app.set('view engine', 'html');
app.engine('html', hbs.__express);
app.set('views', './views');
app.use(cookieParser());
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://${req.get('host')}`);
}
req.schema = 'https';
next();
});
// http://expressjs.com/en/starter/basic-routing.html
app.get('/', (req, res) => {
res.render('webauthn.html');
});
app.get('/webauthn', (req, res) => {
res.render('webauthn.html');
});
app.use('/authn', authn);
// listen for req :)
const port = 8080;
const listener = app.listen(port, () => {
console.log('Your app is listening on port ' + listener.address().port);
});