Gathering detailed insights and metrics for @yir/koa-redis
Gathering detailed insights and metrics for @yir/koa-redis
Gathering detailed insights and metrics for @yir/koa-redis
Gathering detailed insights and metrics for @yir/koa-redis
npm install @yir/koa-redis
Typescript
Module System
Min. Node Version
Node Version
NPM Version
66.3
Supply Chain
98.7
Quality
74.3
Maintenance
100
Vulnerability
98.9
License
JavaScript (100%)
Total Downloads
637
Last Day
1
Last Week
5
Last Month
11
Last Year
93
MIT License
106 Commits
1 Watchers
8 Branches
1 Contributors
Updated on Mar 31, 2019
Minified
Minified + Gzipped
Latest Version
0.0.2
Package Id
@yir/koa-redis@0.0.2
Unpacked Size
11.83 kB
Size
4.35 kB
File Count
5
NPM Version
6.4.1
Node Version
10.15.3
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
0%
5
Compared to previous week
Last Month
10%
11
Compared to previous month
Last Year
5.7%
93
Compared to previous year
Copy from koa-redis.
Redis storage for koa session middleware/cache.
Support redis cluster.
koa-redis
works with koa-session-minimal (a generic session middleware for koa) or koa-session.
koa-redis
use ioredis to connect redis. so the config will support ioredis
options.
1var session = require('koa-session-minimal'); 2var redisStore = require('@yir/koa-redis'); 3var koa = require('koa'); 4 5var app = koa(); 6app.use(session({ 7 key:'USER_SID', 8 store:redisStore({config: 'redis://:123456@127.0.0.1:6379/1'}) 9 /*store:redisStore({config: { 10 port: 6379, // Redis port 11 host: '127.0.0.1', // Redis host 12 family: 4, // 4 (IPv4) or 6 (IPv6) 13 password: '123456', 14 db: 1 15 }})*/ 16})); 17 18app.use(function *() { 19 switch (this.path) { 20 case '/get': 21 get.call(this); 22 break; 23 case '/remove': 24 remove.call(this); 25 break; 26 case '/regenerate': 27 yield regenerate.call(this); 28 break; 29 } 30}); 31 32function get() { 33 var session = this.session; 34 session.count = session.count || 0; 35 session.count++; 36 this.body = session.count; 37} 38 39function remove() { 40 this.session = null; 41 this.body = 0; 42} 43 44function *regenerate() { 45 get.call(this); 46 yield this.regenerateSession(); 47 get.call(this); 48} 49 50app.listen(8080);
For more examples, please see the examples folder of koa-generic-session
.
ioredis
options - Useful things include url
, host
, port
, and path
to the server. Defaults to 127.0.0.1:6379
db
(number) - will run client.select(db)
after connectionclient
(object) - supply your own client, all other options are ignored unless duplicate
is also suppliedduplicate
(boolean) - When true, it will run client.duplicate(options)
on the supplied client
and use all other options supplied. This is useful if you want to select a different DB for sessions but also want to base from the same client object.serialize
- Used to serialize the data that is saved into the store.unserialize
- Used to unserialize the data that is fetched from the store.See the ioredis
docs for more info.
These are some the functions that koa-session-minimal
/ koa-session
uses that you can use manually. You will need to initialize differently than the example above:
1var session = require('koa-session-minimal'); 2var redisStore = require('@yir/koa-redis')({ 3 // Options specified here 4}); 5var app = require('koa')(); 6 7app.keys = ['keys', 'keykeys']; 8app.use(session({ 9 key:'keys', 10 store: redisStore 11}));
Initialize the Redis connection with the optionally provided options (see above). The variable session
below references this.
1var session = require('@yir/koa-redis')({ 2 // Options specified here 3}); 4session.client.set(sid, sess, ttl);
Generator that gets a session by ID. Returns parsed JSON is exists, null
if it does not exist, and nothing upon error.
Generator that sets a JSON session by ID with an optional time-to-live (ttl) in milliseconds. Yields node_redis
's client.set()
or client.setex()
.
Generator that destroys a session (removes it from Redis) by ID. Tields node_redis
's client.del()
.
Generator that stops a Redis session after everything in the queue has completed. Yields node_redis
's client.quit()
.
Alias to session.quit()
. It is not safe to use the real end function, as it cuts off the queue.
Boolean giving the connection status updated using client.connected
after any of the events above is fired.
Direct access to the ioredis
client object.
localhost:6379
. You can use redis-windows
if you are on Windows or just want a quick VM-based server.npm i
in it (Windows should work fine).DEBUG
flag.npm test
to run the tests and generate coverage. To run the tests without generating coverage, run npm run-script test-only
.See the contributing tab
(The MIT License)
Copyright (c) 2015 dead-horse and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-06-23
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