Skip to content

Commit 183fb91

Browse files
committed
fix: use authors hash for bsky author profile endpoint cache key
1 parent 0d952fa commit 183fb91

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

server/api/atproto/bluesky-author-profiles.get.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { AuthorSchema } from '#shared/schemas/blog'
44
import { Client } from '@atproto/lex'
55
import type { Author, ResolvedAuthor } from '#shared/schemas/blog'
66
import * as app from '#shared/types/lexicons/app'
7+
import * as crypto from 'node:crypto'
78

89
export default defineCachedEventHandler(
910
async event => {
@@ -75,7 +76,11 @@ export default defineCachedEventHandler(
7576
maxAge: CACHE_MAX_AGE_ONE_DAY,
7677
getKey: event => {
7778
const { authors } = getQuery(event)
78-
return `author-profiles:${authors ?? 'npmx.dev'}`
79+
if (!authors) {
80+
return 'author-profiles:npmx.dev'
81+
}
82+
const key = crypto.createHash('sha256').update(JSON.stringify(authors)).digest('hex')
83+
return `author-profiles:${key}`
7984
},
8085
},
8186
)

0 commit comments

Comments
 (0)