Skip to content

Commit

Permalink
Fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
evert committed Nov 9, 2023
1 parent 573b50f commit 62305ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ app.use(session({
store: new RedisStore({
prefix: 'mysess',
clientOptions: {
host: 'myhost.redis',
port: 1234,
...
url: 'redis://username:password@host:port/',
},
}),
cookieName: 'MY_SESSION',
Expand All @@ -60,12 +58,9 @@ re-used by a different part of your application:
```typescript
import session from '@curveball/session';
import RedisStore from '@curveball/session-redis';
import { RedisClient } from 'redis';
import { createClient } from 'redis';

const redis = new RedisClient({
host: 'myhost.redis',
port: 1234,
});
const redis = createClient('redis://localhost');

app.use(session({
store: new RedisStore({
Expand All @@ -77,4 +72,4 @@ app.use(session({
});
```
[1]: https://github.com/NodeRedis/node_redis#options-object-properties
[1]: https://github.com/redis/node-redis/blob/master/docs/client-configuration.md
3 changes: 2 additions & 1 deletion src/redis-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type SessionValues = Record<string, any>;
type RedisClient = ReturnType<typeof createClient>;

type RedisOpts = {
clientOptions: RedisClientOptions,
clientOptions: RedisClientOptions;
prefix: string;
} | {
client: RedisClient;
Expand Down Expand Up @@ -40,6 +40,7 @@ export default class RedisStore implements SessionStore {
this.client = this.opts.client;
} else {
this.client = createClient(this.opts.clientOptions);
this.client.connect();
}
}

Expand Down

0 comments on commit 62305ed

Please sign in to comment.