[READ-ONLY] a fast, modern browser for the npm registry
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: add back search util

+22 -2
+22 -2
app/composables/useNpmRegistry.ts
··· 14 14 return await $fetch<Packument>(`${NPM_REGISTRY}/${encodedName}`) 15 15 } 16 16 17 + async function searchNpmPackages( 18 + query: string, 19 + options: { 20 + size?: number 21 + from?: number 22 + quality?: number 23 + popularity?: number 24 + maintenance?: number 25 + } = {}, 26 + ): Promise<NpmSearchResponse> { 27 + const params = new URLSearchParams() 28 + params.set('text', query) 29 + if (options.size) params.set('size', String(options.size)) 30 + if (options.from) params.set('from', String(options.from)) 31 + if (options.quality !== undefined) params.set('quality', String(options.quality)) 32 + if (options.popularity !== undefined) params.set('popularity', String(options.popularity)) 33 + if (options.maintenance !== undefined) params.set('maintenance', String(options.maintenance)) 34 + 35 + return await $fetch<NpmSearchResponse>(`${NPM_REGISTRY}/-/v1/search?${params.toString()}`) 36 + } 37 + 17 38 async function fetchNpmDownloads( 18 39 packageName: string, 19 40 period: 'last-day' | 'last-week' | 'last-month' | 'last-year' = 'last-week', ··· 120 141 from?: number 121 142 }> = {}, 122 143 ) { 123 - const registry = useNpmRegistry() 124 144 let lastSearch: NpmSearchResponse | undefined = undefined 125 145 126 146 return useLazyAsyncData( ··· 130 150 if (!q.trim()) { 131 151 return Promise.resolve(emptySearchResponse) 132 152 } 133 - return lastSearch = await registry.searchPackages(q, toValue(options)) 153 + return lastSearch = await searchNpmPackages(q, toValue(options)) 134 154 }, 135 155 { default: () => lastSearch || emptySearchResponse }, 136 156 )