mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-18 09:30:06 +00:00
feat(sasjs-config): add optional attribute requestHistoryLimit
This commit is contained in:
@@ -1034,7 +1034,8 @@ export default class SASjs {
|
|||||||
: RequestClient
|
: RequestClient
|
||||||
this.requestClient = new RequestClientClass(
|
this.requestClient = new RequestClientClass(
|
||||||
this.sasjsConfig.serverUrl,
|
this.sasjsConfig.serverUrl,
|
||||||
this.sasjsConfig.httpsAgentOptions
|
this.sasjsConfig.httpsAgentOptions,
|
||||||
|
this.sasjsConfig.requestHistoryLimit
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
this.requestClient.setConfig(
|
this.requestClient.setConfig(
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ export interface HttpClient {
|
|||||||
|
|
||||||
export class RequestClient implements HttpClient {
|
export class RequestClient implements HttpClient {
|
||||||
private requests: SASjsRequest[] = []
|
private requests: SASjsRequest[] = []
|
||||||
|
private requestsLimit: number = 10
|
||||||
|
|
||||||
protected csrfToken: CsrfToken = { headerName: '', value: '' }
|
protected csrfToken: CsrfToken = { headerName: '', value: '' }
|
||||||
protected fileUploadCsrfToken: CsrfToken | undefined
|
protected fileUploadCsrfToken: CsrfToken | undefined
|
||||||
@@ -63,9 +64,11 @@ export class RequestClient implements HttpClient {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected baseUrl: string,
|
protected baseUrl: string,
|
||||||
httpsAgentOptions?: https.AgentOptions
|
httpsAgentOptions?: https.AgentOptions,
|
||||||
|
requestsLimit?: number
|
||||||
) {
|
) {
|
||||||
this.createHttpClient(baseUrl, httpsAgentOptions)
|
this.createHttpClient(baseUrl, httpsAgentOptions)
|
||||||
|
if (requestsLimit) this.requestsLimit = requestsLimit
|
||||||
}
|
}
|
||||||
|
|
||||||
public setConfig(baseUrl: string, httpsAgentOptions?: https.AgentOptions) {
|
public setConfig(baseUrl: string, httpsAgentOptions?: https.AgentOptions) {
|
||||||
@@ -149,7 +152,7 @@ export class RequestClient implements HttpClient {
|
|||||||
SASWORK: sasWork
|
SASWORK: sasWork
|
||||||
})
|
})
|
||||||
|
|
||||||
if (this.requests.length > 20) {
|
if (this.requests.length > this.requestsLimit) {
|
||||||
this.requests.splice(0, 1)
|
this.requests.splice(0, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ export class SASjsConfig {
|
|||||||
* Supported login mechanisms are - Redirected and Default
|
* Supported login mechanisms are - Redirected and Default
|
||||||
*/
|
*/
|
||||||
loginMechanism: LoginMechanism = LoginMechanism.Default
|
loginMechanism: LoginMechanism = LoginMechanism.Default
|
||||||
|
/**
|
||||||
|
* Optional settings to configure limit for requests history
|
||||||
|
*/
|
||||||
|
requestHistoryLimit?: number = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum LoginMechanism {
|
export enum LoginMechanism {
|
||||||
|
|||||||
Reference in New Issue
Block a user