-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
34 lines (26 loc) · 674 Bytes
/
Copy pathtest.js
File metadata and controls
34 lines (26 loc) · 674 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
// @ts-check
const express = require('express');
const session = require('express-session');
const postgres = require('postgres');
const PostgresStore = require('.')(session);
const app = express();
app.use(session({
secret: 'wtf',
resave: false,
saveUninitialized: false,
cookie: {
maxAge: 60000
},
store: new PostgresStore({
postgres: postgres(),
createTableIfMissing: true,
pruneSessionInterval: 10
})
}));
app.get('/hello', (req, res) => res.status(200).json({
session: req.session
}));
app.post('/hello', express.json(), (req, res) => res.status(200).json({
session: Object.assign(req.session, req.body)
}));
app.listen(3000);