connect-redis
Advanced tools
Comparing version 7.1.1 to 8.0.0-rc.1
@@ -1,2 +0,1 @@ | ||
import test from "blue-tape" | ||
import {Cookie} from "express-session" | ||
@@ -6,3 +5,4 @@ import {Redis} from "ioredis" | ||
import {createClient} from "redis" | ||
import RedisStore from "./" | ||
import {expect, test} from "vitest" | ||
import {RedisStore} from "./" | ||
import * as redisSrv from "./testdata/server" | ||
@@ -14,3 +14,3 @@ | ||
test("defaults", async (t) => { | ||
test("defaults", async () => { | ||
let client = createClient({url: `redis://localhost:${redisSrv.port}`}) | ||
@@ -21,24 +21,24 @@ await client.connect() | ||
t.ok(store.client, "stores client") | ||
t.equal(store.prefix, "sess:", "defaults to sess:") | ||
t.equal(store.ttl, 86400, "defaults to one day") | ||
t.equal(store.scanCount, 100, "defaults SCAN count to 100") | ||
t.equal(store.serializer, JSON, "defaults to JSON serialization") | ||
t.equal(store.disableTouch, false, "defaults to having `touch` enabled") | ||
t.equal(store.disableTTL, false, "defaults to having `ttl` enabled") | ||
expect(store.client).toBeDefined() | ||
expect(store.prefix).toBe("sess:") | ||
expect(store.ttl).toBe(86400) // defaults to one day | ||
expect(store.scanCount).toBe(100) | ||
expect(store.serializer).toBe(JSON) | ||
expect(store.disableTouch).toBe(false) | ||
expect(store.disableTTL).toBe(false) | ||
await client.disconnect() | ||
}) | ||
test("redis", async (t) => { | ||
test("redis", async () => { | ||
let client = createClient({url: `redis://localhost:${redisSrv.port}`}) | ||
await client.connect() | ||
let store = new RedisStore({client}) | ||
await lifecycleTest(store, client, t) | ||
await lifecycleTest(store, client) | ||
await client.disconnect() | ||
}) | ||
test("ioredis", async (t) => { | ||
test("ioredis", async () => { | ||
let client = new Redis(`redis://localhost:${redisSrv.port}`) | ||
let store = new RedisStore({client}) | ||
await lifecycleTest(store, client, t) | ||
await lifecycleTest(store, client) | ||
client.disconnect() | ||
@@ -49,7 +49,3 @@ }) | ||
async function lifecycleTest( | ||
store: RedisStore, | ||
client: any, | ||
t: test.Test, | ||
): Promise<void> { | ||
async function lifecycleTest(store: RedisStore, client: any): Promise<void> { | ||
const P = (f: any) => promisify(f).bind(store) | ||
@@ -62,6 +58,6 @@ let res = await P(store.clear)() | ||
res = await P(store.get)("123") | ||
t.same(res, sess, "store.get") | ||
expect(res).toEqual(sess) | ||
let ttl = await client.ttl("sess:123") | ||
t.ok(ttl >= 86399, "check one day ttl") | ||
expect(ttl).toBeGreaterThanOrEqual(86399) | ||
@@ -72,3 +68,3 @@ ttl = 60 | ||
ttl = await client.ttl("sess:456") | ||
t.ok(ttl <= 60, "check expires ttl") | ||
expect(ttl).toBeLessThanOrEqual(60) | ||
@@ -79,25 +75,21 @@ ttl = 90 | ||
ttl = await client.ttl("sess:456") | ||
t.ok(ttl > 60, "check expires ttl touch") | ||
expect(ttl).toBeGreaterThan(60) | ||
res = await P(store.length)() | ||
t.equal(res, 2, "stored two keys length") | ||
expect(res).toBe(2) // stored two keys length | ||
res = await P(store.ids)() | ||
res.sort() | ||
t.same(res, ["123", "456"], "stored two keys ids") | ||
expect(res).toEqual(["123", "456"]) | ||
res = await P(store.all)() | ||
res.sort((a: any, b: any) => (a.id > b.id ? 1 : -1)) | ||
t.same( | ||
res, | ||
[ | ||
{id: "123", foo: "bar"}, | ||
{id: "456", cookie: {expires}}, | ||
], | ||
"stored two keys data", | ||
) | ||
expect(res).toEqual([ | ||
{id: "123", foo: "bar"}, | ||
{id: "456", cookie: {expires}}, | ||
]) | ||
await P(store.destroy)("456") | ||
res = await P(store.length)() | ||
t.equal(res, 1, "one key remains") | ||
expect(res).toBe(1) // one key remains | ||
@@ -107,3 +99,3 @@ res = await P(store.clear)() | ||
res = await P(store.length)() | ||
t.equal(res, 0, "no keys remain") | ||
expect(res).toBe(0) // no keys remain | ||
@@ -114,7 +106,7 @@ let count = 1000 | ||
res = await P(store.length)() | ||
t.equal(res, count, "bulk count") | ||
expect(res).toBe(count) | ||
await P(store.clear)() | ||
res = await P(store.length)() | ||
t.equal(res, 0, "bulk clear") | ||
expect(res).toBe(0) | ||
@@ -125,3 +117,3 @@ expires = new Date(Date.now() + ttl * 1000).toISOString() // expires in the future | ||
res = await P(store.length)() | ||
t.equal(res, 1, "one key exists (session 789)") | ||
expect(res).toBe(1) | ||
@@ -132,3 +124,3 @@ expires = new Date(Date.now() - ttl * 1000).toISOString() // expires in the past | ||
res = await P(store.length)() | ||
t.equal(res, 0, "no key remains and that includes session 789") | ||
expect(res).toBe(0) // no key remains and that includes session 789 | ||
} | ||
@@ -135,0 +127,0 @@ |
@@ -29,3 +29,3 @@ import {SessionData, Store} from "express-session" | ||
class RedisStore extends Store { | ||
export class RedisStore extends Store { | ||
client: NormalizedRedisClient | ||
@@ -208,3 +208,1 @@ prefix: string | ||
} | ||
export default RedisStore |
{ | ||
"name": "connect-redis", | ||
"description": "Redis session store for Connect", | ||
"version": "7.1.1", | ||
"version": "8.0.0-rc.1", | ||
"author": "TJ Holowaychuk <tj@vision-media.ca>", | ||
@@ -10,16 +10,17 @@ "contributors": [ | ||
"license": "MIT", | ||
"main": "./dist/esm/index.js", | ||
"type": "module", | ||
"main": "./dist/connect-redis.cjs", | ||
"module": "./dist/connect-redis.js", | ||
"types": "./dist/connect-redis.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./dist/esm/index.js", | ||
"require": "./dist/cjs/index.js", | ||
"default": "./dist/esm/index.js" | ||
"import": "./dist/connect-redis.js", | ||
"require": "./dist/connect-redis.cjs" | ||
} | ||
}, | ||
"types": "./dist/esm/index.d.ts", | ||
"scripts": { | ||
"prepublishOnly": "rm -rf dist && tsc & tsc --project tsconfig.esm.json && echo '{\"type\":\"module\"}' > dist/esm/package.json", | ||
"build": "npm run prepublishOnly", | ||
"test": "nyc ts-node node_modules/blue-tape/bin/blue-tape \"**/*_test.ts\"", | ||
"lint": "tsc --noemit && eslint --max-warnings 0 --ext ts testdata *.ts", | ||
"prepublishOnly": "vite build", | ||
"build": "vite build", | ||
"test": "vitest run --silent --coverage", | ||
"lint": "tsc --noemit && eslint --max-warnings 0 testdata *.ts", | ||
"fmt": "prettier --write .", | ||
@@ -33,18 +34,21 @@ "fmt-check": "prettier --check ." | ||
"devDependencies": { | ||
"@types/blue-tape": "^0.1.36", | ||
"@types/express-session": "^1.17.10", | ||
"@types/node": "^20.11.5", | ||
"@typescript-eslint/eslint-plugin": "^6.19.0", | ||
"@typescript-eslint/parser": "^6.19.0", | ||
"blue-tape": "^1.0.0", | ||
"eslint": "^8.56.0", | ||
"@eslint/js": "^9.15.0", | ||
"@types/eslint__js": "^8.42.3", | ||
"@types/express-session": "^1.18.1", | ||
"@types/node": "^20.17.8", | ||
"@vitest/coverage-v8": "^2.1.6", | ||
"eslint": "^9.15.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"express-session": "^1.17.3", | ||
"ioredis": "^5.3.2", | ||
"nyc": "^15.1.0", | ||
"prettier": "^3.2.4", | ||
"prettier-plugin-organize-imports": "^3.2.4", | ||
"redis": "^4.6.12", | ||
"eslint-plugin-prettier": "^5.2.1", | ||
"express-session": "^1.18.1", | ||
"ioredis": "^5.4.1", | ||
"prettier": "^3.4.1", | ||
"prettier-plugin-organize-imports": "^4.1.0", | ||
"redis": "^4.7.0", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.3.3" | ||
"typescript": "^5.7.2", | ||
"typescript-eslint": "^8.16.0", | ||
"vite": "^6.0.1", | ||
"vite-plugin-dts": "^4.3.0", | ||
"vitest": "^2.1.6" | ||
}, | ||
@@ -55,3 +59,3 @@ "peerDependencies": { | ||
"engines": { | ||
"node": ">=16" | ||
"node": ">=18" | ||
}, | ||
@@ -58,0 +62,0 @@ "bugs": { |
@@ -31,3 +31,3 @@ ![Build Status](https://github.com/tj/connect-redis/workflows/build/badge.svg?branch=master) [![npm](https://img.shields.io/npm/v/connect-redis.svg)](https://npmjs.com/package/connect-redis) [![code-style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://gitter.im/jlongster/prettier) ![Downloads](https://img.shields.io/npm/dm/connect-redis.svg) | ||
```js | ||
import RedisStore from "connect-redis" | ||
import {RedisStore} from "connect-redis" | ||
``` | ||
@@ -38,3 +38,3 @@ | ||
```js | ||
const RedisStore = require("connect-redis").default | ||
const {RedisStore} = require("connect-redis") | ||
``` | ||
@@ -47,3 +47,3 @@ | ||
```js | ||
import RedisStore from "connect-redis" | ||
import {RedisStore} from "connect-redis" | ||
import session from "express-session" | ||
@@ -50,0 +50,0 @@ import {createClient} from "redis" |
{ | ||
"compilerOptions": { | ||
"target": "es2020", | ||
"module": "commonjs", | ||
"target": "es2022", | ||
"module": "esnext", | ||
"strict": true, | ||
"isolatedModules": true, | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"moduleResolution": "node", | ||
"declaration": true, | ||
"outDir": "./dist/cjs", | ||
"esModuleInterop": true, | ||
"resolveJsonModule": true, | ||
"resolveJsonModule": true | ||
}, | ||
"exclude": ["node_modules", "dist"], | ||
"exclude": ["node_modules", "dist"] | ||
} |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Yes
30858
19
16
730
2
1