Skip to content

Commit

Permalink
WIP of upgrading fetch to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
sofisl committed Feb 14, 2025
1 parent 2387b66 commit d8e79bb
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 64 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"dependencies": {
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.0",
"node-fetch": "^2.7.0",
"node-fetch": "^3.3.2",
"stream-events": "^1.0.5",
"uuid": "^11.0.5"
},
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@

import {Agent, AgentOptions as HttpsAgentOptions} from 'https';
import {AgentOptions as HttpAgentOptions} from 'http';
import fetch, * as f from 'node-fetch';
import type * as f from 'node-fetch' with {'resolution-mode': 'import'};
import {PassThrough, Readable, pipeline} from 'stream';
import * as uuid from 'uuid';
import {getAgent} from './agents';
import {TeenyStatistics} from './TeenyStatistics';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const streamEvents = require('stream-events');
const fetch = (...args: any[]) =>

Check warning on line 27 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
import('node-fetch').then(({default: fetch}) => fetch([...args] as any));

Check warning on line 28 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

export interface CoreOptions {
method?: string;
Expand Down Expand Up @@ -152,7 +154,7 @@ function fetchToRequestResponse(opts: f.RequestInit, res: f.Response) {
const resHeaders = {} as Headers;
res.headers.forEach((value, key) => (resHeaders[key] = value));

const response = Object.assign(res.body, {
const response = Object.assign(res.body as any, {

Check warning on line 157 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
statusCode: res.status,
statusMessage: res.statusText,
request,
Expand Down
2 changes: 1 addition & 1 deletion test/TeenyStatistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import * as assert from 'assert';
import assert from 'assert';
import {afterEach, before, beforeEach, describe, it} from 'mocha';
import * as sinon from 'sinon';
import {
Expand Down
2 changes: 1 addition & 1 deletion test/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import * as assert from 'assert';
import assert from 'assert';
import {describe, it, afterEach} from 'mocha';
import * as http from 'http';
import * as https from 'https';
Expand Down
Loading

0 comments on commit d8e79bb

Please sign in to comment.