Skip to content

Commit

Permalink
chore: switch isomorphic-fetch to node-fetch
Browse files Browse the repository at this point in the history
OKTA-372920
<<<Jenkins Check-In of Tested SHA: 6257180 for [email protected]>>>
Artifact: okta-sdk-nodejs
Files changed count: 5
PR Link: "#308"
  • Loading branch information
jaredperreault-okta authored and eng-prod-CI-bot-okta committed Mar 3, 2022
1 parent 4c0953a commit 718f0ae
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .bacon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test_suites:
- name: e2e
script_path: /root/okta/okta-sdk-nodejs/scripts
sort_order: '1'
timeout: '20'
timeout: '30'
script_name: e2e
criteria: MERGE
queue_name: small
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"deep-copy": "^1.4.2",
"form-data": "^4.0.0",
"https-proxy-agent": "^5.0.0",
"isomorphic-fetch": "^3.0.0",
"js-yaml": "^4.1.0",
"lodash": "^4.17.20",
"njwt": "^1.0.0",
"node-fetch": "^2.6.7",
"parse-link-header": "^2.0.0",
"rasha": "^1.2.5",
"safe-flat": "^2.0.2"
Expand Down
4 changes: 2 additions & 2 deletions src/request-executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
*/

const EventEmitter = require('events').EventEmitter;
const isoFetch = require('isomorphic-fetch');
const nodeFetch = require('node-fetch');

class RequestExecutor extends EventEmitter {
fetch(request) {
this.emit('request', request);
return isoFetch(request.url, request).then(response => {
return nodeFetch(request.url, request).then(response => {
this.emit('response', response);
return response;
});
Expand Down
6 changes: 3 additions & 3 deletions test/jest/request-executor.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const mockResponse = { status: 200 };
jest.mock('isomorphic-fetch', () => {
jest.mock('node-fetch', () => {
return jest.fn().mockReturnValue(Promise.resolve(mockResponse));
});

const RequestExecutor = require('../../src/request-executor');
const isoFetch = require('isomorphic-fetch');
const isoFetch = require('node-fetch');

describe('RequestExecutor', () => {

describe('.fetch()', () => {

it('should delegate requests to isomorphic-fetch as (url, request)', async () => {
it('should delegate requests to node-fetch as (url, request)', async () => {
const requestExecutor = new RequestExecutor();
const request = { url: '/foo' };
await requestExecutor.fetch(request);
Expand Down
15 changes: 1 addition & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2380,14 +2380,6 @@ isexe@^2.0.0:
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=

isomorphic-fetch@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-3.0.0.tgz#0267b005049046d2421207215d45d6a262b8b8b4"
integrity sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==
dependencies:
node-fetch "^2.6.1"
whatwg-fetch "^3.4.1"

istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.0.0-alpha.1:
version "3.0.0"
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz#f5944a37c70b550b02a78a5c3b2055b280cec8ec"
Expand Down Expand Up @@ -3381,7 +3373,7 @@ njwt@^1.0.0:
ecdsa-sig-formatter "^1.0.5"
uuid "^3.3.2"

node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.7:
node-fetch@^2.6.0, node-fetch@^2.6.7:
version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
Expand Down Expand Up @@ -4479,11 +4471,6 @@ whatwg-encoding@^1.0.5:
dependencies:
iconv-lite "0.4.24"

whatwg-fetch@^3.4.1:
version "3.6.2"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz#dced24f37f2624ed0281725d51d0e2e3fe677f8c"
integrity sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA==

whatwg-mimetype@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf"
Expand Down

0 comments on commit 718f0ae

Please sign in to comment.