Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface NormalizedRedisClient {
}

interface Serializer {
parse(s: string): SessionData
parse(s: string): SessionData | Promise<SessionData>
stringify(s: SessionData): string
}

Expand Down Expand Up @@ -83,7 +83,7 @@ class RedisStore extends Store {
try {
let data = await this.client.get(key)
if (!data) return cb()
return cb(null, this.serializer.parse(data))
return cb(null, await this.serializer.parse(data))
} catch (err) {
return cb(err)
}
Expand Down
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ This option disables key expiration requiring the user to manually manage key cl

Provide a custom encoder/decoder to use when storing and retrieving session data from Redis (default: `JSON.parse` and `JSON.stringify`).

Optionally `parse` method can be async if need be.

```ts
interface Serializer {
parse(string): object
parse(string): object | Promise<object>
stringify(object): string
}
```
Expand Down