-
Notifications
You must be signed in to change notification settings - Fork 338
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (33 loc) · 771 Bytes
/
index.js
File metadata and controls
39 lines (33 loc) · 771 Bytes
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
const express = require('express')
const session = require('express-session')
const MongoStore = require('connect-mongo')
const { getMongoConfig } = require('./shared/mongo-config')
const app = express()
const port = 3000
const {
mongoUrl,
mongoOptions,
dbName,
sessionSecret,
cryptoSecret
} = getMongoConfig()
const store = MongoStore.create({
mongoUrl,
dbName,
mongoOptions,
stringify: false,
...(cryptoSecret ? { crypto: { secret: cryptoSecret } } : {})
})
app.use(session({
secret: sessionSecret,
resave: false,
saveUninitialized: false,
store
}));
app.get('/', (req, res) => {
req.session.foo = 'test-id'
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})