-
Notifications
You must be signed in to change notification settings - Fork 0
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: added the ability to connect request interceptors #25
base: main
Are you sure you want to change the base?
Conversation
37a9001
to
d445c77
Compare
d445c77
to
6551b53
Compare
lib/index.ts
Outdated
@@ -41,6 +50,7 @@ export interface SdkConfig { | |||
service?: string, | |||
action?: string, | |||
) => SdkActionFunc<TRequestData, TResponseData>; | |||
queriesInterceptors?: ScopeServiceQueryInterceptors[]; |
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.
May be call this option as axiosInterceptors
? The same naming used in gateway
@@ -23,6 +26,12 @@ export interface SdkActionFunc<TRequestData, TResponseData> { | |||
(data: TRequestData, options?: SdkActionOptions): CancellablePromise<TResponseData>; | |||
} | |||
|
|||
export type ScopeServiceQueryInterceptors = { | |||
scope?: string; | |||
service: 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.
If I get correctly we can set up interceptors per service? And to update cookie we will set interceptor for session-service
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.
Yes, interceptors are attached to the service, but this does not specifically mean session-service, but the service in the general form in which it is set for gateway actions, for example, "Backend". That is, here we do not just list all possible authentication methods, but for each service we hang the necessary interceptors module, depending on which authentication is used to access the api of this service. For example, we know that "passport" is used for the "Backend" service, and here we will connect to SDK the appropriate interceptors module for the passport. For some other service, for example, "Tracker", "passport" can also be used, and we will attach the same interceptors module to this service. And in the service, for example, "Cloud", we use "iam". Then we will hang a interceptors module on it that can update cookies during iam authentication. If we have such a interceptors module.
I want to add the ability to connect request interceptors that can perform certain actions before performing standard request processing.
Now, using this mechanism, we plan to connect handlers for different types of authentication, which, if there are certain cookies in the response, will trigger actions in the background to update the user's authorization cookies.