Skip to content

Commit 62305ed

Browse files
committed
Fix documentation
1 parent 573b50f commit 62305ed

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

README.md

+4-9
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ app.use(session({
3939
store: new RedisStore({
4040
prefix: 'mysess',
4141
clientOptions: {
42-
host: 'myhost.redis',
43-
port: 1234,
44-
...
42+
url: 'redis://username:password@host:port/',
4543
},
4644
}),
4745
cookieName: 'MY_SESSION',
@@ -60,12 +58,9 @@ re-used by a different part of your application:
6058
```typescript
6159
import session from '@curveball/session';
6260
import RedisStore from '@curveball/session-redis';
63-
import { RedisClient } from 'redis';
61+
import { createClient } from 'redis';
6462

65-
const redis = new RedisClient({
66-
host: 'myhost.redis',
67-
port: 1234,
68-
});
63+
const redis = createClient('redis://localhost');
6964

7065
app.use(session({
7166
store: new RedisStore({
@@ -77,4 +72,4 @@ app.use(session({
7772
});
7873
```
7974
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

src/redis-store.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type SessionValues = Record<string, any>;
88
type RedisClient = ReturnType<typeof createClient>;
99

1010
type RedisOpts = {
11-
clientOptions: RedisClientOptions,
11+
clientOptions: RedisClientOptions;
1212
prefix: string;
1313
} | {
1414
client: RedisClient;
@@ -40,6 +40,7 @@ export default class RedisStore implements SessionStore {
4040
this.client = this.opts.client;
4141
} else {
4242
this.client = createClient(this.opts.clientOptions);
43+
this.client.connect();
4344
}
4445
}
4546

0 commit comments

Comments
 (0)