Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion server/api/atproto/bluesky-author-profiles.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AuthorSchema } from '#shared/schemas/blog'
import { Client } from '@atproto/lex'
import type { Author, ResolvedAuthor } from '#shared/schemas/blog'
import * as app from '#shared/types/lexicons/app'
import * as crypto from 'node:crypto'

export default defineCachedEventHandler(
async event => {
Expand Down Expand Up @@ -75,7 +76,11 @@ export default defineCachedEventHandler(
maxAge: CACHE_MAX_AGE_ONE_DAY,
getKey: event => {
const { authors } = getQuery(event)
return `author-profiles:${authors ?? 'npmx.dev'}`
if (!authors) {
return 'author-profiles:npmx.dev'
}
const key = crypto.createHash('sha256').update(JSON.stringify(authors)).digest('hex')
return `author-profiles:${key}`
},
},
)
4 changes: 4 additions & 0 deletions server/plugins/oauth-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import type { NodeOAuthClient } from '@atproto/oauth-client-node'
* Creates a long living instance of the NodeOAuthClient.
*/
export default defineNitroPlugin(async nitroApp => {
if (import.meta.test) {
return
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

const oauthClient = await getNodeOAuthClient()

// Attach to event context for access in composables via useRequestEvent()
Expand Down
Loading