Skip to content

Commit 3640e8a

Browse files
committed
fix: use @supabase/node-fetch
1 parent b2e3486 commit 3640e8a

File tree

4 files changed

+68
-89
lines changed

4 files changed

+68
-89
lines changed

package-lock.json

Lines changed: 60 additions & 84 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"docs:json": "typedoc --json docs/v2/spec.json --entryPoints src/index.ts --entryPoints src/packages/* --excludePrivate --excludeExternals --excludeProtected"
3737
},
3838
"dependencies": {
39-
"cross-fetch": "^3.1.5"
39+
"@supabase/node-fetch": "^2.6.13"
4040
},
4141
"devDependencies": {
4242
"@types/jest": "^26.0.13",

src/lib/helpers.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ export const resolveFetch = (customFetch?: Fetch): Fetch => {
55
if (customFetch) {
66
_fetch = customFetch
77
} else if (typeof fetch === 'undefined') {
8-
_fetch = async (...args) => await (await import('cross-fetch')).fetch(...args)
8+
_fetch = (...args) =>
9+
import('@supabase/node-fetch' as any).then(({ default: fetch }) => fetch(...args))
910
} else {
1011
_fetch = fetch
1112
}
1213
return (...args) => _fetch(...args)
1314
}
1415

15-
export const resolveResponse = async () => {
16+
export const resolveResponse = async (): Promise<typeof Response> => {
1617
if (typeof Response === 'undefined') {
17-
return (await import('cross-fetch')).Response
18+
// @ts-ignore
19+
return (await import('@supabase/node-fetch' as any)).Response
1820
}
1921

2022
return Response

test/storageFileApi.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import * as fs from 'fs'
44
import * as path from 'path'
55
import FormData from 'form-data'
66
import assert from 'assert'
7-
import fetch from 'cross-fetch'
7+
// @ts-ignore
8+
import fetch from '@supabase/node-fetch'
89

910
// TODO: need to setup storage-api server for this test
1011
const URL = 'http://localhost:8000/storage/v1'

0 commit comments

Comments
 (0)