@better-auth/redis-storage 1.5.0-beta.18 → 1.5.0-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # Better Auth Redis Storage
2
+
3
+ Redis storage for [Better Auth](https://www.better-auth.com) secondary storage — use Redis for session caching and rate limiting.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @better-auth/redis-storage
9
+ ```
10
+
11
+ ## Documentation
12
+
13
+ For full documentation, visit [better-auth.com/docs/storage](https://www.better-auth.com/docs/storage).
14
+
15
+ ## License
16
+
17
+ MIT
package/package.json CHANGED
@@ -1,13 +1,28 @@
1
1
  {
2
2
  "name": "@better-auth/redis-storage",
3
- "version": "1.5.0-beta.18",
3
+ "version": "1.5.0-beta.20",
4
4
  "description": "Redis storage for Better Auth secondary storage",
5
5
  "type": "module",
6
+ "license": "MIT",
7
+ "homepage": "https://www.better-auth.com/docs/storage",
6
8
  "repository": {
7
9
  "type": "git",
8
10
  "url": "git+https://github.com/better-auth/better-auth.git",
9
11
  "directory": "packages/redis-storage"
10
12
  },
13
+ "keywords": [
14
+ "auth",
15
+ "redis",
16
+ "storage",
17
+ "typescript",
18
+ "better-auth"
19
+ ],
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
11
26
  "main": "./dist/index.mjs",
12
27
  "module": "./dist/index.mjs",
13
28
  "types": "./dist/index.d.mts",
@@ -20,20 +35,22 @@
20
35
  },
21
36
  "peerDependencies": {
22
37
  "ioredis": "^5.0.0",
23
- "@better-auth/core": "1.5.0-beta.18"
38
+ "@better-auth/core": "1.5.0-beta.20"
24
39
  },
25
40
  "devDependencies": {
26
- "@types/node": "^25.2.2",
27
- "ioredis": "^5.9.2",
41
+ "@types/node": "^25.3.2",
42
+ "ioredis": "^5.9.3",
28
43
  "tsdown": "^0.20.3",
29
44
  "typescript": "^5.9.3",
30
45
  "vitest": "^4.0.18",
31
- "@better-auth/core": "1.5.0-beta.18"
46
+ "@better-auth/core": "1.5.0-beta.20"
32
47
  },
33
48
  "scripts": {
34
49
  "build": "tsdown",
35
50
  "dev": "tsdown --watch",
36
- "test": "vitest",
37
- "typecheck": "tsc --noEmit"
51
+ "lint:package": "publint run --strict",
52
+ "lint:types": "attw --profile esm-only --pack .",
53
+ "typecheck": "tsc --noEmit",
54
+ "test": "vitest"
38
55
  }
39
56
  }
@@ -1,14 +0,0 @@
1
-
2
- > @better-auth/redis-storage@1.5.0-beta.18 build /home/runner/work/better-auth/better-auth/packages/redis-storage
3
- > tsdown
4
-
5
- ℹ tsdown v0.20.3 powered by rolldown v1.0.0-rc.3
6
- ℹ entry: src/index.ts
7
- ℹ tsconfig: tsconfig.json
8
- ℹ Build start
9
- ℹ dist/index.mjs 1.30 kB │ gzip: 0.57 kB
10
- ℹ dist/index.d.mts 1.17 kB │ gzip: 0.54 kB
11
- ℹ 2 files, total: 2.47 kB
12
- [PLUGIN_TIMINGS] Warning: Your build spent significant time in plugin `rolldown-plugin-dts:generate`. See https://rolldown.rs/options/checks#plugintimings for more details.
13
-
14
- ✔ Build complete in 8571ms
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export { type RedisStorageConfig, redisStorage } from "./redis-storage";
@@ -1,75 +0,0 @@
1
- import type { SecondaryStorage } from "@better-auth/core/db";
2
- import type Redis from "ioredis";
3
-
4
- export interface RedisStorageConfig {
5
- /**
6
- * Redis client instance from ioredis
7
- */
8
- client: Redis;
9
- /**
10
- * Optional key prefix for all keys stored in Redis
11
- * @default "better-auth:"
12
- */
13
- keyPrefix?: string | undefined;
14
- }
15
-
16
- /**
17
- * Creates a Redis secondary storage for Better Auth using ioredis.
18
- *
19
- * @example
20
- * ```ts
21
- * import { Redis } from "ioredis";
22
- * import { redisStorage } from "@better-auth/redis-storage";
23
- *
24
- * const redis = new Redis({
25
- * host: "localhost",
26
- * port: 6379,
27
- * });
28
- *
29
- * const auth = betterAuth({
30
- * secondaryStorage: redisStorage({ client: redis }),
31
- * });
32
- * ```
33
- *
34
- * @param config - Configuration object containing the Redis client and optional key prefix
35
- * @returns SecondaryStorage implementation for Better Auth
36
- */
37
- export function redisStorage(config: RedisStorageConfig) {
38
- const { client, keyPrefix = "better-auth:" } = config;
39
-
40
- const prefixKey = (key: string): string => {
41
- return `${keyPrefix}${key}`;
42
- };
43
-
44
- return {
45
- async get(key: string) {
46
- return client.get(prefixKey(key));
47
- },
48
-
49
- async set(key: string, value: string, ttl?: number | undefined) {
50
- const prefixedKey = prefixKey(key);
51
- if (ttl !== undefined && ttl > 0) {
52
- await client.setex(prefixedKey, ttl, value);
53
- } else {
54
- await client.set(prefixedKey, value);
55
- }
56
- },
57
-
58
- async delete(key: string) {
59
- await client.del(prefixKey(key));
60
- },
61
-
62
- async listKeys(): Promise<string[]> {
63
- const keys = await client.keys(`${keyPrefix}*`);
64
- return keys.map((key) => key.replace(keyPrefix, ""));
65
- },
66
-
67
- async clear(): Promise<void> {
68
- const keys = await client.keys(`${keyPrefix}*`);
69
- await client.del(...keys);
70
- },
71
- } satisfies SecondaryStorage & {
72
- listKeys: () => Promise<string[]>;
73
- clear: () => Promise<void>;
74
- };
75
- }
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./dist",
5
- "rootDir": "./src",
6
- "exactOptionalPropertyTypes": true
7
- },
8
- "include": ["src/**/*"],
9
- "exclude": ["node_modules", "dist", "**/*.test.ts"]
10
- }