Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use @supabase/node-fetch #179

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 60 additions & 84 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"docs:json": "typedoc --json docs/v2/spec.json --entryPoints src/index.ts --entryPoints src/packages/* --excludePrivate --excludeExternals --excludeProtected"
},
"dependencies": {
"cross-fetch": "^3.1.5"
"@supabase/node-fetch": "^2.6.14"
},
"devDependencies": {
"@types/jest": "^26.0.13",
Expand Down
8 changes: 5 additions & 3 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ export const resolveFetch = (customFetch?: Fetch): Fetch => {
if (customFetch) {
_fetch = customFetch
} else if (typeof fetch === 'undefined') {
_fetch = async (...args) => await (await import('cross-fetch')).fetch(...args)
_fetch = (...args) =>
import('@supabase/node-fetch' as any).then(({ default: fetch }) => fetch(...args))
} else {
_fetch = fetch
}
return (...args) => _fetch(...args)
}

export const resolveResponse = async () => {
export const resolveResponse = async (): Promise<typeof Response> => {
if (typeof Response === 'undefined') {
return (await import('cross-fetch')).Response
// @ts-ignore
return (await import('@supabase/node-fetch' as any)).Response
}

return Response
Expand Down
3 changes: 2 additions & 1 deletion test/storageFileApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import * as fs from 'fs'
import * as path from 'path'
import FormData from 'form-data'
import assert from 'assert'
import fetch from 'cross-fetch'
// @ts-ignore
import fetch from '@supabase/node-fetch'

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