Skip to content

Commit

Permalink
Add express-session, now required
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Oct 20, 2022
1 parent 7040af0 commit 589cb97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
"avvio": "^8.0.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"connect-redis": "^6.1.3",
"cookie": "^0.5.0",
"cookie-parser": "^1.4.4",
"cors": "^2.8.5",
"escape-string-regexp": "^4.0.0",
"explain-error": "^1.0.4",
"express": "^4.17.1",
"express-session": "^1.17.3",
"has": "^1.0.3",
"helmet": "^6.0.0",
"htmlescape": "^1.1.1",
Expand Down Expand Up @@ -73,10 +75,12 @@
"devDependencies": {
"@tsconfig/node14": "^1.0.1",
"@types/bcryptjs": "^2.4.2",
"@types/connect-redis": "^0.0.18",
"@types/cookie": "^0.5.0",
"@types/cookie-parser": "^1.4.2",
"@types/cors": "^2.8.10",
"@types/express": "^4.17.11",
"@types/express-session": "^1.17.5",
"@types/has": "^1.0.0",
"@types/htmlescape": "^1.1.1",
"@types/http-errors": "^1.8.0",
Expand Down
9 changes: 9 additions & 0 deletions src/HttpApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const { randomUUID } = require('crypto');
const express = require('express');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const session = require('express-session');
const RedisSessionStore = require('connect-redis')(session);
const cors = require('cors');
const helmet = require('helmet').default;
const http = require('http');
Expand Down Expand Up @@ -108,6 +110,13 @@ async function httpApi(uw, options) {
}))
.use(bodyParser.json())
.use(cookieParser())
.use(session({
name: 'uwsid',
store: new RedisSessionStore({
client: uw.redis,
}),
secret: options.secret.toString('hex'),
}))
.use(uw.passport.initialize())
.use(addFullUrl())
.use(attachUwaveMeta(uw.httpApi, uw))
Expand Down

0 comments on commit 589cb97

Please sign in to comment.