Skip to content

Commit 3d88dfb

Browse files
committed
wk:auth:feat: implement secondary storage for betterAuth using DEEPCRAWL_AUTH_KV
1 parent 3c3c2d6 commit 3d88dfb

2 files changed

Lines changed: 19 additions & 27 deletions

File tree

apps/workers/auth/src/lib/better-auth/index.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,24 @@ export function createAuth(env: CloudflareBindings) {
99

1010
return betterAuth({
1111
...authConfigs,
12+
secondaryStorage: {
13+
get: async (key: string) => {
14+
return env.DEEPCRAWL_AUTH_KV.get(key);
15+
},
16+
set: async (key: string, value: string, ttl?: number) => {
17+
return env.DEEPCRAWL_AUTH_KV.put(
18+
key,
19+
value,
20+
ttl ? { expirationTtl: ttl } : undefined,
21+
);
22+
},
23+
delete: async (key: string) => {
24+
return env.DEEPCRAWL_AUTH_KV.delete(key);
25+
},
26+
},
27+
rateLimit: {
28+
...authConfigs.rateLimit,
29+
storage: 'secondary-storage',
30+
},
1231
});
1332
}

apps/workers/auth/src/lib/better-auth/options.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)