Skip to content

Commit e8b2f5a

Browse files
committed
refactor: unify atproto caches
1 parent cf74f55 commit e8b2f5a

5 files changed

Lines changed: 6 additions & 18 deletions

File tree

modules/cache.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ export default defineNuxtModule({
3030

3131
const env = process.env.VERCEL_ENV
3232

33-
nitroConfig.storage['oauth-atproto-state'] = {
34-
driver: env === 'production' ? 'vercel-kv' : 'vercel-runtime-cache',
35-
}
36-
37-
nitroConfig.storage['oauth-atproto-session'] = {
33+
nitroConfig.storage.atproto = {
3834
driver: env === 'production' ? 'vercel-kv' : 'vercel-runtime-cache',
3935
}
4036
})

nuxt.config.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,9 @@ export default defineNuxtConfig({
152152
driver: 'fsLite',
153153
base: './.cache/fetch',
154154
},
155-
'oauth-atproto-state': {
155+
'atproto': {
156156
driver: 'fsLite',
157-
base: './.cache/atproto-oauth/state',
158-
},
159-
'oauth-atproto-session': {
160-
driver: 'fsLite',
161-
base: './.cache/atproto-oauth/session',
162-
},
163-
'generic-cache': {
164-
driver: 'fsLite',
165-
base: './.cache/generic',
157+
base: './.cache/atproto',
166158
},
167159
},
168160
typescript: {

server/utils/atproto/oauth-session-store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { H3Event } from 'h3'
44
/**
55
* Storage key prefix for oauth session storage.
66
*/
7-
export const OAUTH_SESSION_CACHE_STORAGE_BASE = 'oauth-atproto-session'
7+
export const OAUTH_SESSION_CACHE_STORAGE_BASE = 'atproto:oauth-session'
88

99
export class OAuthSessionStore implements NodeSavedSessionStore {
1010
// TODO: not sure if we will support multi accounts, but if we do in the future will need to change this around

server/utils/atproto/oauth-state-store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { H3Event } from 'h3'
44
/**
55
* Storage key prefix for oauth state storage.
66
*/
7-
export const OAUTH_STATE_CACHE_STORAGE_BASE = 'oauth-atproto-state'
7+
export const OAUTH_STATE_CACHE_STORAGE_BASE = 'atproto:oauth-state'
88

99
export class OAuthStateStore implements NodeSavedStateStore {
1010
private readonly cookieKey = 'oauth:atproto:state'

server/utils/cache/local.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function isCacheEntryStale(entry: LocalCachedEntry): boolean {
2323
* Local implmentation of a cache to be used during development
2424
*/
2525
export class LocalCacheAdapter implements CacheAdapter {
26-
private readonly storage = useStorage('generic-cache')
26+
private readonly storage = useStorage('atproto:generic')
2727

2828
async get<T>(key: string): Promise<T | undefined> {
2929
const result = await this.storage.getItem<LocalCachedEntry<T>>(key)

0 commit comments

Comments
 (0)