-
Notifications
You must be signed in to change notification settings - Fork 541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add optional methods to the cache store #3747
base: main
Are you sure you want to change the base?
feat: add optional methods to the cache store #3747
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me,
Please add types too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add type checks for the new methods in assertCacheStore
please
Line 184 in 3030506
function assertCacheStore (store, name = 'CacheStore') { |
types/cache-interceptor.d.ts
Outdated
@@ -88,6 +92,10 @@ declare namespace CacheHandler { | |||
|
|||
get isFull (): boolean | |||
|
|||
getOrigins (): Promise<string[]> | |||
|
|||
getRoutesByOrigin (origin: string): Promise<{ method: string, path: string }[]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit but would prefer if the { method: string, path: string }
type was defined outside of the fn declaration so it can be referenced elsewhere if needed (incl user space)
i.e.
export interface RouteByOrigin {
method: string
path: string
}
export interface CacheStore {
getRoutesByOrigin(origin: string): Promise<RouteByOrigin[]>
// ...
}
I'm not sure about that as these methods are optional, because they are not used by the undici package. |
Ci does not look green |
It fails in the main with the same error. |
I make it a draft for now. Not sure about the interface. |
The idea of this PR is to add some optional methods to the cache store that might not be used by the interceptor, but are useful for managing the cache. Right now it's hard to invalidate the cache from the outside of the package, because there is no way to know what values have been cached.
Any ideas about the intercase for these methods are welcome. I'm opening it's as a draft because it's missing a docs at least.