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