Skip to content

Commit

Permalink
feat: upgrade axios (#909)
Browse files Browse the repository at this point in the history
* feat: upgrade axios

* chore: use boolean

* chore: fix check issues
  • Loading branch information
Cafe137 authored Mar 12, 2024
1 parent 46fbcdf commit 5076778
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
18 changes: 12 additions & 6 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 @@ -60,7 +60,7 @@
"dependencies": {
"@ethersphere/swarm-cid": "^0.1.0",
"@types/readable-stream": "^2.3.13",
"axios": "^0.27.2",
"axios": "^0.28.0",
"cafe-utility": "^15.0.2",
"elliptic": "^6.5.4",
"fetch-blob": "2.1.2",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class BeeResponseError extends BeeError {
public constructor(
message: string,
public code?: string,
public axiosStatus?: string,
public axiosStatus?: number,
public status?: number,
public config?: AxiosRequestConfig,
public request?: any,

Check warning on line 22 in src/utils/error.ts

View workflow job for this annotation

GitHub Actions / check (16.x)

Unexpected any. Specify a different type
Expand Down
3 changes: 2 additions & 1 deletion src/utils/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export async function http<T>(options: BeeRequestOptions, config: AxiosRequestCo
maybeRunOnRequestHook(options, requestConfig)
const response = await axios(requestConfig)

return response
// TODO: https://github.com/axios/axios/pull/6253
return response as AxiosResponse<T>
} catch (e: unknown) {
if (e instanceof AxiosError) {
throw new BeeResponseError(e.message, e.code, e.status, e.response?.status, e.config, e.request, e.response)
Expand Down
7 changes: 3 additions & 4 deletions src/utils/stream.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Readable as NodeReadableNative, ReadableOptions as NodeReadableOptions } from 'stream'
import { isStrictlyObject } from './type'
import { ReadableStream } from 'web-streams-polyfill'

import { Readable } from '../types'
import { isStrictlyObject } from './type'

const NodeReadable = NodeReadableNative || class {}

Expand All @@ -21,7 +20,7 @@ export function isReadableStream(entry: unknown): entry is ReadableStream {
return false
}

const browserReadable = entry as ReadableStream
const browserReadable = entry as unknown as ReadableStream

if (
typeof browserReadable.getReader === 'function' &&
Expand All @@ -41,7 +40,7 @@ export function isNodeReadable(entry: unknown): entry is NodeReadableNative {
return false
}

const nodeReadable = entry as NodeReadableNative
const nodeReadable = entry as unknown as NodeReadableNative

if (typeof nodeReadable.pipe === 'function' && nodeReadable.readable && typeof nodeReadable._read === 'function') {
return true
Expand Down
2 changes: 1 addition & 1 deletion src/utils/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export function isTag(value: unknown): value is Tag {
return false
}

return !!value.uid
return Boolean(value.uid)
}

export function assertTag(value: unknown): asserts value is Tag {
Expand Down

0 comments on commit 5076778

Please sign in to comment.