Skip to content

Commit ae31b44

Browse files
committed
fix: Revert "fix: use @supabase/node-fetch"
This reverts commit f290bb3.
1 parent f290bb3 commit ae31b44

File tree

7 files changed

+40
-46
lines changed

7 files changed

+40
-46
lines changed

package-lock.json

Lines changed: 17 additions & 22 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
},
3737
"homepage": "https://github.com/supabase/functions-js#readme",
3838
"dependencies": {
39-
"@supabase/node-fetch": "^2.6.13"
39+
"cross-fetch": "^3.1.5"
4040
},
4141
"devDependencies": {
4242
"@types/jest": "^28.1.0",

src/helper.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ export const resolveFetch = (customFetch?: Fetch): Fetch => {
55
if (customFetch) {
66
_fetch = customFetch
77
} else if (typeof fetch === 'undefined') {
8-
_fetch = (...args) =>
9-
import('@supabase/node-fetch' as any).then(({ default: fetch }) => fetch(...args))
8+
_fetch = async (...args) => await (await import('cross-fetch')).fetch(...args)
109
} else {
1110
_fetch = fetch
1211
}

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export type FunctionInvokeOptions = {
4949
/**
5050
* The HTTP verb of the request
5151
*/
52-
method?: 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE'
52+
method?: "POST"| "GET"| "PUT" | "PATCH" | "DELETE"
5353
/**
5454
* The body of the request.
5555
*/

test/functions/hijack/index.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import { serve } from 'https://deno.land/[email protected]/http/server.ts'
22

33
serve((req) => {
4-
const p = Deno.upgradeHttp(req)
5-
6-
// Run this async IIFE concurrently, first packet won't arrive
7-
// until we return HTTP101 response.
8-
;(async () => {
9-
const [conn, firstPacket] = await p
10-
const decoder = new TextDecoder()
11-
const text = decoder.decode(firstPacket)
12-
console.log(text)
13-
// Hello
14-
const uint8Array = new Uint8Array([72, 101, 108, 108, 111])
15-
conn.write(uint8Array)
16-
conn.close()
17-
})()
4+
const p = Deno.upgradeHttp(req);
5+
6+
(
7+
// Run this async IIFE concurrently, first packet won't arrive
8+
// until we return HTTP101 response.
9+
async () => {
10+
const [conn, firstPacket] = await p
11+
const decoder = new TextDecoder()
12+
const text = decoder.decode(firstPacket)
13+
console.log(text)
14+
// Hello
15+
const uint8Array = new Uint8Array([72, 101, 108, 108, 111])
16+
conn.write(uint8Array)
17+
conn.close()
18+
}
19+
)()
1820

1921
// HTTP101 - Switching Protocols
2022
return new Response(null, { status: 101 })

test/relay/container.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as fs from 'fs'
22
import { nanoid } from 'nanoid'
3-
// @ts-ignore
4-
import nodeFetch from '@supabase/node-fetch'
3+
import crossFetch from 'cross-fetch'
54
import { sign } from 'jsonwebtoken'
65
import { GenericContainer, Network, StartedTestContainer, Wait } from 'testcontainers'
76
import { ExecResult } from 'testcontainers/dist/docker/types'
@@ -88,7 +87,7 @@ export async function runRelay(
8887
log(`check function is healthy: ${slug + '-' + id}`)
8988
for (let ctr = 0; ctr < 30; ctr++) {
9089
try {
91-
const healthCheck = await nodeFetch(
90+
const healthCheck = await crossFetch(
9291
`http://localhost:${startedRelay.getMappedPort(8081)}/${slug}`,
9392
{
9493
method: 'POST',

test/utils/fetch.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// @ts-ignore
2-
import nodeFetch from '@supabase/node-fetch'
1+
import crossFetch from 'cross-fetch'
32

43
/**
54
* It returns a crossFetch function that uses overridden input: RequestInfo and init?: RequestInit for
@@ -12,5 +11,5 @@ export function getCustomFetch(
1211
reqInfo: RequestInfo | URL,
1312
reqInit?: RequestInit | undefined
1413
): (input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response> {
15-
return (input, init) => nodeFetch(reqInfo, reqInit)
14+
return (input, init) => crossFetch(reqInfo, reqInit)
1615
}

0 commit comments

Comments
 (0)