File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import type { Packument } from '#shared/types'
22import { encodePackageName , fetchLatestVersion as _fetchLatestVersion } from '#shared/utils/npm'
33import { maxSatisfying , prerelease } from 'semver'
4+ import { CACHE_MAX_AGE_FIVE_MINUTES } from '#shared/utils/constants'
45
56const NPM_REGISTRY = 'https://registry.npmjs.org'
67
@@ -10,7 +11,7 @@ export const fetchNpmPackage = defineCachedFunction(
1011 return await $fetch < Packument > ( `${ NPM_REGISTRY } /${ encodedName } ` )
1112 } ,
1213 {
13- maxAge : 60 * 5 ,
14+ maxAge : CACHE_MAX_AGE_FIVE_MINUTES ,
1415 swr : true ,
1516 name : 'npm-package' ,
1617 getKey : ( name : string ) => name ,
Original file line number Diff line number Diff line change 11// Duration
22export const CACHE_MAX_AGE_ONE_MINUTE = 60
3+ export const CACHE_MAX_AGE_FIVE_MINUTES = 60 * 5
34export const CACHE_MAX_AGE_ONE_HOUR = 60 * 60
45export const CACHE_MAX_AGE_ONE_DAY = 60 * 60 * 24
56export const CACHE_MAX_AGE_ONE_YEAR = 60 * 60 * 24 * 365
You can’t perform that action at this time.
0 commit comments