-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: add clearTimeout in get request * style: remove one line code * feat: add https checker * fix: split nodos before init promise. * fix: add protocol support when request node info status * feat: add node health * feat: add finalization * style: fix lint, and disable unuse build script * fix: change params to required Co-authored-by: OlegMakarenko <33131259+OlegMakarenko@users.noreply.github.com>
- Loading branch information
Showing
8 changed files
with
185 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
import axios, { AxiosResponse, AxiosRequestConfig } from 'axios'; | ||
const REQEST_TIMEOUT = 10000; | ||
import { monitor } from '@src/config'; | ||
|
||
const REQEST_TIMEOUT = monitor.REQUEST_TIMEOUT; | ||
|
||
export class HTTP { | ||
static get(url: string, config?: AxiosRequestConfig | undefined): Promise<AxiosResponse<any>> { | ||
return new Promise<AxiosResponse<any>>((resolve, reject) => { | ||
setTimeout(() => { | ||
const timeout = setTimeout(() => { | ||
reject(Error(`HTTP get request failed. Timeout error`)); | ||
}, REQEST_TIMEOUT + REQEST_TIMEOUT * 0.1); | ||
|
||
axios | ||
.get(url, { timeout: REQEST_TIMEOUT, ...config }) | ||
.then(resolve) | ||
.catch(reject); | ||
.then((response) => { | ||
clearTimeout(timeout); | ||
resolve(response); | ||
}) | ||
.catch((e) => { | ||
clearTimeout(timeout); | ||
reject(e); | ||
}); | ||
}); | ||
} | ||
} |