Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- add redis-session.ts to use connect-redis module as a middleware
  • Loading branch information
i5on9i committed Nov 2, 2020
1 parent fe5b1ae commit 9258add
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
8 changes: 7 additions & 1 deletion package.json
Expand Up @@ -15,23 +15,29 @@
},
"dependencies": {
"connect-flash": "^0.1.1",
"connect-redis": "^5.0.0",
"dust-makara-helpers": "^4.2.0",
"express": "^4.17.1",
"express-session": "^1.17.1",
"knex": "^0.21.8",
"kraken-js": "^2.3.0",
"makara": "^2.1.0",
"mysql": "^2.18.1",
"objection": "^2.2.3",
"passport": "^0.4.1",
"passport-local": "^1.0.0"
"passport-local": "^1.0.0",
"redis": "^3.0.2"
},
"devDependencies": {
"@types/connect-flash": "0.0.35",
"@types/connect-redis": "0.0.14",
"@types/express": "^4.17.8",
"@types/express-session": "^1.17.0",
"@types/kraken-js": "^2.2.4",
"@types/mocha": "^8.0.3",
"@types/passport": "^1.0.4",
"@types/passport-local": "^1.0.33",
"@types/redis": "^2.8.28",
"@types/supertest": "^2.0.10",
"chai": "^4.2.0",
"copyfiles": "^2.4.0",
Expand Down
24 changes: 23 additions & 1 deletion src/ts/config/config.json
Expand Up @@ -56,7 +56,29 @@
// ]
// }
// },

"session": {
"module": {
"name": "path:./lib/middleware/redis-session",
"method": "conRedis",
"arguments": [
{
"key": "",
"secret": "80bc6d67f80813ccc78ff77adf0eefcafa7eeef6",
"cookie": {
"path": "/",
"httpOnly": true,
"maxAge": null
},
"proxy": null
},
{
"host": "192.168.0.26",
"port": 6379
}
]
}

},

"static": {
"module": {
Expand Down
13 changes: 13 additions & 0 deletions src/ts/lib/middleware/redis-session.ts
@@ -0,0 +1,13 @@

import redis from 'redis';
import session from 'express-session';
import credis from 'connect-redis';

const RedisStore = credis(session);

export function conRedis(settings: any, redisConfig: any) {
const redisClient = redis.createClient(redisConfig)
settings.store = new RedisStore({ client: redisClient });

return session(settings);
};

0 comments on commit 9258add

Please sign in to comment.