Skip to content

Commit

Permalink
feat: add a timeout to Config and Squid (#254)
Browse files Browse the repository at this point in the history
Co-authored-by: Juan Manuel Villarraza <[email protected]>
  • Loading branch information
silasbw and jmdev3 authored Dec 6, 2023
1 parent 140e248 commit dc62cc0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/adapter/HttpAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export default class HttpAdapter {
constructor(config: RequestConfig) {
this.axios = axios.create({
...omit(config, ["config"]),
baseURL: config?.baseUrl
baseURL: config?.baseUrl,
timeout: config?.timeout
});

if (config) {
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export class Squid extends TokensChains {
config,
headers: {
"x-integrator-id": config.integratorId
}
},
timeout: config.timeout
});

this.config = {
Expand All @@ -63,7 +64,8 @@ export class Squid extends TokensChains {
config,
headers: {
"x-integrator-id": config.integratorId || "squid-sdk"
}
},
timeout: config.timeout
});
this.config = {
baseUrl: config?.baseUrl || baseUrl,
Expand Down
1 change: 1 addition & 0 deletions src/types/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export interface RequestConfig {
baseUrl?: string;
config?: Config;
headers?: Record<string, string | number | boolean>;
timeout?: number;
}
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type Config = {
logging?: boolean;
logLevel?: LogLevel;
integratorId: string;
timeout?: number;
};

export type OverrideParams = GasData;
Expand Down

0 comments on commit dc62cc0

Please sign in to comment.