Gathering detailed insights and metrics for connect-redis
Gathering detailed insights and metrics for connect-redis
Gathering detailed insights and metrics for connect-redis
Gathering detailed insights and metrics for connect-redis
npm install connect-redis
97.3
Supply Chain
99.1
Quality
80.1
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
2,801 Stars
335 Commits
342 Forks
57 Watching
3 Branches
66 Contributors
Updated on 27 Nov 2024
TypeScript (94.02%)
JavaScript (5.98%)
Cumulative downloads
Total Downloads
Last day
-7.8%
110,595
Compared to previous day
Last week
-4.1%
608,230
Compared to previous week
Last month
6.5%
2,714,144
Compared to previous month
Last year
17.4%
25,405,864
Compared to previous year
1
connect-redis provides Redis session storage for Express.
connect-redis requires express-session
to installed and one of the following compatible Redis clients:
Install with redis
:
1npm install redis connect-redis express-session
Install with ioredis
:
1npm install ioredis connect-redis express-session
connect-redis supports both CommonJS (require
) and ESM (import
) modules.
Import using ESM/Typescript:
1import {RedisStore} from "connect-redis"
Require using CommonJS:
1const {RedisStore} = require("connect-redis")
Full setup using redis
package:
1import {RedisStore} from "connect-redis" 2import session from "express-session" 3import {createClient} from "redis" 4 5// Initialize client. 6let redisClient = createClient() 7redisClient.connect().catch(console.error) 8 9// Initialize store. 10let redisStore = new RedisStore({ 11 client: redisClient, 12 prefix: "myapp:", 13}) 14 15// Initialize session storage. 16app.use( 17 session({ 18 store: redisStore, 19 resave: false, // required: force lightweight session keep alive (touch) 20 saveUninitialized: false, // recommended: only save session when data exists 21 secret: "keyboard cat", 22 }), 23)
An instance of redis
or ioredis
.
Key prefix in Redis (default: sess:
).
Note: This prefix appends to whatever prefix you may have set on the client
itself.
Note: You may need unique prefixes for different applications sharing the same Redis instance. This limits bulk commands exposed in express-session
(like length
, all
, keys
, and clear
) to a single application's data.
If the session cookie has a expires
date, connect-redis
will use it as the TTL.
Otherwise, it will expire the session using the ttl
option (default: 86400
seconds or one day).
1interface RedisStoreOptions { 2 ... 3 ttl?: number | {(sess: SessionData): number} 4}
ttl
also has external callback support. You can use it for dynamic TTL generation. It has access to session
data.
Note: The TTL is reset every time a user interacts with the server. You can disable this behavior in some instances by using disableTouch
.
Note: express-session
does not update expires
until the end of the request life cycle. Calling session.save()
manually beforehand will have the previous value.
Disables resetting the TTL when using touch
(default: false
)
The express-session
package uses touch
to signal to the store that the user has interacted with the session but hasn't changed anything in its data. Typically, this helps keep the users session alive if session changes are infrequent but you may want to disable it to cut down the extra calls or to prevent users from keeping sessions open too long. Also consider enabling if you store a lot of data on the session.
Ref: https://github.com/expressjs/session#storetouchsid-session-callback
Disables key expiration completely (default: false
)
This option disables key expiration requiring the user to manually manage key cleanup outside of connect-redis
. Only use if you know what you are doing and have an exceptional case where you need to manage your own expiration in Redis.
Note: This has no effect on express-session
setting cookie expiration.
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.
1interface Serializer { 2 parse(string): object | Promise<object> 3 stringify(object): string 4}
Value used for count parameter in Redis SCAN
command. Used for ids()
and all()
methods (default: 100
).
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 11/30 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More