1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-17 17:10:05 +00:00

feat(sasjs-config): add optional attribute requestHistoryLimit

This commit is contained in:
2022-02-17 23:39:55 +05:00
parent 9728ebd98d
commit fe3f6d6287
3 changed files with 11 additions and 3 deletions

View File

@@ -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(

View File

@@ -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)
} }
} }

View File

@@ -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 {