File tree 2 files changed +6
-10
lines changed
2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -39,9 +39,7 @@ app.use(session({
39
39
store: new RedisStore ({
40
40
prefix: ' mysess' ,
41
41
clientOptions: {
42
- host: ' myhost.redis' ,
43
- port: 1234 ,
44
- ...
42
+ url: ' redis://username:password@host:port/' ,
45
43
},
46
44
}),
47
45
cookieName: ' MY_SESSION' ,
@@ -60,12 +58,9 @@ re-used by a different part of your application:
60
58
` ` ` typescript
61
59
import session from ' @curveball/session' ;
62
60
import RedisStore from ' @curveball/session-redis' ;
63
- import { RedisClient } from ' redis' ;
61
+ import { createClient } from ' redis' ;
64
62
65
- const redis = new RedisClient ({
66
- host: ' myhost.redis' ,
67
- port: 1234 ,
68
- });
63
+ const redis = createClient (' redis://localhost' );
69
64
70
65
app .use (session ({
71
66
store: new RedisStore ({
@@ -77,4 +72,4 @@ app.use(session({
77
72
});
78
73
` ` `
79
74
80
- [1]: https://github.com/NodeRedis/node_redis#options-object-properties
75
+ [1]: https://github.com/redis/node-redis/blob/master/docs/client-configuration.md
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ type SessionValues = Record<string, any>;
8
8
type RedisClient = ReturnType < typeof createClient > ;
9
9
10
10
type RedisOpts = {
11
- clientOptions : RedisClientOptions ,
11
+ clientOptions : RedisClientOptions ;
12
12
prefix : string ;
13
13
} | {
14
14
client : RedisClient ;
@@ -40,6 +40,7 @@ export default class RedisStore implements SessionStore {
40
40
this . client = this . opts . client ;
41
41
} else {
42
42
this . client = createClient ( this . opts . clientOptions ) ;
43
+ this . client . connect ( ) ;
43
44
}
44
45
}
45
46
You can’t perform that action at this time.
0 commit comments