Files
bsky-social-app/src/state/queries/service.ts
T
Samuel Newman ffba34c548 add createLexClient factory with strictResponseProcessing: false
lex-client's strict mode rejects the legacy blob reference format
({cid, mimeType}) still present in older records; the old stack
tolerated it. Route all client construction through the factory.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-30 18:21:02 +03:00

33 lines
899 B
TypeScript

import {useQuery} from '@tanstack/react-query'
import {createLexClient} from '#/lib/lexClient'
import {com} from '#/lexicons'
const RQKEY_ROOT = 'service'
export const RQKEY = (serviceUrl: string) => [RQKEY_ROOT, serviceUrl]
export function useServiceQuery(serviceUrl: string) {
return useQuery({
queryKey: RQKEY(serviceUrl),
queryFn: async () => {
/*
* Unauthenticated throwaway client pointed at the candidate service -
* describeServer is a public endpoint on the target PDS/entryway.
*/
const client = createLexClient({service: serviceUrl})
return await client.call(com.atproto.server.describeServer)
},
enabled: isValidUrl(serviceUrl),
})
}
function isValidUrl(url: string) {
try {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const urlp = new URL(url)
return true
} catch {
return false
}
}