2020-08-20 18:51:07 +00:00
|
|
|
const fetch = process.server ? require('node-fetch/lib/index.js') : require('node-fetch/browser.js')
|
|
|
|
|
2020-06-12 15:43:59 +00:00
|
|
|
const AbortController = require('abort-controller')
|
|
|
|
|
|
|
|
const TEN_MEGABYTES = 1000 * 1000 * 10
|
|
|
|
|
|
|
|
if (!global.fetch) {
|
|
|
|
global.fetch = (url, options) => fetch(url, { highWaterMark: TEN_MEGABYTES, ...options })
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!global.Headers) {
|
|
|
|
global.Headers = fetch.Headers
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!global.Request) {
|
|
|
|
global.Request = fetch.Request
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!global.Response) {
|
|
|
|
global.Response = fetch.Response
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!global.AbortController) {
|
|
|
|
global.AbortController = AbortController
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!global.ReadableStream) {
|
|
|
|
try {
|
|
|
|
global.ReadableStream = require('web-streams-polyfill/ponyfill/es2018')
|
|
|
|
} catch (_) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = require('ky/umd')
|