Skip to content

Commit 1bb55b8

Browse files
committed
fix: replace unlisted @atproto/syntax import and fix typo in identity.ts
1 parent a3b6cc0 commit 1bb55b8

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

server/utils/atproto/utils/identity.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { Client } from '@atproto/lex'
2-
import { ensureValidAtIdentifier } from '@atproto/syntax'
1+
import { Client, isAtIdentifierString } from '@atproto/lex'
32
import * as blue from '#shared/types/lexicons/blue'
43

54
const HEADERS = { 'User-Agent': 'npmx' }
65

7-
// Aggersive cache on identity since that doesn't change a ton
6+
// Aggressive cache on identity since that doesn't change a ton
87
const CACHE_MAX_AGE_IDENTITY = CACHE_MAX_AGE_ONE_HOUR * 6
98

109
const CACHE_KEY_IDENTITY = (identity: string) => `identity:${identity}`
@@ -24,15 +23,20 @@ export class IdentityUtils {
2423
* @param identifier - A users did or handle
2524
* @returns
2625
*/
27-
async getMiniDoc(identifier: string): Promise<blue.microcosm.identity.resolveMiniDoc.OutputBody> {
28-
ensureValidAtIdentifier(identifier)
26+
async getMiniDoc(
27+
identifier: string,
28+
): Promise<blue.microcosm.identity.resolveMiniDoc.$OutputBody> {
29+
if (!isAtIdentifierString(identifier)) {
30+
throw createError({ status: 400, message: 'Invalid AT Protocol identifier' })
31+
}
2932
const cacheKey = CACHE_KEY_IDENTITY(identifier)
30-
const cached = await this.cache.get<blue.microcosm.identity.resolveMiniDoc.OutputBody>(cacheKey)
33+
const cached =
34+
await this.cache.get<blue.microcosm.identity.resolveMiniDoc.$OutputBody>(cacheKey)
3135
if (cached) {
3236
return cached
3337
}
3438
const result = await this.slingShotClient.call(blue.microcosm.identity.resolveMiniDoc, {
35-
identifier: identifier,
39+
identifier,
3640
})
3741
await this.cache.set(cacheKey, result, CACHE_MAX_AGE_IDENTITY)
3842
return result

0 commit comments

Comments
 (0)