-
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.
- Loading branch information
1 parent
452598e
commit 6e5b3c1
Showing
5 changed files
with
199 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
import axiosRetry from 'axios-retry'; | ||
import axios from 'axios'; | ||
import axios, {AxiosResponse} from 'axios'; | ||
import ci from 'ci-info'; | ||
|
||
import pkg from '../../package.json'; | ||
|
||
const {version} = pkg; | ||
|
||
const prInfo = typeof ci.isPR === 'boolean' ? `(PR: ${ci.isPR})` : ''; | ||
|
||
export const client = axios.create({ | ||
headers: { | ||
'user-agent': `crr/${version} ${ci.name} ${prInfo}`, | ||
'user-agent': [ | ||
`crr/${version}`, | ||
ci.name, | ||
typeof ci.isPR === 'boolean' ? `(PR: ${ci.isPR})` : null, | ||
] | ||
.filter(Boolean) | ||
.join(' '), | ||
}, | ||
}); | ||
axiosRetry(client, {retries: 3}); | ||
|
||
/** | ||
* extract the request id from the response object | ||
*/ | ||
export function getRequestId(response: AxiosResponse) { | ||
return ( | ||
response.headers['x-request-id'] || response.headers['x-amz-request-id'] | ||
); | ||
} |
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