Skip to content

Commit 3907a78

Browse files
committed
fix: use hash for get bluesky profiles cache key
1 parent f458531 commit 3907a78

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
@@ -1,4 +1,5 @@
11
import * as v from 'valibot'
2+
import crypto from 'node:crypto'
23
import { CACHE_MAX_AGE_ONE_DAY, BLUESKY_API } from '#shared/utils/constants'
34
import { AuthorSchema } from '#shared/schemas/blog'
45
import { Client } from '@atproto/lex'
@@ -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+
const hash = crypto
80+
.createHash('md5')
81+
.update(JSON.stringify(authors ?? 'npmx.dev'))
82+
.digest('hex')
83+
return `author-profiles:${hash}`
7984
},
8085
},
8186
)

0 commit comments

Comments
 (0)