Skip to content

Commit

Permalink
feat: add supports for Bun proxy and unix #10
Browse files Browse the repository at this point in the history
  • Loading branch information
fzn0x committed Jun 18, 2024
1 parent 759a8b0 commit 4124968
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/types/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export interface RequestOptions extends RequestInit {
timeout?: number // Timeout in milliseconds
retryOnTimeout?: boolean // New option to retry on timeout errors
params?: Record<string, string | number> // URLSearchParams option
proxy?: string
unix?: string
}

export type RequestFunction = (
Expand Down
34 changes: 34 additions & 0 deletions src/utils/create-request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,38 @@ describe('createRequest', () => {
expect((err as Error).message).equals('fetch failed')
}
})

it('Bun supports proxy', async () => {
try {
await createRequest(
'http://localhost',
{
proxy: 'https://username:password@proxy.example.com:8080',
},
{},
{
throwOnError: true,
}
)
} catch (err) {
expect((err as Error).message).equals('fetch failed')
}
})

it('Bun supports unix', async () => {
try {
await createRequest(
'http://localhost',
{
unix: '/var/run/docker.sock',
},
{},
{
throwOnError: true,
}
)
} catch (err) {
expect((err as Error).message).equals('fetch failed')
}
})
})

0 comments on commit 4124968

Please sign in to comment.