-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
58 lines (41 loc) · 1.37 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const express = require('express');
const bodyParser = require('body-parser');
//const cookieSession = require('cookie-session');
//const cookieParser = require('cookie-parser');
const session = require('express-session')
const urllib = require('url');
const path = require('path');
const crypto = require('crypto');
const config = require('./config.json');
const defaultroutes = require('./routes/default');
const webuathnauth = require('./routes/webauthn.js');
const admin = require('./routes/admin.js');
const app = express();
// view engine setup
app.engine('pug', require('pug').__express)
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
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())
*/
app.use(session({
secret: crypto.randomBytes(32).toString('hex'),
resave: false,
saveUninitialized: true
}))
app.use('/', defaultroutes)
app.use('/webauthn', webuathnauth)
app.use('/admin', admin)
/* ----- serve static ----- */
app.use(express.static(path.join(__dirname, 'static')));
const port = config.port || 3000;
app.listen(port);
console.log(`Started app on port ${port}`);
module.exports = app;