Skip to content

Commit d338167

Browse files
refactor: return package response
1 parent c768c33 commit d338167

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

app/composables/useNpmRegistry.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ export function useNpmSearch(
346346
if ((error as NpmSearchError)?.data?.code === 'ERR_TEXT_LENGTH') {
347347
try {
348348
const encodedName = encodePackageName(q)
349-
const [{ data: pkg }, { data: downloads }] = await Promise.all([
349+
const [{ data: pkg, isStale }, { data: downloads }] = await Promise.all([
350350
cachedFetch<Packument>(`${NPM_REGISTRY}/${encodedName}`, { signal }),
351351
cachedFetch<NpmDownloadCount>(`${NPM_API}/downloads/point/last-week/${encodedName}`, {
352352
signal,
@@ -365,12 +365,7 @@ export function useNpmSearch(
365365
total: 1,
366366
}
367367

368-
return {
369-
objects: [result],
370-
total: 1,
371-
isStale: false,
372-
time: new Date().toISOString(),
373-
}
368+
return { ...pkg, isStale }
374369
} catch {
375370
// If exact lookup also fails, throw original error
376371
throw error

0 commit comments

Comments
 (0)