-
Notifications
You must be signed in to change notification settings - Fork 156
/
app.js
41 lines (32 loc) · 1.15 KB
/
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
const express = require('express');
const bodyParser = require('body-parser');
const cookieSession = require('cookie-session');
const cookieParser = require('cookie-parser');
const urllib = require('url');
const path = require('path');
const crypto = require('crypto');
const x509 = require('@fidm/x509');
const iso_3166_1 = require('iso-3166-1');
const config = require('./config.json');
const defaultroutes = require('./routes/default');
const passwordauth = require('./routes/password');
const webuathnauth = require('./routes/webauthn.js');
const app = express();
app.use(bodyParser.json());
/* ----- session ----- */
app.use(cookieSession({
name: 'session',
keys: [crypto.randomBytes(32).toString('hex')],
// Cookie Options
maxAge: 24 * 60 * 60 * 1000 // 24 hours
}))
app.use(cookieParser())
/* ----- serve static ----- */
app.use(express.static(path.join(__dirname, 'static')));
app.use('/', defaultroutes)
app.use('/password', passwordauth)
app.use('/webauthn', webuathnauth)
const port = config.port || 3000;
app.listen(port);
console.log(`Started app on port ${port}`);
module.exports = app;