-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: introduce
make-fetch-happen
(#44)
- Loading branch information
Showing
12 changed files
with
656 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import path from 'node:path'; | ||
import fs from 'node:fs'; | ||
import makeFetchHappen from 'make-fetch-happen'; | ||
// eslint-disable-next-line @typescript-eslint/no-restricted-imports -- type only | ||
export type { Response as NodeFetchResponse } from 'node-fetch'; | ||
|
||
const cachePath = path.resolve(__dirname, '../../.cache/__make_fetch_happen__'); | ||
fs.mkdirSync(cachePath, { recursive: true }); | ||
|
||
export const $fetch = makeFetchHappen.defaults({ | ||
cachePath, | ||
maxSockets: 32, /** | ||
* They said 15 is a good default that prevents knocking out others' routers, | ||
* I disagree. 32 is a good number. | ||
*/ | ||
headers: { | ||
'User-Agent': 'curl/8.9.1 (https://github.com/SukkaW/Surge)' | ||
}, | ||
retry: { | ||
retries: 5, | ||
randomize: true | ||
} | ||
}); |
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
Oops, something went wrong.