File tree Expand file tree Collapse file tree
server/utils/atproto/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { FetchError } from 'ofetch'
22import { handleAuthError } from '~/utils/atproto/helpers'
3-
4- // TODO: I need to share a type with the backend likes service
5- export type PackageLikes = {
6- totalLikes : number
7- userHasLiked : boolean
8- }
3+ import type { PackageLikes } from '#shared/types/social'
94
105export type LikeResult = { success : true ; data : PackageLikes } | { success : false ; error : Error }
116
Original file line number Diff line number Diff line change 11import { $nsid as likeNsid } from '#shared/types/lexicons/dev/npmx/feed/like.defs'
22import type { Backlink } from '#shared/utils/constellation'
33
4- /**
5- * Likes for a npm package on npmx
6- */
7- export type PackageLikes = {
8- // The total likes found for the package
9- totalLikes : number
10- // If the logged in user has liked the package, false if not logged in
11- userHasLiked : boolean
12- }
13-
144//Cache keys and helpers
155const CACHE_PREFIX = 'atproto-likes:'
166const CACHE_PACKAGE_TOTAL_KEY = ( packageName : string ) => `${ CACHE_PREFIX } ${ packageName } :total`
@@ -88,7 +78,7 @@ export class PackageLikesUtils {
8878 * @param usersDid
8979 * @returns
9080 */
91- async getLikes ( packageName : string , usersDid ?: string | undefined ) {
81+ async getLikes ( packageName : string , usersDid ?: string | undefined ) : Promise < PackageLikes > {
9282 //TODO: May need to do some clean up on the package name, and maybe even hash it? some of the charcteres may be a bit odd as keys
9383 const totalLikesKey = CACHE_PACKAGE_TOTAL_KEY ( packageName )
9484 const subjectRef = PACKAGE_SUBJECT_REF ( packageName )
Original file line number Diff line number Diff line change 1+ /**
2+ * Likes for a npm package on npmx
3+ */
4+ export type PackageLikes = {
5+ // The total likes found for the package
6+ totalLikes : number
7+ // If the logged in user has liked the package, false if not logged in
8+ userHasLiked : boolean
9+ }
You can’t perform that action at this time.
0 commit comments